print(data.head()) data = StandardScaler().fit_transform(data.values) data = pd.DataFrame(data, columns=columns) return data s = DataSetFormation() s.read_csv() s.createFeatureMatrixCGM() mealFeatures = Features(4) s.mealDataFrame.to_csv("myMealData.csv") noMealFeatures = Features(4) s.noMealDataFrame.to_csv("myNoMealData.csv") finalMealDataFrame = pd.read_csv("myMealData.csv") finalNoMealDataFrame = pd.read_csv("myNoMealData.csv") meal = mealFeatures.completefeatures(finalMealDataFrame) print(meal) print("Final Meal DataSet") mealPrincipalComponentDataFrame = s.normalizeData(meal) nomeal = noMealFeatures.completefeatures(finalNoMealDataFrame) print(nomeal) print("Here", mealPrincipalComponentDataFrame) mealPrincipalComponentDataFrame['Label'] = 1 print("Final NoMeal DataSet") noMealPrincipalComponentDataFrame = s.normalizeData(nomeal) noMealPrincipalComponentDataFrame['Label'] = 0 print("Here", noMealPrincipalComponentDataFrame) #Concatinating 2 dataframes finalMealNoMealDataFrame = pd.concat( [mealPrincipalComponentDataFrame, noMealPrincipalComponentDataFrame],
test_dataframe = pd.read_csv('MealNoMealData/mealData3.csv', names=columns) # print(test_dataframe) row, column = test_dataframe.shape for i in range(row): test_dataframe.dropna(thresh=4, axis=0) print("test_data") # print(test_dataframe) test_dataframe = test_dataframe.interpolate(method='linear', limit_direction='backward') print(test_dataframe) # test_dataframe=test_dataframe.dropna() # print(test_dataframe) s = DataSetFormation() f = Features(4) data = f.completefeatures(test_dataframe) data = normalized_data = s.normalizeData(data) # data=s.applyPCA(data,3) data["Label"] = 1 print(data) column = [ 'fft1', 'fft2', 'fft3', 'fft4', 'velocity1', 'velocity2', 'velocity3', 'velocity4', 'rolling1', 'rolling2', 'rolling3', 'rolling4', 'dwt1', 'dwt2', 'dwt3', 'dwt4' ] column_p = ['pc1', 'pc2', 'pc3'] column_v = ['velocity1', 'velocity2', 'rolling2', 'rolling1'] value = loaded_model.predict(data[column_v]) print(value) result = loaded_model.score(data[column_v], data['Label']) print(result)
'rolling4', 'expwindow1', 'expwindow2', 'expwindow3', 'expwindow4', 'dwt1', 'dwt2', 'dwt3', 'dwt4' ] data = pd.DataFrame(extracted_features, columns=columns) data = data.dropna() print(data.head()) data = MinMaxScaler().fit_transform(data.values) data = pd.DataFrame(data, columns=columns) self.applyPCA(data, 5, person, 'PCA') print("""----------------------------------------| | Enter a Person Number | | | |-----------------------------------------|""") n = input() directoryPath = os.getcwd() access_right = 0o777 try: if not os.path.isdir(directoryPath + '/Person' + str(n)): os.mkdir(directoryPath + '/Person' + str(n), access_right) except OSError: print('Directoy not created') s = DataSetFormation(int(n)) s.plotCGMData(int(n)) b = Features(4, s.CGMData) final_extracted_feature_matrix = b.completefeatures(int(n)) df = pd.DataFrame(final_extracted_feature_matrix) df.to_csv('FeaturesExtracted.csv') s.normalizeData(final_extracted_feature_matrix, n)