<jupyter_start><jupyter_text>Scikit-Learn Data Preprocessor Using TITANIC_VIEW from DWC. This view has 861 records  Install fedml_gcp package<jupyter_code>pip install fedml_gcp<jupyter_output><empty_output><jupyter_text>Import Libraries<jupyter_code>from fedml_gcp import DwcGCP
import numpy as np
import pandas as pd<jupyter_output><empty_output><jupyter_text>Create DwcGCP Instance to access class methods and train model It is expected that the bucket name passed here already exists in Cloud Storage.<jupyter_code>dwc = DwcGCP(project_name='example-project',
                 bucket_name='<bucket-name>')<jupyter_output><empty_output><jupyter_text>Create tar bundle of script folder so GCP can use it for trainingBefore running this cell, please ensure that the script package has all the necessary files for a training job.<jupyter_code>dwc.make_tar_bundle('DataPreprocessor.tar.gz', 'DataPreprocessor', 'datapreprocessor/train/DataPreprocessor.tar.gz')<jupyter_output><empty_output><jupyter_text>Create tar bundle of predictor script folder so GCP can use it for inferencingBefore running this cell, please ensure that the predictor package has all the necessary files for a training job.<jupyter_code>dwc.make_tar_bundle('DataPreprocessorPredictor.tar.gz', 'DataPreprocessorPredictor', 'datapreprocessor/prediction/DataPreprocessorPredictor.tar.gz')<jupyter_output><empty_output><jupyter_text>Train Model GCP takes in training inputs that are specific to the training job and the environment needed.In the training inputs, we are the python module. This is the module that your script package is named, and it references the task.py file inside the script package.We are also passing args which hold the table name to get data from. Before running the following cell, you should have a config.json file in the script package with the specified values to allow you to access to DWC.You should also have the follow view `TITANIC_VIEW` created in your DWC. To gather this data, please refer to https://www.kaggle.com/c/titanic/data and download the train.csv file.<jupyter_code>training_inputs = {
    'scaleTier': 'BASIC',
    'packageUris': ['gs://<bucket-name>/datapreprocessor/train/DataPreprocessor.tar.gz'],
    'pythonModule': 'trainer.task',
    'args': ['--table_name', 'TITANIC_VIEW', '--bucket_name', '<bucket-name>'],
    'region': 'us-east1',
    'jobDir': 'gs://<bucket-name>',
    'runtimeVersion': '2.5',
    'pythonVersion': '3.7',
    'scheduling': {'maxWaitTime': '3600s', 'maxRunningTime': '7200s'}
}
dwc.train_model('preprocessor_final_train1', training_inputs)<jupyter_output><empty_output><jupyter_text>Deploy model<jupyter_code>dwc.deploy(model_name='<example-model>',  
           model_location='/datapreprocessor/model', version='v1', region='us-east1', 
           prediction_location='datapreprocessor/prediction/', custom_predict='DataPreprocessorPredictor.tar.gz', module_name='predictor.MyPredictor', 
           onlinePredictionLogging=True, onlinePredictionConsoleLogging=True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09720853858784893, 'fraction_numerical': 0.0062397372742200325, 'mean_word_length': 6.150234741784038, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '258780', 'license': 'Apache-2.0', 'n_tokens_mistral': 934, 'n_tokens_neox': 913, 'n_words': 262, 'path': 'GCP/sample-notebooks/DataPreprocessor/DataPreprocessor.ipynb', 'repo_name': 'SAP-samples/data-warehouse-cloud-fedml', 'size': '3045'}