目录

(3)matplotlib
画图包,并提供2D、3D的绘图。
(4)pandas
提供了数据结构,有许多函数用于importing 、manipulation and analysis.特备是提供操作数值表、时间序列的数据结构
(5)SciKit-Learn
it is a collection of algorithms and tools for machine learing .是机器学习算法和工具的集合。

截屏2020-11-19 下午8.31.48.png

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
截屏2020-11-19 下午8.31.18.png

3 scikit-learn functions

(1)转变类型

  1. from slearn import prepeocessing
  2. X = preprocessing.StandardScalar().fit(X).trainsform(X)
  3. # transform raw feature vectors into a suittable form of vector for modeling

(2)划分数据集

  1. from sklearn.model_selection import train_test_split
  2. X_train,X_test,y_train,y_test = train_test_split(X,y,test_size = 0.33)

(3)设置算法

  1. from sklearn import sum
  2. clf = svm.SVC(gamma = 0.001,C = 100.)
  3. # build a classifier using support vector classification algorithm
  4. #

(4)训练设置

  1. clf.fit(X_train,y_train)

(5)进行预测

  1. clf.predict(X_test)

(6)计算准确度

  1. from sklearn.metrics import confusion_matrix
  2. print(confusion_matrix(y_test,yhat,labels = [1,0]))

(7)保存模型

  1. import pickle
  2. s = pickle.dumps(clf)