Machine learning in python (part II) 2019-12-23

Today, I will go on the journey of machine learning.

2. Supervised learning: classification and regression

In classification, the label is discrete, while in regression, the label is continuous.

2.1 classification

K nearest neighbors(kNN) is one of the simplest learning strategies: given a new, unknown observation, look up in your reference database which ones have the closest features and assign the predominant class.

from sklearn import neighbors, datasets
iris = datasets.load_iris()
X, y = iris.data, iris.target
knn = neighbors.KNeighborsClassifier(n_neighbors = 1)
knn.fit(X, y)
print(iris.target_names[knn.predict([[3,5,4,2]])])

output:['virginica']

Figure 1. A plot of the sepal space and the prediction of the KNN.png

2.2 regression

The simplest possible regression setting is the linear regression one:


Figure 2. A plot of a simple linear regression.png

(I have studied this two types in previous days, umumum...)
这部分内容,也是概述性的,之前学习过类似的内容,算是复习吧。。。


Figure 3. Simple versus complex models for classification.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容