zl程序教程

您现在的位置是:首页 >  后端

当前栏目

【ML吴恩达】2 Python的机器学习相关库libraries

Python机器学习 相关 ML libraries 吴恩达
2023-09-14 09:13:09 时间

Course 课程Machine learning with python

1 Python 的机器学习相关库

(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与Numpy和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)