MILKPython 機(jī)器學(xué)習(xí)工具包
MILK(MACHINE LEARNING TOOLKIT) 是 Python 語(yǔ)言的機(jī)器學(xué)習(xí)工具包。
它主要是在很多可得到的分類比如 SVMS、K-NN、隨機(jī)森林以及決策樹(shù)中使用監(jiān)督分類法,它還可執(zhí)行特征選擇。這些分類器在許多方面相結(jié)合,可以形成不同的例如無(wú)監(jiān)督學(xué)習(xí)、密切關(guān)系傳播和由 MILK 支持的 K-means 聚類等分類系統(tǒng)。
MILK 關(guān)注速度和內(nèi)存的使用,因此大多數(shù)對(duì)性能比較敏感的代碼都是用 C++ 編寫的。為了方便起見(jiàn),基于 Python 實(shí)現(xiàn)了接口。
示例代碼
測(cè)試對(duì)一些 features,labels 數(shù)據(jù)的分類情況,通過(guò)交叉驗(yàn)證測(cè)量:
import numpy as np import milk features = np.random.rand(100,10) # 2d array of features: 100 examples of 10 features each labels = np.zeros(100) features[50:] += .5 labels[50:] = 1 confusion_matrix, names = milk.nfoldcrossvalidation(features, labels) print 'Accuracy:', confusion_matrix.trace()/float(confusion_matrix.sum())
如果想要使用分類器,可以創(chuàng)建一個(gè) learner object 并調(diào)用它的 train() 方法:
import numpy as np import milk features = np.random.rand(100,10) labels = np.zeros(100) features[50:] += .5 labels[50:] = 1 learner = milk.defaultclassifier() model = learner.train(features, labels) # Now you can use the model on new examples: example = np.random.rand(10) print model.apply(example) example2 = np.random.rand(10) example2 += .5 print model.apply(example2)
特性
-
支持向量機(jī)。使用封裝了 pythonesque 的 libsvm solver
-
LASSO 算法
-
K-means 使用的內(nèi)存小,可有效地對(duì)數(shù)百萬(wàn)個(gè)實(shí)例進(jìn)行集群
-
隨機(jī)森林
-
自組織地圖
-
逐步判別分析特征選擇
-
非負(fù)矩陣分解(Non-negative Matrix Factorization,NMF)算法
-
AP(Affinity Propagation)聚類算法
評(píng)論
圖片
表情
