开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 6

readerloop/MLflow

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (15)
标签 (16)
master
pr-template
disable_sagemaker_docker_build
branch-0.9
revert-968-notebook-link-query-params
readme-patch
branch-0.8
mateiz-jackson-databind
branch-0.7
h2o_model_snippets
pytorch_model_snippets
dbczumar-model-arg
java-client
branch-0.5
v0.5.2_release_branch
v0.9.0
v0.8.2
v0.8.1
v0.8.0
v0.7.0
v0.7
v0.6.0
v0.5.2
v0.5.1
v0.5.0
v0.4.2
v0.4.1
v0.4.0
v0.3.0
v0.2.1
v0.2.0
master
分支 (15)
标签 (16)
master
pr-template
disable_sagemaker_docker_build
branch-0.9
revert-968-notebook-link-query-params
readme-patch
branch-0.8
mateiz-jackson-databind
branch-0.7
h2o_model_snippets
pytorch_model_snippets
dbczumar-model-arg
java-client
branch-0.5
v0.5.2_release_branch
v0.9.0
v0.8.2
v0.8.1
v0.8.0
v0.7.0
v0.7
v0.6.0
v0.5.2
v0.5.1
v0.5.0
v0.4.2
v0.4.1
v0.4.0
v0.3.0
v0.2.1
v0.2.0
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (15)
标签 (16)
master
pr-template
disable_sagemaker_docker_build
branch-0.9
revert-968-notebook-link-query-params
readme-patch
branch-0.8
mateiz-jackson-databind
branch-0.7
h2o_model_snippets
pytorch_model_snippets
dbczumar-model-arg
java-client
branch-0.5
v0.5.2_release_branch
v0.9.0
v0.8.2
v0.8.1
v0.8.0
v0.7.0
v0.7
v0.6.0
v0.5.2
v0.5.1
v0.5.0
v0.4.2
v0.4.1
v0.4.0
v0.3.0
v0.2.1
v0.2.0
MLflow
/
docs
/
source
/
quickstart.rst
MLflow
/
docs
/
source
/
quickstart.rst
quickstart.rst 7.03 KB
一键复制 编辑 原始数据 按行查看 历史
Stephanie Bodoff 提交于 2019年02月24日 11:08 +08:00 . Style edit and fix some formatting bugs. (#862)

Quickstart

Installing MLflow

You install MLflow by running:

.. code-section::

 .. code-block:: python

 pip install mlflow

 .. code-block:: R

 install.packages("mlflow")
 mlflow::mlflow_install()

Note

You cannot install MLflow on the MacOS system installation of Python. We recommend installing Python 3 through the :doc:`tutorial` for a walk-through on how you can leverage MLflow in your daily workflow.

Downloading the Quickstart

Download the quickstart code by cloning MLflow via git clone https://github.com/mlflow/mlflow, and cd into the examples subdirectory of the repository. We'll use this working directory for running the quickstart.

We avoid running directly from our clone of MLflow as doing so would cause the tutorial to use MLflow from source, rather than your PyPi installation of MLflow.

Using the Tracking API

The :doc:`MLflow Tracking API<tracking/>` lets you log metrics and artifacts (files) from your data science code and see a history of your runs. You can try it out by writing a simple Python script as follows (this example is also included in quickstart/mlflow_tracking.py):

.. code-section::

 .. code-block:: python

 import os
 from mlflow import log_metric, log_param, log_artifact

 if __name__ == "__main__":
 # Log a parameter (key-value pair)
 log_param("param1", 5)

 # Log a metric; metrics can be updated throughout the run
 log_metric("foo", 1)
 log_metric("foo", 2)
 log_metric("foo", 3)

 # Log an artifact (output file)
 with open("output.txt", "w") as f:
 f.write("Hello world!")
 log_artifact("output.txt")

 .. code-block:: R

 library(mlflow)

 # Log a parameter (key-value pair)
 mlflow_log_param("param1", 5)

 # Log a metric; metrics can be updated throughout the run
 mlflow_log_metric("foo", 1)
 mlflow_log_metric("foo", 2)
 mlflow_log_metric("foo", 3)

 # Log an artifact (output file)
 writeLines("Hello world!", "output.txt")
 mlflow_log_artifact("output.txt")

Viewing the Tracking UI

By default, wherever you run your program, the tracking API writes data into files into an mlruns directory. You can then run MLflow's Tracking UI:

.. code-section::

 .. code-block:: python

 mlflow ui

 .. code-block:: R

 mlflow_ui()

and view it at :ref:`log runs to a remote server<tracking>` to manage your results centrally or share them across a team.

Running MLflow Projects

MLflow allows you to package code and its dependencies as a project that can be run in a reproducible fashion on other data. Each project includes its code and a MLproject file that defines its dependencies (for example, Python environment) as well as what commands can be run into the project and what arguments they take.

You can easily run existing projects with the mlflow run command, which runs a project from either a local directory or a GitHub URI:

mlflow run sklearn_elasticnet_wine -P alpha=0.5

mlflow run https://github.com/mlflow/mlflow-example.git -P alpha=5

There's a sample project in tutorial, including a MLproject file that specifies its dependencies. if you haven't configured a :ref:`tracking server <tracking_server>`, projects log their Tracking API data in the local mlruns directory so you can see these runs using mlflow ui.

Note

By default mlflow run installs all dependencies using :doc:`projects`.

Saving and Serving Models

MLflow includes a generic MLmodel format for saving models from a variety of tools in diverse flavors. For example, many models can be served as Python functions, so an MLmodel file can declare how each model should be interpreted as a Python function in order to let various tools serve it. MLflow also includes tools for running such models locally and exporting them to Docker containers or commercial serving platforms.

To illustrate this functionality, the mlflow.sklearn package can log scikit-learn models as MLflow artifacts and then load them again for serving. There is an example training application in sklearn_logistic_regression/train.py that you can run as follows:

python sklearn_logistic_regression/train.py

When you run the example, it outputs an MLflow run ID for that experiment. If you look at mlflow ui, you will also see that the run saved a model folder containing an MLmodel description file and a pickled scikit-learn model. You can pass the run ID and the path of the model within the artifacts directory (here "model") to various tools. For example, MLflow includes a simple REST server for python-based models:

mlflow pyfunc serve -r <RUN_ID> -m model

Note

By default the server runs on port 5000. If that port is already in use, use the --port option to specify a different port. For example: mlflow pyfunc serve --port 1234 -r <RUN_ID> -m model

Once you have started the server, you can pass it some sample data and see the predictions.

The following example uses curl to send a JSON-serialized pandas DataFrame with the split orientation to the pyfunc server. For more information about the input data formats accepted by the pyfunc model server, see the :ref:`MLflow deployment tools documentation <pyfunc_deployment>`.

curl -d '{"columns":["x"], "data":[[1], [-1]]}' -H 'Content-Type: application/json; format=pandas-split' -X POST localhost:5000/invocations

which returns:

{"predictions": [1, 0]}

Note

The sklearn_logistic_regression/train.py script must be run with the same Python version as the version of Python that runs mlflow pyfunc serve. If they are not the same version, the stacktrace below may appear:

File "/usr/local/lib/python3.6/site-packages/mlflow/sklearn.py", line 54, in _load_model_from_local_file
return pickle.load(f)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc6 in position 0: ordinal not in range(128)

For more information, see :doc:`models`.

Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

MLflow 是由 Apache Spark 技术团队开源的一个机器学习平台,主打开放性: 开放接口:可与任意 ML 库、算法、部署工具或编程语言一起使用
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/readerloop/MLflow.git
git@gitee.com:readerloop/MLflow.git
readerloop
MLflow
MLflow
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /