Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more of the sklearn regressors to the presets #27

Merged
merged 6 commits into from
Jun 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 88 additions & 14 deletions xcessiv/presets/learnersetting.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,44 @@
from __future__ import absolute_import, print_function, division, unicode_literals
from xcessiv.presets import learnersource


__all__ = [
'sklearn_random_forest',
'sklearn_extra_trees',

# Classifiers
'sklearn_random_forest_classifier',
'sklearn_extra_trees_classifier',
'sklearn_logistic_regression',
'sklearn_knn_classifier',
'sklearn_svm_classifier',
'sklearn_gaussian_nb',
'sklearn_adaboost_classifier',
'xgboost_classifier',
'xgboost_regressor',

# Regressors
'sklearn_random_forest_regressor',
'sklearn_extra_trees_regressor',
'sklearn_bagging_regressor',
'sklearn_GP_regressor',
'sklearn_ridge_regressor',
'sklearn_lasso_regressor',
'sklearn_kernel_ridge_regressor',
'sklearn_knn_regressor',
'sklearn_svr_regressor',
'sklearn_decision_tree_regressor',
'sklearn_linear_regression',
'sklearn_adaboost_regressor'
'sklearn_adaboost_regressor',
'xgboost_regressor'
]


sklearn_random_forest = {
'name': 'scikit-learn Random Forest',
'source': learnersource.sklearn_random_forest_source,
# Classifiers
sklearn_random_forest_classifier = {
'name': 'scikit-learn Random Forest Classifier',
'source': learnersource.sklearn_random_forest_classifier_source,
'meta_feature_generator': 'predict_proba'
}

sklearn_extra_trees = {
sklearn_extra_trees_classifier = {
'name': 'scikit-learn Extra Trees Classifier',
'source': learnersource.sklearn_extra_trees_source,
'source': learnersource.sklearn_extra_trees_classifier_source,
'meta_feature_generator': 'predict_proba'
}

Expand Down Expand Up @@ -66,9 +79,64 @@
'meta_feature_generator': 'predict_proba'
}

xgboost_regressor = {
'name': 'XGBoost Regressor',
'source': learnersource.xgboost_regressor_source,
# Regressors
sklearn_random_forest_regressor = {
'name': 'scikit-learn Random Forest Regressor',
'source': learnersource.sklearn_random_forest_regressor_source,
'meta_feature_generator': 'predict'
}

sklearn_extra_trees_regressor = {
'name': 'scikit-learn Extra Trees Regressor',
'source': learnersource.sklearn_extra_trees_regressor_source,
'meta_feature_generator': 'predict'
}

sklearn_bagging_regressor = {
'name': 'scikit-learn Bagging Regressor',
'source': learnersource.sklearn_bagging_regressor_source,
'meta_feature_generator': 'predict'
}

sklearn_GP_regressor = {
'name': 'scikit-learn Gaussian Process Regressor',
'source': learnersource.sklearn_GP_regressor_source,
'meta_feature_generator': 'predict'
}

sklearn_ridge_regressor = {
'name': 'scikit-learn Ridge Regressor',
'source': learnersource.sklearn_ridge_regressor_source,
'meta_feature_generator': 'predict'
}

sklearn_lasso_regressor = {
'name': 'scikit-learn Lasso Regressor',
'source': learnersource.sklearn_lasso_regressor_source,
'meta_feature_generator': 'predict'
}

sklearn_kernel_ridge_regressor = {
'name': 'scikit-learn Kernel Ridge Regressor',
'source': learnersource.sklearn_kernel_ridge_regressor_source,
'meta_feature_generator': 'predict'
}

sklearn_knn_regressor = {
'name': 'scikit-learn K-NN Regressor',
'source': learnersource.sklearn_knn_regressor_source,
'meta_feature_generator': 'predict'
}

sklearn_svr_regressor = {
'name': 'scikit-learn Support Vector Regressor',
'source': learnersource.sklearn_svr_regressor_source,
'meta_feature_generator': 'predict'
}

sklearn_decision_tree_regressor = {
'name': 'scikit-learn Decision Tree Regressor',
'source': learnersource.sklearn_decision_tree_regressor_source,
'meta_feature_generator': 'predict'
}

Expand All @@ -83,3 +151,9 @@
'source': learnersource.sklearn_adaboost_regressor_source,
'meta_feature_generator': 'predict'
}

xgboost_regressor = {
'name': 'XGBoost Regressor',
'source': learnersource.xgboost_regressor_source,
'meta_feature_generator': 'predict'
}
99 changes: 92 additions & 7 deletions xcessiv/presets/learnersource.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
"""This module contains preset source codes for base learners"""
from __future__ import absolute_import, print_function, division, unicode_literals
___all__ = [
'sklearn_random_forest_source'

__all__ = [

# Classifiers
'sklearn_random_forest_classifier_source',
'sklearn_extra_trees_classifier_source',
'sklearn_logistic_regression_source',
'sklearn_knn_classifier_source',
'sklearn_svm_classifier_source',
'sklearn_gaussian_nb_source',
'sklearn_adaboost_classifier_source',
'xgboost_classifier_source',

# Regressors
'sklearn_random_forest_regressor_source',
'sklearn_extra_trees_regressor_source',
'sklearn_bagging_regressor_source',
'sklearn_GP_regressor_source',
'sklearn_ridge_regressor_source',
'sklearn_lasso_regressor_source',
'sklearn_kernel_ridge_regressor_source',
'sklearn_knn_regressor_source',
'sklearn_svr_regressor_source',
'sklearn_decision_tree_regressor_source',
'sklearn_linear_regression_source',
'sklearn_adaboost_regressor_source',
'xgboost_regressor_source'
]

sklearn_random_forest_source = \
sklearn_random_forest_classifier_source = \
"""from sklearn.ensemble import RandomForestClassifier

base_learner = RandomForestClassifier(random_state=8)
"""

sklearn_extra_trees_source = \
sklearn_extra_trees_classifier_source = \
"""from sklearn.ensemble import ExtraTreesClassifier

base_learner = ExtraTreesClassifier(random_state=8)
Expand Down Expand Up @@ -52,10 +77,64 @@
base_learner = XGBClassifier(seed=8)
"""

xgboost_regressor_source = \
"""from xgboost import XGBRegressor
sklearn_random_forest_regressor_source = \
"""from sklearn.ensemble import RandomForestRegressor

base_learner = XGBRegressor(seed=8)
base_learner = RandomForestRegressor(random_state=8)
"""

sklearn_extra_trees_regressor_source = \
"""from sklearn.ensemble import ExtraTreesRegressor

base_learner = ExtraTreesRegressor(random_state=8)
"""

sklearn_bagging_regressor_source = \
"""from sklearn.ensemble import BaggingRegressor

base_learner = BaggingRegressor(random_state=8)
"""

sklearn_GP_regressor_source = \
"""from sklearn.gaussian_process import GaussianProcessRegressor

base_learner = GaussianProcessRegressor(random_state=8)
"""

sklearn_ridge_regressor_source = \
"""from sklearn.linear_model import Ridge

base_learner = Ridge(random_state=8)
"""

sklearn_lasso_regressor_source = \
"""from sklearn.linear_model import Lasso

base_learner = Lasso(random_state=8)
"""

sklearn_kernel_ridge_regressor_source = \
"""from sklearn.kernel_ridge import KernelRidge

base_learner = KernelRidge()
"""

sklearn_knn_regressor_source = \
"""from sklearn.neighbors import KNeighborsRegressor

base_learner = KNeighborsRegressor()
"""

sklearn_svr_regressor_source = \
"""from sklearn.svm import SVR

base_learner = SVR()
"""

sklearn_decision_tree_regressor_source = \
"""from sklearn.tree import DecisionTreeRegressor

base_learner = DecisionTreeRegressor(random_state=8)
"""

sklearn_linear_regression_source = \
Expand All @@ -69,3 +148,9 @@

base_learner = AdaBoostRegressor(random_state=8)
"""

xgboost_regressor_source = \
"""from xgboost import XGBRegressor

base_learner = XGBRegressor(seed=8)
"""