将我的Python机器学习模型部署为Web服务

时间:2019-05-17 12:11:27

标签: python python-3.x

我已经使用Python3在anaconda提示符下开发了一种机器学习模型,以便将其部署并在GitHub上动态地运行或在Web服务上以任何方式运行它。

我已经使用了Pickle命令,但是它对我不起作用。

'components' => [
    // You can name it whatever you want as it is custom
    'urlManagerBackend' => [
        'class' => 'yii\web\urlManager',
        'baseUrl' => 'yourbackendend/absolutepath/uploads/',
        'enablePrettyUrl' => true,
        'showScriptName' => false,
    ],
],

它没有将我的模型部署为Web服务。

1 个答案:

答案 0 :(得分:2)

您可以尝试使用烧瓶。它使用python并将其部署为Web应用程序。这是您可以尝试的一些示例代码。

from flask import Flask, render_template, request
app = Flask(__name__, static_url_path='/static')

@app.route('/')
def upload_file():    
    return "hello world"
if __name__ == '__main__':
    app.run(host="0.0.0.0")

通过设置

  

host =“ 0.0.0.0”

您正在使用本地计算机作为服务器在网上部署应用程序。