The best machine learning (Python code implementation)

content

1 Mind Map

2 Smart Journey: An Introduction to Machine Learning

2.1 The concept of machine learning

2.2 Research questions of machine learning

2.3 Simple Classification of Machine Learning

2.4 Mathematical knowledge involved in machine learning

2.5 Programming knowledge

2.6 Algorithm knowledge

3 python code experience


1 Mind Map

2 Smart Journey: An Introduction to Machine Learning

2.1 Concepts of Machine Learning

Machine learning is the process of learning patterns from historical data and then applying those patterns to predict the future.

2.2 Research questions of machine learning

(1) Regression
Goal: Fit the existing data, and then predict the future based on the fitted function.
Method: The machine needs to find the division rule of the known classification, and then apply the division rule to classify things.
(2) Classification
Goal: To study how to determine which of the known categories a thing belongs to.
Method: The machine needs to fit the existing data, and then predict a certain process according to the fitted function.
(3) Clustering
Goal: Group ungrouped things
Method: The machine needs to divide things into several groups according to the similarity between things, and add labels
(4) Dimensionality reduction
Goal: Extract key information from high-dimensional data
Method: The machine needs to analyze the importance of data in different dimensions, so as to extract the key information in the data

2.3 Simple Classification of Machine Learning

(1) Supervised learning
L regression
Classification
......
(2) Unsupervised learning
clustering
Dimensionality reduction
......
(3) The purpose of machine learning
Image Identification
speech recognition
Precise positioning
Content recommendation

2.4 Mathematical knowledge involved in machine learning

Linear algebra: vectors, matrices, linear transformations., eigenvalues, singular values...
Intercepting integrals: derivatives, partial derivatives...
Probability theory: Bies' law, Bernoulli distribution, normal distribution...
Statistics: variance, covariance, correlation coefficient, parameter estimation, hypothesis testing...
Convex optimization: linear programming, quadratic programming, least quadratic optimization, regularization...

2.5 Programming knowledge

(1) Python basic syntax
Basic data types, loops, conditional judgments, functions, classes and modules...
(2) Python common modules
numpy library, pandas library, matplotlib library, scipy library. sklearn library...  

2.6 Algorithm knowledge

(1) Supervised learning algorithm
Regression: linear regression, order-preserving regression...
Classification: K-Nearest Neighbors, Support Vector Machines, Decision Trees, Neural Networks...
(2) Unsupervised learning algorithm
Clustering: K-Means clustering. Spectral clustering...  
Longwei: principal component analysis, linear discriminant analysis...
(3) KNN algorithm
concept:
The full name of K Nearest Neighbors is a supervised learning algorithm suitable for classification problems.
calculation steps
1) Calculate the distance between the unknown transaction and each known categorical feature.
2) Select an appropriate K value and find out the known classifications corresponding to the top K minimum values ​​in the distance.
3) According to the principle that the minority obeys the majority, the category of the new transaction is predicted.

3 python code experience

import pandas as pd
from sklearn.neighbors import KNeighborsClassifier

#~~~~~~~~Step1 读取数据~~~~~~~~~~~~~
df = pd .read_csv ( "./工作/insect.csv" )
x= df[['翅长','触角长']].values
y = df['类别'].values

#~~~~~~~Step2数据预处理~~~~~~~~~~~~~~
#最后3个样本为未知样本﹐其余样本为已知样本
train_X = x[:-3]
train_Y = y[:-3]pred_X = ×[-3:]

#~~~~~~~Step3 训练模型~~~~~~~~~~~~~~~~`
# 在K近邻分类器中,K值通过参数n_neighbors设置
model = KNeighborsclassifier(n_neighbors=3)
model.fit(train_X, train_Y)

#~~~~~~~Step4应用模型~~~~~~~~~~~~~~~`
# 应用训练出的模型预测未知蚊子的类别
pred_Y = model.predict(pred_X)print(pred_Y)


Guess you like

Origin blog.csdn.net/weixin_46039719/article/details/123979258