%global _empty_manifest_terminate_build 0 Name: python-hpsklearn Version: 0.1.0 Release: 1 Summary: Hyperparameter Optimization for sklearn License: BSD URL: http://hyperopt.github.com/hyperopt-sklearn/ Source0: https://mirrors.nju.edu.cn/pypi/web/packages/ce/cb/61b99f73621e2692abd0e730f7888a9983d01f626868336fa1db1d57bc1e/hpsklearn-0.1.0.tar.gz BuildArch: noarch %description # hyperopt-sklearn [Hyperopt-sklearn](http://hyperopt.github.com/hyperopt-sklearn/) is [Hyperopt](http://hyperopt.github.com/hyperopt)-based model selection among machine learning algorithms in [scikit-learn](http://scikit-learn.org/). See how to use hyperopt-sklearn through [examples](http://hyperopt.github.io/hyperopt-sklearn/#documentation) or older [notebooks](http://nbviewer.ipython.org/github/hyperopt/hyperopt-sklearn/tree/master/notebooks) ## Installation Installation from a git clone using pip is supported: git clone git@github.com:hyperopt/hyperopt-sklearn.git (cd hyperopt-sklearn && pip install -e .) ## Usage If you are familiar with sklearn, adding the hyperparameter search with hyperopt-sklearn is only a one line change from the standard pipeline. ``` from hpsklearn import HyperoptEstimator, svc from sklearn import svm # Load Data # ... if use_hpsklearn: estim = HyperoptEstimator(classifier=svc('mySVC')) else: estim = svm.SVC() estim.fit(X_train, y_train) print(estim.score(X_test, y_test)) # <> ``` Complete example using the Iris dataset: ``` from hpsklearn import HyperoptEstimator, any_classifier from sklearn.datasets import load_iris from hyperopt import tpe import numpy as np # Download the data and split into training and test sets iris = load_iris() X = iris.data y = iris.target test_size = int(0.2 * len(y)) np.random.seed(13) indices = np.random.permutation(len(X)) X_train = X[ indices[:-test_size]] y_train = y[ indices[:-test_size]] X_test = X[ indices[-test_size:]] y_test = y[ indices[-test_size:]] # Instantiate a HyperoptEstimator with the search space and number of evaluations estim = HyperoptEstimator(classifier=any_classifier('my_clf'), preprocessing=any_preprocessing('my_pre'), algo=tpe.suggest, max_evals=100, trial_timeout=120) # Search the hyperparameter space based on the data estim.fit( X_train, y_train ) # Show the results print( estim.score( X_test, y_test ) ) # 1.0 print( estim.best_model() ) # {'learner': ExtraTreesClassifier(bootstrap=False, class_weight=None, criterion='gini', # max_depth=3, max_features='log2', max_leaf_nodes=None, # min_impurity_decrease=0.0, min_impurity_split=None, # min_samples_leaf=1, min_samples_split=2, # min_weight_fraction_leaf=0.0, n_estimators=13, n_jobs=1, # oob_score=False, random_state=1, verbose=False, # warm_start=False), 'preprocs': (), 'ex_preprocs': ()} ``` Here's an example using MNIST and being more specific on the classifier and preprocessing. ``` from hpsklearn import HyperoptEstimator, extra_trees from sklearn.datasets import fetch_mldata from hyperopt import tpe import numpy as np # Download the data and split into training and test sets digits = fetch_mldata('MNIST original') X = digits.data y = digits.target test_size = int(0.2 * len(y)) np.random.seed(13) indices = np.random.permutation(len(X)) X_train = X[ indices[:-test_size]] y_train = y[ indices[:-test_size]] X_test = X[ indices[-test_size:]] y_test = y[ indices[-test_size:]] # Instantiate a HyperoptEstimator with the search space and number of evaluations estim = HyperoptEstimator(classifier=extra_trees('my_clf'), preprocessing=[], algo=tpe.suggest, max_evals=10, trial_timeout=300) # Search the hyperparameter space based on the data estim.fit( X_train, y_train ) # Show the results print( estim.score( X_test, y_test ) ) # 0.962785714286 print( estim.best_model() ) # {'learner': ExtraTreesClassifier(bootstrap=True, class_weight=None, criterion='entropy', # max_depth=None, max_features=0.959202875857, # max_leaf_nodes=None, min_impurity_decrease=0.0, # min_impurity_split=None, min_samples_leaf=1, # min_samples_split=2, min_weight_fraction_leaf=0.0, # n_estimators=20, n_jobs=1, oob_score=False, random_state=3, # verbose=False, warm_start=False), 'preprocs': (), 'ex_preprocs': ()} ``` ## Available Components Not all of the classifiers/regressors/preprocessing from sklearn have been implemented yet. A list of those currently available is shown below. If there is something you would like that is not on the list, feel free to make an issue or a pull request! The source code for implementing these functions is found [here](https://github.com/hyperopt/hyperopt-sklearn/blob/master/hpsklearn/components.py) ### Classifiers ``` svc svc_linear svc_rbf svc_poly svc_sigmoid liblinear_svc knn ada_boost gradient_boosting random_forest extra_trees decision_tree sgd xgboost_classification multinomial_nb gaussian_nb passive_aggressive linear_discriminant_analysis quadratic_discriminant_analysis rbm colkmeans one_vs_rest one_vs_one output_code ``` For a simple generic search space across many classifiers, use `any_classifier`. If your data is in a sparse matrix format, use `any_sparse_classifier`. ### Regressors ``` svr svr_linear svr_rbf svr_poly svr_sigmoid knn_regression ada_boost_regression gradient_boosting_regression random_forest_regression extra_trees_regression sgd_regression xgboost_regression ``` For a simple generic search space across many regressors, use `any_regressor`. If your data is in a sparse matrix format, use `any_sparse_regressor`. ### Preprocessing ``` pca one_hot_encoder standard_scaler min_max_scaler normalizer ts_lagselector tfidf ``` For a simple generic search space across many preprocessing algorithms, use `any_preprocessing`. If you are working with raw text data, use `any_text_preprocessing`. Currently only TFIDF is used for text, but more may be added in the future. Note that the `preprocessing` parameter in `HyperoptEstimator` is expecting a list, since various preprocessing steps can be chained together. The generic search space functions `any_preprocessing` and `any_text_preprocessing` already return a list, but the others do not so they should be wrapped in a list. If you do not want to do any preprocessing, pass in an empty list `[]`. %package -n python3-hpsklearn Summary: Hyperparameter Optimization for sklearn Provides: python-hpsklearn BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-hpsklearn # hyperopt-sklearn [Hyperopt-sklearn](http://hyperopt.github.com/hyperopt-sklearn/) is [Hyperopt](http://hyperopt.github.com/hyperopt)-based model selection among machine learning algorithms in [scikit-learn](http://scikit-learn.org/). See how to use hyperopt-sklearn through [examples](http://hyperopt.github.io/hyperopt-sklearn/#documentation) or older [notebooks](http://nbviewer.ipython.org/github/hyperopt/hyperopt-sklearn/tree/master/notebooks) ## Installation Installation from a git clone using pip is supported: git clone git@github.com:hyperopt/hyperopt-sklearn.git (cd hyperopt-sklearn && pip install -e .) ## Usage If you are familiar with sklearn, adding the hyperparameter search with hyperopt-sklearn is only a one line change from the standard pipeline. ``` from hpsklearn import HyperoptEstimator, svc from sklearn import svm # Load Data # ... if use_hpsklearn: estim = HyperoptEstimator(classifier=svc('mySVC')) else: estim = svm.SVC() estim.fit(X_train, y_train) print(estim.score(X_test, y_test)) # <> ``` Complete example using the Iris dataset: ``` from hpsklearn import HyperoptEstimator, any_classifier from sklearn.datasets import load_iris from hyperopt import tpe import numpy as np # Download the data and split into training and test sets iris = load_iris() X = iris.data y = iris.target test_size = int(0.2 * len(y)) np.random.seed(13) indices = np.random.permutation(len(X)) X_train = X[ indices[:-test_size]] y_train = y[ indices[:-test_size]] X_test = X[ indices[-test_size:]] y_test = y[ indices[-test_size:]] # Instantiate a HyperoptEstimator with the search space and number of evaluations estim = HyperoptEstimator(classifier=any_classifier('my_clf'), preprocessing=any_preprocessing('my_pre'), algo=tpe.suggest, max_evals=100, trial_timeout=120) # Search the hyperparameter space based on the data estim.fit( X_train, y_train ) # Show the results print( estim.score( X_test, y_test ) ) # 1.0 print( estim.best_model() ) # {'learner': ExtraTreesClassifier(bootstrap=False, class_weight=None, criterion='gini', # max_depth=3, max_features='log2', max_leaf_nodes=None, # min_impurity_decrease=0.0, min_impurity_split=None, # min_samples_leaf=1, min_samples_split=2, # min_weight_fraction_leaf=0.0, n_estimators=13, n_jobs=1, # oob_score=False, random_state=1, verbose=False, # warm_start=False), 'preprocs': (), 'ex_preprocs': ()} ``` Here's an example using MNIST and being more specific on the classifier and preprocessing. ``` from hpsklearn import HyperoptEstimator, extra_trees from sklearn.datasets import fetch_mldata from hyperopt import tpe import numpy as np # Download the data and split into training and test sets digits = fetch_mldata('MNIST original') X = digits.data y = digits.target test_size = int(0.2 * len(y)) np.random.seed(13) indices = np.random.permutation(len(X)) X_train = X[ indices[:-test_size]] y_train = y[ indices[:-test_size]] X_test = X[ indices[-test_size:]] y_test = y[ indices[-test_size:]] # Instantiate a HyperoptEstimator with the search space and number of evaluations estim = HyperoptEstimator(classifier=extra_trees('my_clf'), preprocessing=[], algo=tpe.suggest, max_evals=10, trial_timeout=300) # Search the hyperparameter space based on the data estim.fit( X_train, y_train ) # Show the results print( estim.score( X_test, y_test ) ) # 0.962785714286 print( estim.best_model() ) # {'learner': ExtraTreesClassifier(bootstrap=True, class_weight=None, criterion='entropy', # max_depth=None, max_features=0.959202875857, # max_leaf_nodes=None, min_impurity_decrease=0.0, # min_impurity_split=None, min_samples_leaf=1, # min_samples_split=2, min_weight_fraction_leaf=0.0, # n_estimators=20, n_jobs=1, oob_score=False, random_state=3, # verbose=False, warm_start=False), 'preprocs': (), 'ex_preprocs': ()} ``` ## Available Components Not all of the classifiers/regressors/preprocessing from sklearn have been implemented yet. A list of those currently available is shown below. If there is something you would like that is not on the list, feel free to make an issue or a pull request! The source code for implementing these functions is found [here](https://github.com/hyperopt/hyperopt-sklearn/blob/master/hpsklearn/components.py) ### Classifiers ``` svc svc_linear svc_rbf svc_poly svc_sigmoid liblinear_svc knn ada_boost gradient_boosting random_forest extra_trees decision_tree sgd xgboost_classification multinomial_nb gaussian_nb passive_aggressive linear_discriminant_analysis quadratic_discriminant_analysis rbm colkmeans one_vs_rest one_vs_one output_code ``` For a simple generic search space across many classifiers, use `any_classifier`. If your data is in a sparse matrix format, use `any_sparse_classifier`. ### Regressors ``` svr svr_linear svr_rbf svr_poly svr_sigmoid knn_regression ada_boost_regression gradient_boosting_regression random_forest_regression extra_trees_regression sgd_regression xgboost_regression ``` For a simple generic search space across many regressors, use `any_regressor`. If your data is in a sparse matrix format, use `any_sparse_regressor`. ### Preprocessing ``` pca one_hot_encoder standard_scaler min_max_scaler normalizer ts_lagselector tfidf ``` For a simple generic search space across many preprocessing algorithms, use `any_preprocessing`. If you are working with raw text data, use `any_text_preprocessing`. Currently only TFIDF is used for text, but more may be added in the future. Note that the `preprocessing` parameter in `HyperoptEstimator` is expecting a list, since various preprocessing steps can be chained together. The generic search space functions `any_preprocessing` and `any_text_preprocessing` already return a list, but the others do not so they should be wrapped in a list. If you do not want to do any preprocessing, pass in an empty list `[]`. %package help Summary: Development documents and examples for hpsklearn Provides: python3-hpsklearn-doc %description help # hyperopt-sklearn [Hyperopt-sklearn](http://hyperopt.github.com/hyperopt-sklearn/) is [Hyperopt](http://hyperopt.github.com/hyperopt)-based model selection among machine learning algorithms in [scikit-learn](http://scikit-learn.org/). See how to use hyperopt-sklearn through [examples](http://hyperopt.github.io/hyperopt-sklearn/#documentation) or older [notebooks](http://nbviewer.ipython.org/github/hyperopt/hyperopt-sklearn/tree/master/notebooks) ## Installation Installation from a git clone using pip is supported: git clone git@github.com:hyperopt/hyperopt-sklearn.git (cd hyperopt-sklearn && pip install -e .) ## Usage If you are familiar with sklearn, adding the hyperparameter search with hyperopt-sklearn is only a one line change from the standard pipeline. ``` from hpsklearn import HyperoptEstimator, svc from sklearn import svm # Load Data # ... if use_hpsklearn: estim = HyperoptEstimator(classifier=svc('mySVC')) else: estim = svm.SVC() estim.fit(X_train, y_train) print(estim.score(X_test, y_test)) # <> ``` Complete example using the Iris dataset: ``` from hpsklearn import HyperoptEstimator, any_classifier from sklearn.datasets import load_iris from hyperopt import tpe import numpy as np # Download the data and split into training and test sets iris = load_iris() X = iris.data y = iris.target test_size = int(0.2 * len(y)) np.random.seed(13) indices = np.random.permutation(len(X)) X_train = X[ indices[:-test_size]] y_train = y[ indices[:-test_size]] X_test = X[ indices[-test_size:]] y_test = y[ indices[-test_size:]] # Instantiate a HyperoptEstimator with the search space and number of evaluations estim = HyperoptEstimator(classifier=any_classifier('my_clf'), preprocessing=any_preprocessing('my_pre'), algo=tpe.suggest, max_evals=100, trial_timeout=120) # Search the hyperparameter space based on the data estim.fit( X_train, y_train ) # Show the results print( estim.score( X_test, y_test ) ) # 1.0 print( estim.best_model() ) # {'learner': ExtraTreesClassifier(bootstrap=False, class_weight=None, criterion='gini', # max_depth=3, max_features='log2', max_leaf_nodes=None, # min_impurity_decrease=0.0, min_impurity_split=None, # min_samples_leaf=1, min_samples_split=2, # min_weight_fraction_leaf=0.0, n_estimators=13, n_jobs=1, # oob_score=False, random_state=1, verbose=False, # warm_start=False), 'preprocs': (), 'ex_preprocs': ()} ``` Here's an example using MNIST and being more specific on the classifier and preprocessing. ``` from hpsklearn import HyperoptEstimator, extra_trees from sklearn.datasets import fetch_mldata from hyperopt import tpe import numpy as np # Download the data and split into training and test sets digits = fetch_mldata('MNIST original') X = digits.data y = digits.target test_size = int(0.2 * len(y)) np.random.seed(13) indices = np.random.permutation(len(X)) X_train = X[ indices[:-test_size]] y_train = y[ indices[:-test_size]] X_test = X[ indices[-test_size:]] y_test = y[ indices[-test_size:]] # Instantiate a HyperoptEstimator with the search space and number of evaluations estim = HyperoptEstimator(classifier=extra_trees('my_clf'), preprocessing=[], algo=tpe.suggest, max_evals=10, trial_timeout=300) # Search the hyperparameter space based on the data estim.fit( X_train, y_train ) # Show the results print( estim.score( X_test, y_test ) ) # 0.962785714286 print( estim.best_model() ) # {'learner': ExtraTreesClassifier(bootstrap=True, class_weight=None, criterion='entropy', # max_depth=None, max_features=0.959202875857, # max_leaf_nodes=None, min_impurity_decrease=0.0, # min_impurity_split=None, min_samples_leaf=1, # min_samples_split=2, min_weight_fraction_leaf=0.0, # n_estimators=20, n_jobs=1, oob_score=False, random_state=3, # verbose=False, warm_start=False), 'preprocs': (), 'ex_preprocs': ()} ``` ## Available Components Not all of the classifiers/regressors/preprocessing from sklearn have been implemented yet. A list of those currently available is shown below. If there is something you would like that is not on the list, feel free to make an issue or a pull request! The source code for implementing these functions is found [here](https://github.com/hyperopt/hyperopt-sklearn/blob/master/hpsklearn/components.py) ### Classifiers ``` svc svc_linear svc_rbf svc_poly svc_sigmoid liblinear_svc knn ada_boost gradient_boosting random_forest extra_trees decision_tree sgd xgboost_classification multinomial_nb gaussian_nb passive_aggressive linear_discriminant_analysis quadratic_discriminant_analysis rbm colkmeans one_vs_rest one_vs_one output_code ``` For a simple generic search space across many classifiers, use `any_classifier`. If your data is in a sparse matrix format, use `any_sparse_classifier`. ### Regressors ``` svr svr_linear svr_rbf svr_poly svr_sigmoid knn_regression ada_boost_regression gradient_boosting_regression random_forest_regression extra_trees_regression sgd_regression xgboost_regression ``` For a simple generic search space across many regressors, use `any_regressor`. If your data is in a sparse matrix format, use `any_sparse_regressor`. ### Preprocessing ``` pca one_hot_encoder standard_scaler min_max_scaler normalizer ts_lagselector tfidf ``` For a simple generic search space across many preprocessing algorithms, use `any_preprocessing`. If you are working with raw text data, use `any_text_preprocessing`. Currently only TFIDF is used for text, but more may be added in the future. Note that the `preprocessing` parameter in `HyperoptEstimator` is expecting a list, since various preprocessing steps can be chained together. The generic search space functions `any_preprocessing` and `any_text_preprocessing` already return a list, but the others do not so they should be wrapped in a list. If you do not want to do any preprocessing, pass in an empty list `[]`. %prep %autosetup -n hpsklearn-0.1.0 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-hpsklearn -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Wed Apr 12 2023 Python_Bot - 0.1.0-1 - Package Spec generated