用泡菜装载用天蓝色automl训练的模型

时间:2020-09-16 16:16:00

标签: python azure jupyter-notebook automl

我有一个已注册的数据集(基于泰坦尼克号),并且用azure automl训练了一个模型:

from azureml.train.automl import AutoMLConfig

automl_config = AutoMLConfig(name='Automated ML Experiment on titanic dataset',
                             task='classification',
                             compute_target=compute_target,
                             enable_local_managed=True,
                             training_data = train_ds,
                             validation_data = test_ds,
                             label_column_name='Survived',
                             iterations=6,
                             primary_metric = 'AUC_weighted',
                             max_concurrent_iterations=4,
                             featurization='auto'
                             )

print("Ready for Auto ML run.")

from azureml.core.experiment import Experiment
from azureml.widgets import RunDetails

print('Submitting Auto ML experiment...')
automl_experiment = Experiment(ws, 'titanic_automl')
automl_run = automl_experiment.submit(automl_config)
RunDetails(automl_run).show()
automl_run.wait_for_completion(show_output=True)

best_run, fitted_model = automl_run.get_output()

from azureml.core import Model

# Register model
best_run.register_model(model_path='outputs/model.pkl', model_name='titanic_model_automl',
                        tags={'Training context':'Auto ML'},
                        properties={'AUC': best_run_metrics['AUC_weighted'], 'Accuracy': best_run_metrics['accuracy']})

然后我想通过使用以下命令在另一个笔记本中加载该模型:

import pickle

filename = 'model/azure-automl.pkl'
model = pickle.load(open(filename, 'rb'))

但是我无法确定它可以在本地还是在Azure计算实例上工作。

0 个答案:

没有答案
相关问题