Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import numpy as np
- import os
- from sklearn.feature_selection import SelectKBest
- from sklearn.feature_selection import f_classif
- features_dic = {}
- results_dic = {}
- script_dir = os.path.dirname(__file__)
- rel_path = "dane_zawaly.xlsx"
- abs_file_path = os.path.join(script_dir, rel_path)
- dataExcel = pd.read_excel(abs_file_path, nrows=901)
- df = pd.DataFrame(dataExcel)
- # print(df)
- feature_data = df.iloc[:, :-1]
- diagnose_classes = np.array(df['Klasa'])
- # Create an SelectKBest object to select features with two best ANOVA F-Values
- fvalue_selector = SelectKBest(f_classif)
- # Apply the SelectKBest object to the features and target
- feature_data_kbest = fvalue_selector.fit(feature_data, diagnose_classes)
- # print('Original number of features:', feature_data.shape[1])
- # print('Reduced number of features:', feature_data_kbest.shape[1])
- # print('Klasy', feature_data_kbest)
- ranking = fvalue_selector.scores_
- ranking_ulepszony = pd.DataFrame(ranking)
- # ranking_ulepszony.insert(1, 'Numer cechy', pd.DataFrame(list(range(1,60))))
- # ranking_ulepszony.sort_values(ranking_ulepszony[0])
- print(ranking_ulepszony)
- # print(ranking)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement