unifiedbooster 0.1.0__tar.gz
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-0.1.0/PKG-INFO +25 -0
- unifiedbooster-0.1.0/README.md +1 -0
- unifiedbooster-0.1.0/setup.cfg +4 -0
- unifiedbooster-0.1.0/setup.py +64 -0
- unifiedbooster-0.1.0/unifiedbooster/__init__.py +4 -0
- unifiedbooster-0.1.0/unifiedbooster/gbdt_classification.py +80 -0
- unifiedbooster-0.1.0/unifiedbooster/gbdt_regression.py +77 -0
- unifiedbooster-0.1.0/unifiedbooster.egg-info/PKG-INFO +25 -0
- unifiedbooster-0.1.0/unifiedbooster.egg-info/SOURCES.txt +12 -0
- unifiedbooster-0.1.0/unifiedbooster.egg-info/dependency_links.txt +1 -0
- unifiedbooster-0.1.0/unifiedbooster.egg-info/entry_points.txt +2 -0
- unifiedbooster-0.1.0/unifiedbooster.egg-info/not-zip-safe +1 -0
- unifiedbooster-0.1.0/unifiedbooster.egg-info/requires.txt +5 -0
- unifiedbooster-0.1.0/unifiedbooster.egg-info/top_level.txt +1 -0
|
@@ -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 @@
|
|
|
1
|
+
# unifiedbooster
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
"""The setup script."""
|
|
4
|
+
|
|
5
|
+
import platform
|
|
6
|
+
import subprocess
|
|
7
|
+
from setuptools import setup, find_packages
|
|
8
|
+
from codecs import open
|
|
9
|
+
from os import path
|
|
10
|
+
|
|
11
|
+
subprocess.check_call(['pip', 'install', 'Cython'])
|
|
12
|
+
|
|
13
|
+
__version__ = "0.1.0"
|
|
14
|
+
|
|
15
|
+
here = path.abspath(path.dirname(__file__))
|
|
16
|
+
|
|
17
|
+
# get the dependencies and installs
|
|
18
|
+
|
|
19
|
+
with open(
|
|
20
|
+
path.join(here, "requirements.txt"), encoding="utf-8"
|
|
21
|
+
) as f:
|
|
22
|
+
all_reqs = f.read().split("\n")
|
|
23
|
+
|
|
24
|
+
install_requires = [
|
|
25
|
+
x.strip() for x in all_reqs if "git+" not in x
|
|
26
|
+
]
|
|
27
|
+
dependency_links = [
|
|
28
|
+
x.strip().replace("git+", "")
|
|
29
|
+
for x in all_reqs
|
|
30
|
+
if x.startswith("git+")
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
setup(
|
|
34
|
+
author="T. Moudiki",
|
|
35
|
+
author_email='thierry.moudiki@gmail.com',
|
|
36
|
+
python_requires='>=3.6',
|
|
37
|
+
classifiers=[
|
|
38
|
+
'Development Status :: 2 - Pre-Alpha',
|
|
39
|
+
'Intended Audience :: Developers',
|
|
40
|
+
'License :: OSI Approved :: BSD License',
|
|
41
|
+
'Natural Language :: English',
|
|
42
|
+
'Programming Language :: Python :: 3',
|
|
43
|
+
'Programming Language :: Python :: 3.6',
|
|
44
|
+
'Programming Language :: Python :: 3.7',
|
|
45
|
+
'Programming Language :: Python :: 3.8',
|
|
46
|
+
],
|
|
47
|
+
description="Call R functions from Python",
|
|
48
|
+
entry_points={
|
|
49
|
+
'console_scripts': [
|
|
50
|
+
'unifiedbooster=unifiedbooster.cli:main',
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
install_requires=install_requires,
|
|
54
|
+
license="BSD license",
|
|
55
|
+
long_description="Unified interface for Gradient Boosted Decision Trees",
|
|
56
|
+
include_package_data=True,
|
|
57
|
+
keywords='unifiedbooster',
|
|
58
|
+
name='unifiedbooster',
|
|
59
|
+
packages=find_packages(include=['unifiedbooster', 'unifiedbooster.*']),
|
|
60
|
+
test_suite='tests',
|
|
61
|
+
url='https://github.com/thierrymoudiki/unifiedbooster',
|
|
62
|
+
version=__version__,
|
|
63
|
+
zip_safe=False,
|
|
64
|
+
)
|
|
@@ -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,12 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
setup.py
|
|
3
|
+
unifiedbooster/__init__.py
|
|
4
|
+
unifiedbooster/gbdt_classification.py
|
|
5
|
+
unifiedbooster/gbdt_regression.py
|
|
6
|
+
unifiedbooster.egg-info/PKG-INFO
|
|
7
|
+
unifiedbooster.egg-info/SOURCES.txt
|
|
8
|
+
unifiedbooster.egg-info/dependency_links.txt
|
|
9
|
+
unifiedbooster.egg-info/entry_points.txt
|
|
10
|
+
unifiedbooster.egg-info/not-zip-safe
|
|
11
|
+
unifiedbooster.egg-info/requires.txt
|
|
12
|
+
unifiedbooster.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
unifiedbooster
|