unifiedbooster 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- unifiedbooster/__init__.py +4 -0
- unifiedbooster/gbdt_classification.py +80 -0
- unifiedbooster/gbdt_regression.py +77 -0
- unifiedbooster-0.1.0.dist-info/METADATA +25 -0
- unifiedbooster-0.1.0.dist-info/RECORD +8 -0
- unifiedbooster-0.1.0.dist-info/WHEEL +5 -0
- unifiedbooster-0.1.0.dist-info/entry_points.txt +2 -0
- unifiedbooster-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from sklearn.base import BaseEstimator, ClassifierMixin
|
|
2
|
+
from xgboost import XGBClassifier
|
|
3
|
+
from catboost import CatBoostClassifier
|
|
4
|
+
from lightgbm import LGBMClassifier
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class GBDTClassifier(BaseEstimator, ClassifierMixin):
|
|
8
|
+
def __init__(self, model_type='xgboost',
|
|
9
|
+
n_estimators=100,
|
|
10
|
+
learning_rate=0.1,
|
|
11
|
+
max_depth=3,
|
|
12
|
+
subsample=1.0,
|
|
13
|
+
verbosity=0,
|
|
14
|
+
**kwargs):
|
|
15
|
+
self.model_type = model_type
|
|
16
|
+
self.n_estimators = n_estimators
|
|
17
|
+
self.learning_rate = learning_rate
|
|
18
|
+
self.max_depth = max_depth
|
|
19
|
+
self.subsample = subsample
|
|
20
|
+
self.verbosity = verbosity
|
|
21
|
+
# xgboost -----
|
|
22
|
+
# n_estimators
|
|
23
|
+
# learning_rate
|
|
24
|
+
# subsample
|
|
25
|
+
# max_depth
|
|
26
|
+
# lightgbm -----
|
|
27
|
+
# num_iterations
|
|
28
|
+
# learning_rate
|
|
29
|
+
# bagging_fraction
|
|
30
|
+
# max_depth
|
|
31
|
+
# catboost -----
|
|
32
|
+
# iterations
|
|
33
|
+
# learning_rate
|
|
34
|
+
# rsm
|
|
35
|
+
# depth
|
|
36
|
+
if self.model_type == "xgboost":
|
|
37
|
+
self.params = {
|
|
38
|
+
'n_estimators': self.n_estimators,
|
|
39
|
+
'learning_rate': self.learning_rate,
|
|
40
|
+
'subsample': self.subsample,
|
|
41
|
+
'max_depth': self.max_depth,
|
|
42
|
+
'verbosity': self.verbosity,
|
|
43
|
+
**kwargs
|
|
44
|
+
}
|
|
45
|
+
elif self.model_type == "lightgbm":
|
|
46
|
+
self.params = {
|
|
47
|
+
'num_iterations': self.n_estimators,
|
|
48
|
+
'learning_rate': self.learning_rate,
|
|
49
|
+
'bagging_fraction': self.subsample,
|
|
50
|
+
'max_depth': self.max_depth,
|
|
51
|
+
'verbose': self.verbosity - 1 if self.verbosity==0 else self.verbosity
|
|
52
|
+
**kwargs
|
|
53
|
+
}
|
|
54
|
+
elif self.model_type == "catboost":
|
|
55
|
+
self.params = {
|
|
56
|
+
'iterations': self.n_estimators,
|
|
57
|
+
'learning_rate': self.learning_rate,
|
|
58
|
+
'rsm': self.subsample,
|
|
59
|
+
'depth': self.max_depth,
|
|
60
|
+
'verbose': self.verbosity
|
|
61
|
+
**kwargs
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if model_type == 'xgboost':
|
|
65
|
+
self.model = XGBClassifier(**self.params)
|
|
66
|
+
elif model_type == 'catboost':
|
|
67
|
+
self.model = CatBoostClassifier(**self.params, logging_level='Silent')
|
|
68
|
+
elif model_type == 'lightgbm':
|
|
69
|
+
self.model = LGBMClassifier(**self.params)
|
|
70
|
+
else:
|
|
71
|
+
raise ValueError(f"Unknown model_type: {model_type}")
|
|
72
|
+
|
|
73
|
+
def fit(self, X, y, **kwargs):
|
|
74
|
+
return self.model.fit(X, y, **kwargs)
|
|
75
|
+
|
|
76
|
+
def predict(self, X):
|
|
77
|
+
return self.model.predict(X)
|
|
78
|
+
|
|
79
|
+
def predict_proba(self, X):
|
|
80
|
+
return self.model.predict_proba(X)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
from sklearn.base import BaseEstimator, RegressorMixin
|
|
2
|
+
from xgboost import XGBRegressor
|
|
3
|
+
from catboost import CatBoostRegressor
|
|
4
|
+
from lightgbm import LGBMRegressor
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class GBDTRegressor(BaseEstimator, RegressorMixin):
|
|
8
|
+
def __init__(self, model_type='xgboost',
|
|
9
|
+
n_estimators=100,
|
|
10
|
+
learning_rate=0.1,
|
|
11
|
+
max_depth=3,
|
|
12
|
+
subsample=1.0,
|
|
13
|
+
verbosity=0,
|
|
14
|
+
**kwargs):
|
|
15
|
+
self.model_type = model_type
|
|
16
|
+
self.n_estimators = n_estimators
|
|
17
|
+
self.learning_rate = learning_rate
|
|
18
|
+
self.max_depth = max_depth
|
|
19
|
+
self.subsample = subsample
|
|
20
|
+
self.verbosity = verbosity
|
|
21
|
+
# xgboost -----
|
|
22
|
+
# n_estimators
|
|
23
|
+
# learning_rate
|
|
24
|
+
# subsample
|
|
25
|
+
# max_depth
|
|
26
|
+
# lightgbm -----
|
|
27
|
+
# num_iterations
|
|
28
|
+
# learning_rate
|
|
29
|
+
# bagging_fraction
|
|
30
|
+
# max_depth
|
|
31
|
+
# catboost -----
|
|
32
|
+
# iterations
|
|
33
|
+
# learning_rate
|
|
34
|
+
# rsm
|
|
35
|
+
# depth
|
|
36
|
+
if self.model_type == "xgboost":
|
|
37
|
+
self.params = {
|
|
38
|
+
'n_estimators': self.n_estimators,
|
|
39
|
+
'learning_rate': self.learning_rate,
|
|
40
|
+
'subsample': self.subsample,
|
|
41
|
+
'max_depth': self.max_depth,
|
|
42
|
+
'verbosity': self.verbosity,
|
|
43
|
+
**kwargs
|
|
44
|
+
}
|
|
45
|
+
elif self.model_type == "lightgbm":
|
|
46
|
+
self.params = {
|
|
47
|
+
'num_iterations': self.n_estimators,
|
|
48
|
+
'learning_rate': self.learning_rate,
|
|
49
|
+
'bagging_fraction': self.subsample,
|
|
50
|
+
'max_depth': self.max_depth,
|
|
51
|
+
'verbose': self.verbosity - 1 if self.verbosity==0 else self.verbosity
|
|
52
|
+
**kwargs
|
|
53
|
+
}
|
|
54
|
+
elif self.model_type == "catboost":
|
|
55
|
+
self.params = {
|
|
56
|
+
'iterations': self.n_estimators,
|
|
57
|
+
'learning_rate': self.learning_rate,
|
|
58
|
+
'rsm': self.subsample,
|
|
59
|
+
'depth': self.max_depth,
|
|
60
|
+
'verbose': self.verbosity
|
|
61
|
+
**kwargs
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if model_type == 'xgboost':
|
|
65
|
+
self.model = XGBRegressor(**self.params)
|
|
66
|
+
elif model_type == 'catboost':
|
|
67
|
+
self.model = CatBoostRegressor(**self.params, logging_level='Silent')
|
|
68
|
+
elif model_type == 'lightgbm':
|
|
69
|
+
self.model = LGBMRegressor(**self.params)
|
|
70
|
+
else:
|
|
71
|
+
raise ValueError(f"Unknown model_type: {model_type}")
|
|
72
|
+
|
|
73
|
+
def fit(self, X, y, **kwargs):
|
|
74
|
+
return self.model.fit(X, y, **kwargs)
|
|
75
|
+
|
|
76
|
+
def predict(self, X):
|
|
77
|
+
return self.model.predict(X)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: unifiedbooster
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Call R functions from Python
|
|
5
|
+
Home-page: https://github.com/thierrymoudiki/unifiedbooster
|
|
6
|
+
Author: T. Moudiki
|
|
7
|
+
Author-email: thierry.moudiki@gmail.com
|
|
8
|
+
License: BSD license
|
|
9
|
+
Keywords: unifiedbooster
|
|
10
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Requires-Python: >=3.6
|
|
19
|
+
Requires-Dist: Cython
|
|
20
|
+
Requires-Dist: scikit-learn
|
|
21
|
+
Requires-Dist: xgboost
|
|
22
|
+
Requires-Dist: lightgbm
|
|
23
|
+
Requires-Dist: catboost
|
|
24
|
+
|
|
25
|
+
Unified interface for Gradient Boosted Decision Trees
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
unifiedbooster/__init__.py,sha256=urmH2DAkJ4e-idIh0oMZX9lP9rlqTPyZ-qHuNeJcEIc,137
|
|
2
|
+
unifiedbooster/gbdt_classification.py,sha256=4KIPuPGdXpQvppgklkS_7tB180WTAuxZKHC8ulCJjQs,2784
|
|
3
|
+
unifiedbooster/gbdt_regression.py,sha256=BrM51nKDkd9mU3TnmRqT4QLaQLfrQ_inQEIJvmhj1PQ,2719
|
|
4
|
+
unifiedbooster-0.1.0.dist-info/METADATA,sha256=8ATMu6Xyb5ab8B0Og5nlakWnZ0kGu6OitZiDG23QuXc,841
|
|
5
|
+
unifiedbooster-0.1.0.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
|
6
|
+
unifiedbooster-0.1.0.dist-info/entry_points.txt,sha256=OVNTsCzMYnaJ11WIByB7G8Lym_dj-ERKZyQxWFUcW30,59
|
|
7
|
+
unifiedbooster-0.1.0.dist-info/top_level.txt,sha256=gOMxxpRtx8_nJXTWsXJDFkNeCsjSJQPs6aUXKK5_nI4,15
|
|
8
|
+
unifiedbooster-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
unifiedbooster
|