Fenny_Theo

<Type1>540_Model Testing

Jul 22nd, 2021
892
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pandas as pd
  2. import numpy as np
  3. import h5py
  4. import matplotlib
  5. #matplotlib.use('agg')
  6. import matplotlib.pyplot as plt
  7. from keras.models import Model, Sequential
  8. from keras.layers import Dense, Input, concatenate,Conv1D, Conv2D, MaxPooling2D, Conv2DTranspose,MaxPooling1D, Cropping2D, Multiply, subtract, Flatten, Reshape, Permute, LSTM, TimeDistributed,Dropout,BatchNormalization,UpSampling1D
  9. from keras.optimizers import SGD
  10. from keras.callbacks import ModelCheckpoint,EarlyStopping
  11. import tensorflow as tf
  12. from keras.models import load_model
  13. from keras import optimizers
  14. from keras import regularizers
  15. from math import sqrt
  16. from sklearn.metrics import mean_squared_error
  17. from sklearn.metrics import mean_absolute_error
  18. import pickle
  19. from sklearn.preprocessing import StandardScaler
  20. import time
  21. from sklearn import preprocessing
  22. from numpy import argmax
  23. from keras.utils import to_categorical
  24. from tabulate import tabulate
  25. from numpy import array
  26. from sklearn.externals import joblib
  27. from sklearn.metrics import confusion_matrix,classification_report
  28.  
  29. filename="D:\\NCSU Research\\GEARS_Jul9\\GEARS\\540\\data_test.complete.csv"
  30. test=pd.read_csv(filename)
  31.  
  32.  
  33. clf=joblib.load("train_model_540.m")
  34.  
  35.  
  36. x_columns = [x for x in test.columns if x not in ["label_new"]]
  37. X=test[x_columns]
  38. y=test["label_new"]
  39.  
  40.  
  41. y_predicted = clf.predict(X)    
  42. accuracy = np.mean(y_predicted == y) * 100
  43. confusion_m=confusion_matrix(y, y_predicted)
  44. print ("y_predicted\n",y_predicted)
  45. print ("accuracy:",accuracy)
  46. print(confusion_m)
  47. print(classification_report(y,y_predicted))
  48.  
RAW Paste Data