【在线机器学习】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

相关推荐
leizhen198408094 小时前
AI 不会注定失控,也不会自动被控制
人工智能·安全
远航计算机5 小时前
客服记录怎么变成 AI 会引用的内容?五步清洗法
大数据·人工智能·算法·aigc
三声三视5 小时前
封全站判“允许“,封目录判“禁止“:tri-geo 体检 74 分那次我拆了 31 行 judge_ua
人工智能·ai·skillhub·tri-skill·tri-geo
赋创小助手5 小时前
Qwen3.8-27B 本地推理 Benchmark 解析:llama.cpp、vLLM、SGLang 与长 Context 的性能差异
服务器·人工智能·大模型·qwen·vllm·sglang·context长度
Wendy不吃榴莲5 小时前
Seko教程:AI 短视频分镜怎么做?零基础用 6 格讲清一个 30 秒故事(2026 最新版)
人工智能
YOLO数据集集合5 小时前
无人机低空影像语义分割数据集 | 语义分割 遥感影像 无人机低空 地物分类 Potsdam Vaihingen LoveDA 9080期
人工智能·深度学习·yolo·目标检测·计算机视觉·语义分割·无人机数据集
海宇数据5 小时前
零信任架构实战:基于海宇手机消费区间验证构建自动化信用分类网关
人工智能·ai·工具分享
连线Insight5 小时前
逃离Agent坟场:企业需要产业智能体操作系统
人工智能
码流子5 小时前
几万路监控怎么接:高速公路视频汇聚平台的架构设计与落地坑点
大数据·人工智能·物联网·算法·架构
2601_949499945 小时前
工业 POF 器件国产化新思路:芯瑞科技DT‑2532Z 解决安华高 HFBR‑2532Z 供应链卡点
运维·网络·人工智能·科技·光模块