evolutionaryalgorithmsearchcv How to dowload it? evolutionaryalgorithmsearchcv
evolutionaryalgorithmsearchcv How to use it? evolutionaryalgorithmsearchcv
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
evolutionaryalgorithmsearchcv How to get it for free? evolutionaryalgorithmsearchcv
- from sklearn import datasets
- from sklearn.decomposition import PCA
- from sklearn.pipeline import Pipeline
- from sklearn.svm import SVC
- grid = {
- 'svc__C': [0.001, 0.01, 0.05, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0, 1.3, 1.5, 1.7, 10, 100, 1000],
evolutionaryalgorithmsearchcv How to dowload it? evolutionaryalgorithmsearchcv
- 'svc__kernel': ['linear', 'poly', 'rbf', 'sigmoid'],
- 'pca__n_components': [1, 2, 3, 4]
- }
- iris = datasets.load_iris()
- X, y = iris.data, iris.target
- pipeline = Pipeline(steps=[
- ('pca', PCA()),
- ('svc', SVC())
- ])
- results = []
- for n_iter in range(1, 20):
- clf_ev = EvolutionaryAlgorithmSearchCV(pipeline, grid, scoring=None, verbose=True, n_jobs=4, population_size=5,
- generations_number=n_iter)
- clf_ev.fit(X, y)
- results.append(clf_ev.best_score_)
- print([x.values[0] for x in results])
- from sklearn.grid_search import RandomizedSearchCV
- results = []
- for n_iter in range(1, 100):
- clf_rand = RandomizedSearchCV(pipeline, grid, scoring=None, verbose=True, n_jobs=4,
- n_iter=n_iter)
- clf_rand.fit(X, y)
- results.append(sorted(clf_rand.grid_scores_, key=lambda x: x[1])[-1])
- print([x[1] for x in results])
Advertisement
evolutionaryalgorithmsearchcv How to get it? evolutionaryalgorithmsearchcv
evolutionaryalgorithmsearchcv How to use it? evolutionaryalgorithmsearchcv
evolutionaryalgorithmsearchcv How to get it? evolutionaryalgorithmsearchcv
Add Comment
Please, Sign In to add comment