Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. import pandas as pd
  2. import numpy as np
  3. import os
  4.  
  5. from sklearn.datasets import load_iris
  6. from sklearn.feature_selection import SelectKBest
  7. from sklearn.feature_selection import f_classif
  8.  
  9. features_dic = {}
  10. results_dic = {}
  11.  
  12. script_dir = os.path.dirname(__file__)
  13. rel_path = "bialaczka_switched.xls"
  14. abs_file_path = os.path.join(script_dir, rel_path)
  15.  
  16. dataExcel = pd.read_excel(abs_file_path, nrows=410)
  17. df = pd.DataFrame(dataExcel)
  18.  
  19. feature_data = df.iloc[:, :-2]
  20. diagnose_classes = np.array(df['Klasa'])
  21.  
  22. # Create an SelectKBest object to select features with two best ANOVA F-Values
  23. fvalue_selector = SelectKBest(f_classif)
  24.  
  25. # Apply the SelectKBest object to the features and target
  26. feature_data_kbest = fvalue_selector.fit(feature_data, diagnose_classes)
  27.  
  28. ranking = fvalue_selector.scores_
  29.  
  30. ranking_ = pd.DataFrame(ranking)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement