Parcourir la source

model parameters reduced

Jérôme BUISINE il y a 4 ans
Parent
commit
6f3a6f5153
1 fichiers modifiés avec 4 ajouts et 4 suppressions
  1. 4 4
      models.py

+ 4 - 4
models.py

@@ -6,7 +6,7 @@ from sklearn.neighbors import KNeighborsClassifier
 from sklearn.ensemble import GradientBoostingClassifier
 from sklearn.ensemble import GradientBoostingClassifier
 from sklearn.feature_selection import RFECV
 from sklearn.feature_selection import RFECV
 import sklearn.svm as svm
 import sklearn.svm as svm
-from sklearn.metrics.scorer import accuracy_scorer
+from sklearn.metrics import accuracy_scorer
 from thundersvm import SVC
 from thundersvm import SVC
 
 
 # variables and parameters
 # variables and parameters
@@ -21,12 +21,12 @@ def my_accuracy_scorer(*args):
 
 
 def _get_best_model(X_train, y_train):
 def _get_best_model(X_train, y_train):
 
 
-    Cs = [0.001, 0.01, 0.1, 1, 2, 5, 10, 100, 1000]
-    gammas = [0.001, 0.01, 0.1, 1, 2, 5, 10, 100]
+    Cs = [0.001, 0.01, 0.1, 1, 10, 100, 1000]
+    gammas = [0.001, 0.01, 0.1, 5, 10, 100]
     param_grid = {'kernel':['rbf'], 'C': Cs, 'gamma' : gammas}
     param_grid = {'kernel':['rbf'], 'C': Cs, 'gamma' : gammas}
 
 
     svc = svm.SVC(probability=True, class_weight='balanced')
     svc = svm.SVC(probability=True, class_weight='balanced')
-    clf = GridSearchCV(svc, param_grid, cv=10, verbose=1, scoring=my_accuracy_scorer, n_jobs=-1)
+    clf = GridSearchCV(svc, param_grid, cv=5, verbose=1, scoring=my_accuracy_scorer, n_jobs=-1)
 
 
     clf.fit(X_train, y_train)
     clf.fit(X_train, y_train)