Skip to content
Open
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
4 changes: 2 additions & 2 deletions optimization/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

plt.style.use('dark_background')


class Optimizer:
def __init__(self, model, featureset, target, validator, goal='maximize', search_spaces=None):
if isinstance(search_spaces, type(None)):
Expand Down Expand Up @@ -45,8 +46,7 @@ def plot_objective(self):
models=self.opt.models)
plot_objective(res, dimensions=self.parameter_names);
plt.show()



def plot_evaluations(self):
res = create_result(Xi=self.opt.Xi,
yi=self.opt.yi,
Expand Down
28 changes: 22 additions & 6 deletions zoo/binary_classification.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from ..model import *
from .. import config

from xgboost import XGBClassifier as _XGBC
from lightgbm import LGBMClassifier as _LGBMC
from catboost import CatBoostClassifier as _CBC
from sklearn.linear_model import LogisticRegression as _LOGR
from sklearn.neighbors import KNeighborsClassifier as _KNC


class XGBClassifier(Model):
Estimator = _XGBC
search_spaces = {
Expand Down Expand Up @@ -38,8 +43,8 @@ def _fit(self, X, y, **kwargs):

def predict(self, X):
return self.estimator.predict_proba(X)[:, 1]
from lightgbm import LGBMClassifier as _LGBMC


class LGBMClassifier(Model):
Estimator = _LGBMC
search_spaces = {
Expand All @@ -58,8 +63,8 @@ class LGBMClassifier(Model):

def predict(self, X):
return self.estimator.predict_proba(X)[:, 1]
from catboost import CatBoostClassifier as _CBC


class CBClassifier(Model):
Estimator = _CBC
short_name = 'cb'
Expand All @@ -75,7 +80,7 @@ def _fit(self, X, y, **kwargs):
def predict(self, X):
return self.estimator.predict_proba(X)[:, 1]

from sklearn.linear_model import LogisticRegression as _LOGR

class LogisticRegression(Model):
Estimator = _LOGR
short_name = 'logr'
Expand All @@ -97,3 +102,14 @@ class LogisticRegression(Model):

def predict(self, X):
return self.estimator.predict_proba(X)[:, 1]


class KNeighborsClassifier(Model):
Estimator = _KNC
system_params = {
"n_jobs": -1,
}
short_name = 'knc'

def predict(self, X):
return self.estimator.predict_proba(X)[:, 1]
46 changes: 14 additions & 32 deletions zoo/classification.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
from ..model import *
from .. import config

from xgboost import XGBClassifier as _XGBC
from sklearn.neighbors import KNeighborsClassifier as _KNC


class XGBClassifier(Model):
Estimator = _XGBC
default_params = {
"max_depth": 3,
"learning_rate": 0.1,
"n_estimators": 100,
"booster": 'gbtree',
"gamma": 0,
"min_child_weight": 1,
"max_delta_step": 0,
"subsample": 1,
"colsample_bytree": 1,
"colsample_bylevel": 1,
"reg_alpha": 0,
"reg_lambda": 1,
"scale_pos_weight": 1,
"base_score": 0.5,
}
search_spaces = {
'max_depth': (0, 50),
'learning_rate': (0.01, 1.0, 'log-uniform'),
Expand All @@ -39,24 +25,20 @@ class XGBClassifier(Model):
system_params = {
"objective": 'binary:logistic',
"silent": True,
"n_jobs": 1,
"n_jobs": -1,
"random_state": 0,
"seed": config.seed
}
short_name = 'xgb'


from lightgbm import LGBMClassifier as _LGBMC
class LGBMClassifier(Model):
Estimator = _LGBMC
short_name = 'lgb'


from catboost import CatBoostClassifier as _CBC
class CBClassifier(Model):
Estimator = _CBC
short_name = 'cb'



class KNeighborsClassifier(Model):
Estimator = _KNC
system_params = {
"n_jobs": -1,
}
short_name = 'knc'

def predict(self, X):
return self.estimator.predict_proba(X)