Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. from sklearn import datasets
  2. from sklearn.linear_model import LogisticRegression
  3. wine = datasets.load_wine()
  4. X = wine.data # rows of features
  5. y = wine.target # integer labels
  6.  
  7. num_features = len(X[0])
  8. features = []
  9. for i in range(7):
  10.     selected_feature = None
  11.     max_precision = -1
  12.     for j in range(num_features):
  13.         if j in features:
  14.             continue
  15.         current_features = features.copy() # copy the current selection
  16.         current_features.append(j) # and add what we are considering now
  17.         sel_X = X[:, current_features]
  18.        
  19.         # 1. sel_X로 logistic regression classifier 학습
  20.        
  21.         # 2. classifier 정확도 평가
  22.        
  23.         # 3. 해당 feature(j)를 고를건지 말건지 판단
  24.        
  25.         print('>', current_features, score)
  26.         #################################
  27.     if selected_feature is not None:
  28.         features.append(selected_feature)
  29.     print(features)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement