目录
- 1 Python libraries for machine learning
- 2 More about scikit-learn
- 3 scikit-learn functions
1 Python libraries for machine learning
(1)Numpy
更快的计算,比如提供数组、字典、函数、数据类型
(2)SCIpy
是一个数值算法和领域专用工具箱。包括信号处理、优化、统计等等,对于科研有很大的用处
(3)matplotlib
画图包,并提供2D、3D的绘图。
(4)pandas
提供了数据结构,有许多函数用于importing 、manipulation and analysis.特备是提供操作数值表、时间序列的数据结构
(5)SciKit-Learn
it is a collection of algorithms and tools for machine learing .是机器学习算法和工具的集合。
2 More about scikit-learn
(1)Free software machine learning library
(2)Classification、RegresSion and clustering algorithm
(3)Work with Numpy and SciPy
(4)Great documentation
(5)Easy to implement
3 scikit-learn functions
(1)转变类型
from slearn import prepeocessing
X = preprocessing.StandardScalar().fit(X).trainsform(X)
# transform raw feature vectors into a suittable form of vector for modeling
(2)划分数据集
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size = 0.33)
(3)设置算法
from sklearn import sum
clf = svm.SVC(gamma = 0.001,C = 100.)
# build a classifier using support vector classification algorithm
#
(4)训练设置
clf.fit(X_train,y_train)
(5)进行预测
clf.predict(X_test)
(6)计算准确度
from sklearn.metrics import confusion_matrix
print(confusion_matrix(y_test,yhat,labels = [1,0]))
(7)保存模型
import pickle
s = pickle.dumps(clf)