You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
"""Example using an sklearn Pipeline with TuneGridSearchCV.
Example taken and modified from https://scikit-learn.org/stable/auto_examples/compose/
plot_compare_reduction.html
"""
from tune_sklearn import TuneSearchCV
from tune_sklearn import TuneGridSearchCV
from sklearn.datasets import load_digits
from sklearn.pipeline import Pipeline
from sklearn.svm import LinearSVC
from sklearn.decomposition import PCA, NMF
from sklearn.feature_selection import SelectKBest, chi2
pipe = Pipeline([
# the reduce_dim stage is populated by the param_grid
("reduce_dim", "passthrough"),
("classify", LinearSVC(dual=False, max_iter=10000))
])
random = TuneSearchCV(pipe, param_grid, search_optimization="random")
X, y = load_digits(return_X_y=True)
random.fit(X, y)
print(random.cv_results_)
grid = TuneGridSearchCV(pipe, param_grid=param_grid)
grid.fit(X, y)
print(grid.cv_results_)
The code you provided will not run directly. The environment is already configured
WinError 2] 系统找不到指定的文件。
File "C:\Users\dell\Downloads\测试3.py", line 38, in
random.fit(X, y)
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
"""Example using an sklearn Pipeline with TuneGridSearchCV.
Example taken and modified from
https://scikit-learn.org/stable/auto_examples/compose/
plot_compare_reduction.html
"""
from tune_sklearn import TuneSearchCV
from tune_sklearn import TuneGridSearchCV
from sklearn.datasets import load_digits
from sklearn.pipeline import Pipeline
from sklearn.svm import LinearSVC
from sklearn.decomposition import PCA, NMF
from sklearn.feature_selection import SelectKBest, chi2
pipe = Pipeline([
# the reduce_dim stage is populated by the param_grid
("reduce_dim", "passthrough"),
("classify", LinearSVC(dual=False, max_iter=10000))
])
N_FEATURES_OPTIONS = [2, 4, 8]
C_OPTIONS = [1, 10]
param_grid = [
{
"reduce_dim": [PCA(iterated_power=7), NMF()],
"reduce_dim__n_components": N_FEATURES_OPTIONS,
"classify__C": C_OPTIONS
},
{
"reduce_dim": [SelectKBest(chi2)],
"reduce_dim__k": N_FEATURES_OPTIONS,
"classify__C": C_OPTIONS
},
]
random = TuneSearchCV(pipe, param_grid, search_optimization="random")
X, y = load_digits(return_X_y=True)
random.fit(X, y)
print(random.cv_results_)
grid = TuneGridSearchCV(pipe, param_grid=param_grid)
grid.fit(X, y)
print(grid.cv_results_)
The code you provided will not run directly. The environment is already configured
WinError 2] 系统找不到指定的文件。
File "C:\Users\dell\Downloads\测试3.py", line 38, in
random.fit(X, y)
The text was updated successfully, but these errors were encountered: