scikit-multiflow的初尝试

一、安装

在pycharm或者spyder上安装scikit-multiflow可能会遇到各种问题,只能耐心一点,多在网上找找教程。具体的安装过程可以参考以下b站上的视频教程,当然以下教程也不是包治百病。

如何在Anaconda上安装及卸载第三方包_哔哩哔哩_bilibili

二、代码

下面是一份完整的python代码,注释里面的方法不成功,错误提示为EvaluatePrequential导入不成功。

from skmultiflow.data import SEAGenerator
from skmultiflow.trees import HoeffdingTree
from skmultiflow import EvaluatePrequential
import matplotlib.pyplot as plt
import numpy as np

stream = SEAGenerator()  '''创建数据流
stream.prepare_for_use()
nb_iters=100
tree = HoeffdingTree() '''创建HoeffdingTree


correctness_dist = []

for i in range(nb_iters):
    X,Y = stream.next_sample()
    prediction = tree.predict(X)
    if Y==prediction:
        correctness_dist.append(1)
    else:
        correctness_dist.append(0)
    tree.partial_fit(X,Y)

time = [i for i in range(nb_iters)]
sumValue=0
accuracy= np.zeros(len(correctness_dist))
for i in range(len(correctness_dist)):
    sumValue = sumValue + correctness_dist[i]
    accuracy[i] = (sumValue*1.0)/(i+1)
    
print(accuracy)
plt.plot(time,accuracy)

'''
evaluator = EvaluatePrequential(show_plot=True, max_sample=nb_iters)
evaluator.evaluate(stream=stream,model=tree)
'''

三 参考文献

本博客参考了以下网络资源:

使用Scikit-Multiflow进行增量(在线)学习

进一步的学习,可以上官网查阅资料:scikit-multiflow

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值