基于wisard模型的wisard库
wisardpkg的Python项目详细描述
wisardpkg
说明:
这是一个基于Wisard的不同型号的项目, 具有高性能,易于使用,易于安装和遵循使用模式。 这些模型是机器学习模型, 有监督、无监督和半监督学习。
要安装:
Python:
pip install wisardpkg
适用于python2和pyhton3。
如果您在Linux上,而不是在虚拟环境中,则可能需要以超级用户身份运行。
OBS:
要在Windows平台上安装,您可以使用anaconda并执行以下操作:
python -m pip install wisardpkg
C++: 将文件wisardpkg.hpp复制到项目中
include/wisardpkg.hpp
要卸载:
pip uninstall wisardpkg
导入:
Python:
importwisardpkgaswp
C++:
# include "wisardpkg.hpp"namespacewp=wisardpkg;
使用:
wisard
默认情况下,带有漂白功能的wisard:
Python:
# load input data, just zeros and ones X=[[1,1,1,0,0,0,0,0],[1,1,1,1,0,0,0,0],[0,0,0,0,1,1,1,1],[0,0,0,0,0,1,1,1]]# load label data, which must be a string arrayy=["cold","cold","hot","hot"]addressSize=3# number of addressing bits in the ramignoreZero=False# optional; causes the rams to ignore the address 0# False by default for performance reasons,# when True, WiSARD prints the progress of train() and classify()verbose=Truewsd=wp.Wisard(addressSize,ignoreZero=ignoreZero,verbose=verbose)# train using the input datawsd.train(X,y)# classify some dataout=wsd.classify(X)# the output of classify is a string list in the same sequence as the inputfori,dinenumerate(X):print(out[i],d)
C++:
vector<vector<int>>X(4);X[0]={1,1,1,0,0,0,0,0};X[1]={1,1,1,1,0,0,0,0};X[2]={0,0,0,0,1,1,1,1};X[3]={0,0,0,0,0,1,1,1};vector<string>y={"cold","cold","hot","hot"};wp::Wisardw(3,{{"ignoreZero",false},{"verbose",true}});w.train(X,y);vector<string>out=w.classify(X);for(inti=0;i<4;i++){cout<<"i: "<<i<<"; class: "<<out[i]<<endl;}
俱乐部
默认情况下带有漂白功能的俱乐部:
addressSize=3# number of addressing bits in the ram.minScore=0.1# min score of training processthreshold=10# limit of training cycles by discriminatordiscriminatorLimit=5# limit of discriminators by clusters# False by default for performance reasons# when enabled,e ClusWiSARD prints the progress of train() and classify()verbose=Trueclus=ClusWisard(addressSize,minScore,threshold,discriminatorLimit,verbose=True)# train using the input dataclus.train(X,y)# optionally you can train using arbitrary labels for the data# input some labels in a dict,# the keys must be integer indices indicating which input array the entry is associated to,# the values are the labels which must be stringsy2={1:"cold",3:"hot"}clus.train(X,y2)# classify some dataout=clus.classify(X)# the output of classify is a string list in the same sequence as the inputfori,dinenumerate(X):print(out[i],d)
文档:
您可以在page中找到完整的文档。