简体   繁体   English

气流:存储机器学习模型

[英]Airflow: Storing machine learning model

I'd make pipeline of machine learning on Airflow. 我会在Airflow上构建机器学习管道。
Example) 例)

result = model.fit()

But DAG file:( sample.py ) is refreshed on each times. 但是DAG文件:( sample.py )每次都会刷新。

在此处输入图片说明

So I can't store trained model. 所以我不能存储训练有素的模型。

How should I treat trained model ? 我应该如何对待训练有素的模型

Or should I store the trained model data in external? 还是应该将经过训练的模型数据存储在外部?
Then take the trained model in use? 然后采用训练有素的模型?

Store the model in pickle file and retrieve the model from same file whenever you want. 将模型存储在pickle文件中,并在需要时从同一文件中检索模型。

import pickle 
result = model.fit()
# save the model to disk
filename = 'my_model.sav'
pickle.dump(model, open(filename, 'wb'))

# load the model from file for later use
reload_model = pickle.load(open(filename, 'rb'))
result_final = reload_model.score(X_test, y_test)
print result_final

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM