scikit-hyperband icon indicating copy to clipboard operation
scikit-hyperband copied to clipboard

error with pipeline

Open developpeur-windev-php-python opened this issue 5 years ago • 1 comments

Hello,

I have always an error ValueError: Invalid parameter n_estimators for estimator Pipeline(memory=None, steps=[('umap', UMAP(a=None, angular_rp_forest=False, b=None, init='spectral', learning_rate=1.0, local_connectivity=1.0, metric='euclidean', metric_kwds=None, min_dist=0.1, n_components=2, n_epochs=None, n_neighbors=15, negative_sample_rate=5, random_state=456, repulsion_strength=1.0, s...ax_iter=1000, multi_class='ovr', penalty='l2', random_state=None, tol=0.0001, verbose=0))]). Check the list of available parameters with estimator.get_params().keys().

my code from sklearn.model_selection import RandomizedSearchCV umap2 = umap.UMAP(random_state=456) svc=LinearSVC(dual=False) pipeline = Pipeline([("umap", umap2), ("svc", svc)])

params_grid_pipeline = {"umap__n_neighbors": [5,20], "umap__n_components": [15, 25, 50], "svc__C": [10**k for k in range(-3, 4)], 'svc__random_state':[43]}

gs=HyperbandSearchCV(estimator=pipeline, param_distributions=params_grid_pipeline, scoring='recall', cv=10, verbose=1,n_jobs = 5)

gs = gs.fit(X_train.values,y_train.values.ravel())

My params are good

If you read the documentation of the HyperbandSearchCV class, you will see that there is an argument resource_param that you need to set. It tells the method which parameter corresponds to the cost parameter for hyperband, and is by default set to n_estimators. You'll have to change it to whatever makes sense for your method

thuijskens avatar May 11 '19 10:05 thuijskens