text_plain_output_1.png
from keras.layers import Dense

from keras.models import Sequential

from keras.utils import to_categorical

from sklearn import preprocessing,cross_validation,neighbors

from sklearn import tree

from sklearn.model_selection import cross_val_score

import numpy as np

import pandas as pd

import numpy as np
import pandas as pd
from sklearn import preprocessing, cross_validation, neighbors
from keras.models import Sequential
from keras.layers import Dense
from keras.utils import to_categorical
from sklearn import tree
import graphviz
from sklearn.model_selection import cross_val_score
df = pd.read_csv('../input/glass.csv')

X = np.array(df.drop(['Type'], 1).astype(float))
X = preprocessing.scale(X)
y = np.array(df['Type'])
y = to_categorical(y)
X_train, X_test, y_train, y_test = cross_validation.train_test_split(X, y, test_size=0.2)
clf = neighbors.KNeighborsClassifier()
clf.fit(X_train, y_train)
accuracy = clf.score(X_test, y_test)

model = Sequential()
model.add(Dense(50, activation='relu', input_shape=(X.shape[1],)))
model.add(Dense(25, activation='relu'))
model.add(Dense(y.shape[1], activation='softmax'))
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
model.fit(X, y, epochs=50, batch_size=5, validation_split=0.2, verbose=True)
scores = model.evaluate(X, y)

trs = tree.DecisionTreeClassifier(max_depth=3)
cross_val_score(trs, X, y, cv=5)