Sklearn-SVM&Tensorflow MLP fashion_mnist

# encoding = utf-8

import tensorflow as tf
from tensorflow import keras

from sklearn import neighbors, datasets
from sklearn.model_selection import train_test_split

(X_train, y_train), (X_test, y_test) = keras.datasets.fashion_mnist.load_data()

X_train = X_train.reshape(X_train.shape[0], -1)
X_test = X_test.reshape(X_test.shape[0], -1)

assert X_train.shape == (60000, 784)  #checks if it's been reshaped - flattended here.Execution stops if not true
assert X_test.shape == (10000, 784)
X_train.dtype
#X_train[1]
#y_train[1:100]


train_df = pd.DataFrame(X_train)
train_df['label'] = pd.DataFrame(y_train)

test_df = pd.DataFrame(X_test)
test_df['label'] = pd.DataFrame(y_test)


for i in range(784):
    train_df[i] = train_df[i].apply(lambda x:x/255)
    test_df[i] = test_df[i].apply(lambda x:x/255)

from sklearn.svm import SVC

model = SVC(kernel='linear') 
mode

版权声明:本文为weixin_41362649原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。