concept format in category jupyter

appears as: formats, format
Machine Learning for Business: Using Amazon SageMaker and Jupyter

This is an excerpt from Manning's book Machine Learning for Business: Using Amazon SageMaker and Jupyter.

You can see that the data has a single customer per row and that it reflects the format of the data in table 3.3. The first column in table 3.4 indicates whether the customer churned or did not churn. If the customer churned, the first column contains a 1. If they remain a customer, it should show a 0. Note that these data rows are provided by way of example, and the rows of data you see might be different.

Listing 4.8. Transforming each row to the format used by BlazingText
def preprocess(df):
    all_rows = df.values.tolist()                       #1
    transformed_rows = list(
      map(transform_instance, all_rows))                #2
    transformed_df = pd.DataFrame(transformed_rows)         #3
    return transformed_df                               #4

def transform_instance(row):
    cur_row = []                                        #5
    label = '__label__1' if row[5] == True \
        else '__label__0'                               #6
    cur_row.append(label)                               #7
    cur_row.extend(
        nltk.word_tokenize(row[4].lower()))             #8
    return cur_row                                      #9

transformed_validation_rows = preprocess(val_df)        #10
display(transformed_validation_rows.head())             #11