Last active
April 2, 2020 00:22
-
-
Save AmeerHajAli/c329751c311355b2d4a283cba689d980 to your computer and use it in GitHub Desktop.
HP SVM sklearn Ray
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from joblib import parallel_backend # added line. | |
from sklearn.datasets import load_digits | |
from sklearn.model_selection import RandomizedSearchCV | |
from sklearn.svm import SVC | |
from ray.util.joblib import register_ray # added line. | |
register_ray() # added line. | |
param_space = { | |
'C': np.logspace(-6, 6, 30), | |
'gamma': np.logspace(-8, 8, 30), | |
'tol': np.logspace(-4, -1, 30), | |
'class_weight': [None, 'balanced'], | |
} | |
model = SVC(kernel='rbf') | |
search = RandomizedSearchCV(model, param_space, cv=5, n_iter=300,verbose=1) | |
digits = load_digits() | |
#ray.init(address=”auto”) | |
with parallel_backend('ray'): # added line. | |
search.fit(digits.data, digits.target) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment