<jupyter_start><jupyter_text>Scikit-Learn Hierarchical Clustering Using MALL_CUSTOMERS_VIEW from DWC. This view has 200 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('HierarchicalClustering.tar.gz', 'HierarchicalClustering', 'hc/train/HierarchicalClustering.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('HierarchicalClusteringPredictor.tar.gz', 'HierarchicalClusteringPredictor', 'hc/prediction/HierarchicalClusteringPredictor.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 `MALL_CUSTOMERS_VIEW` created in your DWC. To gather this data, please refer to https://www.kaggle.com/roshansharma/mall-customers-clustering-analysis/data<jupyter_code>training_inputs = {
    'scaleTier': 'BASIC',
    'packageUris': ['gs://<bucket-name>/hc/train/HierarchicalClustering.tar.gz'],
    'pythonModule': 'trainer.task',
    'args': ['--table_name', 'MALL_CUSTOMERS_VIEW',
             '--table_size', '1',
            '--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('h_clustering_final_train2', training_inputs)<jupyter_output><empty_output><jupyter_text>Deploy model<jupyter_code>dwc.deploy(model_name='<example-model>', model_location='/hc/model/', version='v1', region='us-east1', 
           prediction_location='hc/prediction/', custom_predict='HierarchicalClusteringPredictor.tar.gz', module_name='predictor.MyPredictor')<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup