training better models using automated machine learning · import pandas as pd from...

40
Training better models using Automated Machine Learning Vlad Iliescu

Upload: others

Post on 23-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

Training better models usingAutomated Machine Learning

Vlad Iliescu

Page 2: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

Tools of the trade

Page 3: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

Google’s AUTOML

Page 4: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

Auto-keras

Page 5: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

Auto-SKLearn Microsoft’s automated ML

Page 6: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

Kaggle

Page 7: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl
Page 8: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl
Page 9: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

Features

• PassengerId

• Survived

• Pclass

• Sex

• Age

• Sibsp

• Parch

• Ticket

• Fare

• Cabin

• Embarked

Page 10: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

import pandas as pdfrom azureml.core.experiment import Experimentfrom azureml.core.workspace import Workspacefrom azureml.train.automl import AutoMLConfig

Page 11: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

# Load training datadf = pd.read_csv('./data/train.csv')

X = df.drop(['Survived', 'PassengerId'], axis=1)y = df['Survived']

Page 12: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

# Configure the experiment

config = AutoMLConfig(task='classification',primary_metric=AUC_weighted',iterations=5,X=X,y=y.values.flatten(),n_cross_validations=5,preprocess=True

)

Page 13: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

# Configure the experiment

config = AutoMLConfig(task='classification',primary_metric=AUC_weighted',iterations=10,X=X,y=y.values.flatten(),n_cross_validations=5,preprocess=True

)

• Classification

• Regression

• Forecasting

Page 14: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

# Configure the experiment

config = AutoMLConfig(task='classification',primary_metric=AUC_weighted',iterations=5,X=X,y=y.values.flatten(),n_cross_validations=5,preprocess=True

)

• AUC_Macro

• AUC_Micro

• AUC_Weighted

• accuracy

• average_precision_score_macro

• average_precision_score_micro

• average_precision_score_weighted

• balanced_accuracy

• f1_score_macro

• f1_score_micro

• f1_score_weighted

• log_loss

• norm_macro_recall

• precision_score_macro

• precision_score_micro

• precision_score_weighted

• recall_score_macro

• recall_score_micro

• recall_score_weighted

• weighted_accuracy

Page 15: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

# Configure the experiment

config = AutoMLConfig(task='classification',primary_metric=AUC_weighted',iterations=5,X=X,y=y.values.flatten(),n_cross_validations=5,preprocess=True

)

Page 16: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

# Configure the experiment

config = AutoMLConfig(task='classification',primary_metric=AUC_weighted',iterations=5,X=X,y=y.values.flatten(),n_cross_validations=5,preprocess=True

)

Page 17: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

# Configure the experiment

config = AutoMLConfig(task='classification',primary_metric=AUC_weighted',iterations=5,X=X,y=y.values.flatten(),n_cross_validations=5,preprocess=True

)

Page 18: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

# Configure the experiment

config = AutoMLConfig(task='classification',primary_metric=AUC_weighted',iterations=5,X=X,y=y.values.flatten(),n_cross_validations=5,preprocess=True

)

Page 19: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

# Configure the experiment

config = AutoMLConfig(task='classification',primary_metric=AUC_weighted',iterations=5,X=X,y=y.values.flatten(),n_cross_validations=5,preprocess=False

)

• StandardScaleWrapper

• MinMaxScalar

• MaxAbsScaler

• RobustScalar

• PCA

• TruncatedSVDWrapper

• SparseNormalizer

Page 20: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

# Configure the experiment

config = AutoMLConfig(task='classification',primary_metric=AUC_weighted',iterations=5,X=X,y=y.values.flatten(),n_cross_validations=5,preprocess=True

)

• StandardScaleWrapper

• MinMaxScalar

• MaxAbsScaler

• RobustScalar

• PCA

• TruncatedSVDWrapper

• SparseNormalizer

• Drop high cardinality or no

variance features

• Impute missing values

• Generate additional features

• Transform and encode

• Word embeddings

• Target encodings

• Text target encoding

• Weight of Evidence (WoE)

• Cluster Distance

Page 21: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

# Run the Automated ML experiment

ws = Workspace.from_config()experiment = Experiment(ws, 'NDR2019')

local_run = experiment.submit(config, show_output=True)

Page 22: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

# Run the Automated ML experiment

ws = Workspace.from_config()experiment = Experiment(ws, 'NDR2019')

local_run = experiment.submit(config, show_output=True)

Page 23: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl
Page 24: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl
Page 25: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl
Page 26: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl
Page 27: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

# Run the best model on the test datasetbest_run, fitted_model = local_run.get_output()

df_test = pd.read_csv('./data/test.csv')df_test_X = df_test.drop(['PassengerId'], axis=1)pred_y = fitted_model.predict(df_test_X)

Page 28: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

# Generate the submission fileoutput = pd.DataFrame({

'PassengerId': df_test['PassengerId’], 'Survived': pred_y})

output.to_csv('./output.csv', index=False)

Page 29: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl
Page 30: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

Top 19%

Page 31: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

Turning it up to 11

Page 32: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

# Configure the experiment

config = AutoMLConfig(task='classification',primary_metric='AUC_weighted',iterations=50,X=X,y=y.values.flatten(),n_cross_validations=5,preprocess=True

)

Page 33: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl
Page 34: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl
Page 35: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

# Configure the experiment

config = AutoMLConfig(task='classification',primary_metric='accuracy',iterations=10,X=X,y=y.values.flatten(),n_cross_validations=5,preprocess=True

)

Page 36: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl
Page 37: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

Top 6,3%

Page 38: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

What just happened?

Page 39: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

Questions?

Page 40: Training better models using Automated Machine Learning · import pandas as pd from azureml.core.experiment import Experiment from azureml.core.workspace import Workspace from azureml.train.automl

The END

Vlad Iliescu