python分类模型_Python分类模型构建

from sklearn.model_selection import train_test_split

eg: X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)

标准化 (同模型使用方法相同)

from sklearn.preprocessing import StandardScaler

归一化(同模型使用方法相同)

from sklearn.preprocessing import MinMaxScaler

(模型参数待补充)

1.逻辑回归模型

Logistic函数图像很像一个“S”型,所以该函数又叫 sigmoid 函数。

from sklearn.liner_model import LogisticRegression

LR = LogisticRegression()

clf = LR.fit(X, y)

prediction = clf.predict(X)

2.线性判别(LDA)——费希尔判别

from sklearn.discriminant_analysis import LinearDiscriminantAnalysis

LDA = LinearDiscriminantAnalysis()

clf = LDA.fit(X, y)

prediction = clf.predict(X)

3.KNN

from sklearn.neighbors import KNeighborsClassifier

clf = KNeighborsClassifier().fit(X, y) _可以一步到位

prediction = clf.predict(X)

4.贝叶斯

from sklearn.naive_bayes import GaussianNB

5.决策树

from sklearn.tree import DecisionTreeClassifier

6.支持向量机

from sklearn.svm import SVC

7.神经网络

from sklearn.neural_network import MLPClassifier

你可能感兴趣的:(python分类模型)