ABED160105

Perkinson CNN Train accuracy test abed

Sep 29th, 2020
1,320
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pandas as pd
  2.  
  3. from main import classifier, test_set
  4.  
  5. df = pd.read_csv('data.csv')
  6. # print(df)
  7.  
  8. dataset = df.values
  9. #
  10. # print(dataset)
  11.  
  12. X = dataset[:, 0:10]
  13. Y = dataset[:, 10]
  14.  
  15. from sklearn import preprocessing
  16.  
  17. min_max_scaler = preprocessing.MinMaxScaler()
  18. X_scale = min_max_scaler.fit_transform(X)
  19.  
  20. # print(X_scale)
  21.  
  22. from sklearn.model_selection import train_test_split
  23.  
  24. X_train, X_val_and_test, Y_train, Y_val_and_test = train_test_split(X_scale, Y, test_size=0.3)
  25. X_val, X_test, Y_val, Y_test = train_test_split(X_val_and_test, Y_val_and_test, test_size=0.5)
  26. print(X_train.shape, X_val.shape, X_test.shape, Y_train.shape, Y_val.shape, Y_test.shape)
  27.  
  28.  
  29. from keras.models import Sequential
  30. from keras.layers import Dense
  31.  
  32.  
  33. model = Sequential([
  34.     Dense(32, activation='relu', input_shape=(10,)),
  35.     Dense(32, activation='relu'),
  36.     Dense(1, activation='sigmoid'),
  37. ])
  38.  
  39. model.compile(optimizer='sgd',
  40.               loss='binary_crossentropy',
  41.               metrics=['accuracy'])
  42.  
  43. hist = model.fit(X_train, Y_train,
  44.           batch_size=32, epochs=100,
  45.           validation_data=(X_val, Y_val))
  46.  
  47. model.evaluate(X_test, Y_test)[1]
  48.  
  49. score = model.evaluate(X_test, Y_test, verbose=0)
  50. # print('Test loss:', score[0])
  51. print('Test accuracy:', score[1])
  52.  
RAW Paste Data