如何将scikit预测模型链接到flask静态网站?

时间:2017-10-06 10:21:48

标签: python flask scikit-learn

我成功地在我的localhost上运行了scikit学习预测模型,现在我有兴趣将这个模型添加到我的flask静态网站。我怎样才能做到这一点?有什么建议?我基本上想在flask静态网站上添加一个链接到预测模型。

例如

在localhost:5000上运行的静态网站具有以下代码

@app.route('/index')
def index():
    return  render_template('index.html')

`@app.route('/model')`     #This code is wrong but I am trying to add my
`def model():`             #model here  

    return  url_for('localhost:8080')

    @app.route('/contactus')
    def contactus():
        return  render_template('contactus.html')

1 个答案:

答案 0 :(得分:0)

首先,您需要保存模型,使其持续存在,然后您可以将其上传到服务器并将其加载到那里,因为您需要sklearn joblib

here是一个有用的教程,解释了您真正需要的内容: