如何使用fashion-MNIST数据集进行逻辑回归

时间:2020-09-29 05:00:54

标签: python

我不知道下一步该怎么做,我尝试了很多次,但是我的老师要我制作10个模型。

 import pandas as pd
from numpy import reshape
from sklearn import metrics

train = pd.read_csv('fashion_train.csv',header =None)
print(train.head())
label = train[0]

test = pd.read_csv('fashion_test.csv',header = None)
print(test.head())
labelT = test[0]
print(labelT)
X_train = train.iloc[:, 1:]

print(X_train)

y_train = train.iloc[:, 0]
print(y_train)

X_test = test.iloc[:, 1:]
y_test = test.iloc[:, 0]

from sklearn.linear_model import LogisticRegression

1 个答案:

答案 0 :(得分:0)

好的,现在您需要做的是训练模型。因此,只需将以下行添加到您的代码中即可。

model = LogisticRegression()
model.fit(X_train, y_train)
prediction = model.predict(X_test)

现在您可以使用任何精度计算器。例如:

score = sklearn.metrics.classification_report(y_test, prediction)
print(score)

我也建议将导入更改为import sklearn

相关问题