【在线机器学习】River对流数据进行机器学习

River是一个用于在线机器学习的Python库。它旨在成为对流数据进行机器学习的最用户友好的库。River是crème和scikit-multiflow合并的结果。

https://github.com/online-ml/river

举个简单示例,将训练逻辑回归来对网站网络钓鱼数据集进行分类。下面介绍了数据集中的第一个观测值。

python 复制代码
>>> from pprint import pprint
>>> from river import datasets

>>> dataset = datasets.Phishing()

>>> for x, y in dataset:
...     pprint(x)
...     print(y)
...     break
{'age_of_domain': 1,
 'anchor_from_other_domain': 0.0,
 'empty_server_form_handler': 0.0,
 'https': 0.0,
 'ip_in_url': 1,
 'is_popular': 0.5,
 'long_url': 1.0,
 'popup_window': 0.0,
 'request_from_other_domain': 0.0}
True

现在,让我们以流式处理方式在数据集上运行模型。我们按顺序交错预测和模型更新。同时,我们更新性能指标以查看模型的表现如何。

python 复制代码
>>> from river import compose
>>> from river import linear_model
>>> from river import metrics
>>> from river import preprocessing

>>> model = compose.Pipeline(
...     preprocessing.StandardScaler(),
...     linear_model.LogisticRegression()
... )

>>> metric = metrics.Accuracy()

>>> for x, y in dataset:
...     y_pred = model.predict_one(x)      # make a prediction
...     metric = metric.update(y, y_pred)  # update the metric
...     model = model.learn_one(x, y)      # make the model learn

>>> metric
Accuracy: 89.28%

当然,这只是一个人为的例子。我们欢迎您查看文档的介绍部分以获取更全面的教程。

🛠 安装

River 旨在与 Python 3.8 及更高版本配合使用。安装可以通过以下方式完成:pip

pip install river

有可用于Linux,MacOS和Windows的轮子,这意味着您很可能不必从源代码构建River。

您可以从 GitHub 安装最新的开发版本,如下所示:

pip install git+https://github.com/online-ml/river --upgrade

或者,通过 SSH:

pip install git+ssh://git@github.com/online-ml/river.git --upgrade

River 提供了以下算法系列的在线实现

线性模型,具有各种优化器

决策树和随机森林

(近似)最近邻

异常检测

漂移检测

推荐系统

时间序列预测

强盗

因子分解机

不平衡的学习

聚类

装袋/升压/堆垛

主动学习

River还提供其他在线实用程序

特征提取和选择

在线统计和指标

预处理

内置数据集

渐进式模型验证

对管道进行建模

查看 API 以获得全面的概述

很棒的在线机器学习

https://github.com/online-ml/awesome-online-machine-learning
https://parameterfree.com/lecture-notes-on-online-learning/

https://www.zhihu.com/question/465062970/answer/3148474389?utm_id=0
https://scikit-multiflow.readthedocs.io/en/stable/installation.html

Online learning的综述文章:https://arxiv.org/abs/1912.13213

相关推荐
糖果店的幽灵5 分钟前
【langgraph 从入门到精通】全面实践项目:智能客服工单系统
人工智能·langgraph
卡卡罗特学AI12 分钟前
曾经人手一个的Superpowers,为什么现在都在卸
人工智能·程序员
audyxiao00117 分钟前
人工智能顶会CVPR 2026论文分享|SegMoTE:一种可显著提高模型泛化能力的Token级混合专家架构
人工智能·cvpr·智慧医疗·混合专家架构·医学影像分割
武汉唯众智创25 分钟前
具身智能:人工智能的下一个范式革命
人工智能·具身智能·人形机器人·多模态感知·机器人运动控制·机器人产教融合·机器人感知决策
lisw0543 分钟前
【计算机科学技术】算力是什么?为何用小时计?怎么使用?
人工智能·机器学习·软件工程
半兽先生44 分钟前
大模型实现金融文本分类
人工智能·python·金融
汤姆小白1 小时前
06-LoRA参数高效微调
人工智能·python·机器学习·transformer
Dola_Zou1 小时前
以CmASIC重塑AI+边缘设备的安全与商业复利
人工智能·安全·软件工程·软件加密
蓝星空20001 小时前
GPT-image-2 模型国内免费使用教程:零门槛直出商业级 AI 大片
人工智能·gpt·aigc·image2·imagen
直接冲冲冲1 小时前
两层神经网络与三层神经网络的区别
人工智能·深度学习·神经网络