Python模块(8)-sklearn 简易使用教程
sklearn 簡易使用教程
- 1.scikit-learn的數(shù)據(jù)集
- 2.scikit-learn 的訓練和預測
scikit-learn 是在Numpy,SciPy,Matplotlib三個模塊上編寫的,數(shù)據(jù)挖掘和數(shù)據(jù)分析的一個簡單有效的工具。scikit-learn包括6大功能:分類,回歸,聚類,降維,模型選擇和預處理。
此前寫過決策樹,PCA,LDA簡單實踐:
機器學習(5)-決策樹基礎+sklearn.DecisionTreeClassifier簡單實踐:https://blog.csdn.net/sinat_40624829/article/details/108411253
機器學習(6)–PCA,LDA基礎+sklearn 簡單實踐:https://blog.csdn.net/sinat_40624829/article/details/108600427
1.scikit-learn的數(shù)據(jù)集
scikit-learn 常用數(shù)據(jù)集合
分類數(shù)據(jù)集:iris, digits(8*8像素數(shù)組)
回歸數(shù)據(jù)集:波士頓房價
數(shù)據(jù)集類似于字典對象 ,數(shù)據(jù)被存在.data的成員內(nèi),是一個n_samples*n_features的數(shù)組;在有監(jiān)督學習的情形下.target成員中存儲一個或多個因變量(目標值)
2.scikit-learn 的訓練和預測
在scikit-learn 中,預測器是一個Python對象,具有fit(X,y)方法和predict(test)方法。依據(jù)不同的機器學習算法,可以構成相應的預測器。如SVM分類器、決策樹分類器等。不同的預測器使用fit(X,y)方法進行學習,而predict(test)方法進行預測。
from sklearn import datasets from sklearn import svmdigits = datasets.load_digits() print(digits.data[:2]) print(digits.target[:2])# 選擇模型參數(shù) clf = svm.SVC(gamma=0.0001, C=100)# 進行訓練 clf.fit(digits.data[:-1], digits.target[:-1])# 進行預測 print(clf.predict(digits.data[-1:]))總結(jié)
以上是生活随笔為你收集整理的Python模块(8)-sklearn 简易使用教程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: opencv findContours
- 下一篇: Ubuntu装机后的基础应用