Skip to content

Commit

Permalink
add cross val. and lazy cross val. Pt.4
Browse files Browse the repository at this point in the history
  • Loading branch information
thierrymoudiki committed Aug 4, 2024
1 parent 7bb241c commit c4a8baa
Show file tree
Hide file tree
Showing 8 changed files with 293 additions and 206 deletions.
2 changes: 1 addition & 1 deletion examples/cross_val.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sklearn.metrics import accuracy_score
from time import time

print(f"\n ----- Running: {os.path.basename(__file__)}... ----- \n")
print(f"\n ----- Running: {os.path.basename(__file__)}... ----- \n")

dataset = load_breast_cancer()
X, y = dataset.data, dataset.target
Expand Down
30 changes: 27 additions & 3 deletions examples/lazy_cross_val.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,34 @@

print(f"\n ----- Running: {os.path.basename(__file__)}... ----- \n")

dataset = load_iris()
dataset = load_breast_cancer()
X, y = dataset.data, dataset.target
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=42
)

res3 = ub.lazy_cross_val_optim(
# start = time()
# res3 = ub.lazy_cross_val_optim(
# X_train,
# y_train,
# X_test=X_test,
# y_test=y_test,
# model_type="lightgbm",
# type_fit="classification",
# scoring="accuracy",
# n_estimators=100,
# cv=5,
# n_jobs=None,
# n_init=10,
# n_iter=190,
# abs_tol=1e-3,
# seed=123,
# customize=True
# )
# print(f"Elapsed: {time()-start}")

start = time()
res4 = ub.lazy_cross_val_optim(
X_train,
y_train,
X_test=X_test,
Expand All @@ -30,5 +51,8 @@
n_iter=190,
abs_tol=1e-3,
seed=123,
customize=False
)
print(res3)
print(f"Elapsed: {time()-start}")
#print(res3)
print(res4)
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ scikit-learn
xgboost
lightgbm
catboost
GPopt
GPopt
nnetsauce
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

subprocess.check_call(['pip', 'install', 'Cython'])

__version__ = "0.4.1"
__version__ = "0.4.2"

here = path.abspath(path.dirname(__file__))

Expand Down
9 changes: 7 additions & 2 deletions unifiedbooster/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
from .gbdt_regression import GBDTRegressor
from .gpoptimization import cross_val_optim, lazy_cross_val_optim

__all__ = ["GBDT", "GBDTClassifier", "GBDTRegressor",
"cross_val_optim", "lazy_cross_val_optim"]
__all__ = [
"GBDT",
"GBDTClassifier",
"GBDTRegressor",
"cross_val_optim",
"lazy_cross_val_optim",
]
9 changes: 5 additions & 4 deletions unifiedbooster/gbdt_classification.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
from .gbdt import GBDT
from sklearn.base import ClassifierMixin

try:
from xgboost import XGBClassifier
except:
pass
except:
pass
try:
from catboost import CatBoostClassifier
except:
pass
try:
try:
from lightgbm import LGBMClassifier
except:
pass
pass
from sklearn.ensemble import GradientBoostingClassifier


Expand Down
11 changes: 6 additions & 5 deletions unifiedbooster/gbdt_regression.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
from .gbdt import GBDT
from sklearn.base import RegressorMixin
try:

try:
from xgboost import XGBRegressor
except:
pass
pass
try:
from catboost import CatBoostRegressor
except:
pass
try:
pass
try:
from lightgbm import LGBMRegressor
except:
pass
pass
from sklearn.ensemble import GradientBoostingRegressor


Expand Down
Loading

0 comments on commit c4a8baa

Please sign in to comment.