Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- from main import classifier, test_set
- df = pd.read_csv('data.csv')
- # print(df)
- dataset = df.values
- #
- # print(dataset)
- X = dataset[:, 0:10]
- Y = dataset[:, 10]
- from sklearn import preprocessing
- min_max_scaler = preprocessing.MinMaxScaler()
- X_scale = min_max_scaler.fit_transform(X)
- # print(X_scale)
- from sklearn.model_selection import train_test_split
- X_train, X_val_and_test, Y_train, Y_val_and_test = train_test_split(X_scale, Y, test_size=0.3)
- X_val, X_test, Y_val, Y_test = train_test_split(X_val_and_test, Y_val_and_test, test_size=0.5)
- print(X_train.shape, X_val.shape, X_test.shape, Y_train.shape, Y_val.shape, Y_test.shape)
- from keras.models import Sequential
- from keras.layers import Dense
- model = Sequential([
- Dense(32, activation='relu', input_shape=(10,)),
- Dense(32, activation='relu'),
- Dense(1, activation='sigmoid'),
- ])
- model.compile(optimizer='sgd',
- loss='binary_crossentropy',
- metrics=['accuracy'])
- hist = model.fit(X_train, Y_train,
- batch_size=32, epochs=100,
- validation_data=(X_val, Y_val))
- model.evaluate(X_test, Y_test)[1]
- score = model.evaluate(X_test, Y_test, verbose=0)
- # print('Test loss:', score[0])
- print('Test accuracy:', score[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement