def load_ml_model(file_name):
with open(file_name, 'rb') as read_file:
base_pipeline = dill.load(read_file)
if isinstance(base_pipeline, utils_categorical_ensembling.CategoricalEnsembler):
for step in base_pipeline.transformation_pipeline.named_steps:
pipeline_step = base_pipeline.transformation_pipeline.named_steps[step]
try:
if pipeline_step.get('model_name', 'reallylongnonsensicalstring')[:12] == 'DeepLearning':
pipeline_step.model = insert_deep_learning_model(pipeline_step, file_name)
except AttributeError:
pass
for step in base_pipeline.trained_models:
pipeline_step = base_pipeline.trained_models[step]
try:
if pipeline_step.get('model_name', 'reallylongnonsensicalstring')[:12] == 'DeepLearning':
pipeline_step.model = insert_deep_learning_model(pipeline_step, file_name)
except AttributeError:
pass
else:
for step in base_pipeline.named_steps:
pipeline_step = base_pipeline.named_steps[step]
try:
if pipeline_step.get('model_name', 'reallylongnonsensicalstring')[:12] == 'DeepLearning':
pipeline_step.model = insert_deep_learning_model(pipeline_step, file_name)
except AttributeError:
pass
return base_pipeline
# Keeping this here for legacy support
评论列表
文章目录