python sklearn學習筆記(1)svm

2021-08-02 04:02:19 字數 605 閱讀 7449

scikit-learn的安裝:

'''python

#安裝gcc庫

brew install gcc

#安裝scipy

pip install scipy

後面的安裝,就按步就班了

#安裝matplotlib,方便把資料繪圖顯示出來

pip install matplotlib

#安裝sklearn,我理解這個安裝必須在pandas之前

pip install -u numpy scipy scikit-learn

#安裝pandas

pip install pandas

'''

clf = svm.svc()

clf.fit(datamat,labelmat)

result = clf.predict([3.5,2.5])

print(result)

載入測試資料集,並進行svm回歸測試:

clf1 = svm.svr()

clf1.fit(datamat,labelmat)

result1 = clf1.predict([3.5,2.5])

Python sklearn 交叉驗證

from sklearn.datasets import load boston from sklearn.model selection import cross val score from sklearn.tree import decisiontreeregressor boston loa...

python sklearn庫實現簡單邏輯回歸

import xlrd import matplotlib.pyplot as plt import numpy as np from sklearn import model selection from sklearn.linear model import logisticregression...

Python sklearn 中的SVM示例

coding utf 8 import pandas as pd from numpy.random import shuffle from sklearn import svm import joblib from sklearn import metrics inputfile data mom...