text_plain_output_1.png
from sklearn import svm

from sklearn.preprocessing import LabelEncoder

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

data = pd.read_csv('../input/mushrooms.csv')

from sklearn.preprocessing import LabelEncoder
labelencoder = LabelEncoder()
for col in data.columns:
    data[col] = labelencoder.fit_transform(data[col])

data = np.array(data)
_length = 8000
train, test = (data[0:_length,], data[_length:,])
Xtrain, ytrain = (train[:, 1:], train[:, 0])
Xtest, ytest = (test[:, 1:], test[:, 0])

from sklearn import svm
model = svm.SVC(kernel='linear', gamma=1)
model.fit(Xtrain, ytrain)
scr = model.score(Xtrain, ytrain)
predicted = model.predict(Xtest)
dif = predicted - ytest

from keras.models import *
from keras.layers import *
batch_size = 1
mlp_neurons = 5
neurons = 5
bi_neurons = 5
repeats = 5
nb_epochs = 5

def mlp_model(train, batch_size, nb_epoch, neurons):
    X, y = (train[:, 1:], train[:, 0])
    model = Sequential()
    model.add(Dense(neurons, input_dim=X.shape[1], init='normal', activation='relu'))
    model.add(Dropout(0.2))
    model.add(Dense(neurons, init='normal', activation='relu'))
    model.add(Dropout(0.2))
    model.add(Dense(neurons, init='normal', activation='relu'))
    model.add(Dense(1, activation='linear'))
    model.compile(loss='mse', optimizer='adam', metrics=['acc'])
    for i in range(nb_epoch):
        model.fit(X, y, epochs=1, batch_size=batch_size, verbose=2, shuffle=False)
        model.reset_states()
    return model

mlp_RNN = mlp_model(train, batch_size, nb_epochs, mlp_neurons)