Browse Source

enable thundersvm choice

Jérôme BUISINE 1 year ago
parent
commit
e26e4afc69
1 changed files with 9 additions and 10 deletions
  1. 9 10
      models.py

+ 9 - 10
models.py

@@ -7,7 +7,7 @@ from sklearn.ensemble import GradientBoostingClassifier
 from sklearn.feature_selection import RFECV
 import sklearn.svm as svm
 from sklearn.metrics import accuracy_score
-#from thundersvm import SVC
+from thundersvm import SVC
 
 # variables and parameters
 n_predict = 0
@@ -41,19 +41,18 @@ def svm_model(X_train, y_train):
 
 def _get_best_gpu_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]
-    # param_grid = {'kernel':['rbf'], 'C': Cs, 'gamma' : gammas}
+    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]
+    param_grid = {'kernel':['rbf'], 'C': Cs, 'gamma' : gammas}
 
-    # svc = SVC(probability=True, class_weight='balanced')
-    # clf = GridSearchCV(svc, param_grid, cv=10, verbose=1, scoring=my_accuracy_scorer, n_jobs=-1)
+    svc = SVC(probability=True, class_weight='balanced')
+    clf = GridSearchCV(svc, param_grid, cv=10, verbose=1, scoring=my_accuracy_scorer, n_jobs=-1)
 
-    # clf.fit(X_train, y_train)
+    clf.fit(X_train, y_train)
 
-    # model = clf.best_estimator_
+    model = clf.best_estimator_
 
-    # return model
-    pass
+    return model
 
 def svm_gpu(X_train, y_train):