mlflow训练机器学习模板

1 安装mlflow

pip install  mlflow

2.测试

import mlflow
import mlflow.sklearn

# 设置mlflow的地址

mlflow.set_tracking_uri("http://192.**.**.***:10000/")

# 创建实验(如果第一次创建了,需要从新启动)

mlflow.create_experiment("test")

# 加载实验

mlflow.set_experiment("test")# 逻辑回归模型
with mlflow.start_run():
    mlflow.log_param("model", "logisticregression")
    mlflow.log_param("max_iter", "5")
    ts = time.time()
    clf = LogisticRegression(verbose=1, max_iter=1)
    clf.fit(train_x, train_y)
    score = clf.score(train_x, train_y)
    mlflow.log_metric("train_acc", score)
    te = time.time()
    print("LogisticRegression train use time:", te-ts)
    print("LogisticRegression train set accuracy:", score)
#      测试集测试
    test_score = clf.score(test_x, test_y)
    print("LogisticRegression test set accuracy:", test_score )
    mlflow.log_metric("test_acc", test_score)

等模型训练完就可以在浏览器中查看自己的训练结果了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值