unifiedbooster 0.7.0__py3-none-any.whl → 0.10.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/gbdt.py CHANGED
@@ -35,6 +35,7 @@ class GBDT(BaseEstimator):
35
35
  **kwargs: dict
36
36
  additional parameters to be passed to the class
37
37
  """
38
+
38
39
  def __init__(
39
40
  self,
40
41
  model_type="xgboost",
@@ -40,10 +40,10 @@ class GBDTClassifier(GBDT, ClassifierMixin):
40
40
 
41
41
  colsample: float
42
42
  percentage of features to use at each node split
43
-
43
+
44
44
  level: float
45
45
  confidence level for prediction sets
46
-
46
+
47
47
  pi_method: str
48
48
  method for constructing the prediction intervals: 'icp' (inductive conformal), 'tcp' (transductive conformal)
49
49
 
@@ -95,6 +95,7 @@ class GBDTClassifier(GBDT, ClassifierMixin):
95
95
  print(f"Classification Accuracy lightgbm: {accuracy3:.2f}")
96
96
  ```
97
97
  """
98
+
98
99
  def __init__(
99
100
  self,
100
101
  model_type="xgboost",
@@ -128,34 +129,66 @@ class GBDTClassifier(GBDT, ClassifierMixin):
128
129
 
129
130
  if self.level is not None:
130
131
 
131
- if model_type == "xgboost":
132
- self.model = PredictionSet(XGBClassifier(**self.params),
133
- level=self.level,
134
- method=self.pi_method)
132
+ if model_type in ("xgboost", "xgb"):
133
+ self.model = PredictionSet(
134
+ XGBClassifier(**self.params),
135
+ level=self.level,
136
+ method=self.pi_method,
137
+ )
135
138
  elif model_type == "catboost":
136
- self.model = PredictionSet(CatBoostClassifier(**self.params),
137
- level=self.level,
138
- method=self.pi_method)
139
- elif model_type == "lightgbm":
140
- self.model = PredictionSet(LGBMClassifier(**self.params),
141
- level=self.level,
142
- method=self.pi_method)
143
- elif model_type == "gradientboosting":
144
- self.model = PredictionSet(GradientBoostingClassifier(**self.params),
145
- level=self.level,
146
- method=self.pi_method)
139
+
140
+ fast_cb = dict(
141
+ thread_count=-1,
142
+ boosting_type="Plain",
143
+ grow_policy="Depthwise",
144
+ bootstrap_type="Bernoulli",
145
+ subsample=0.8,
146
+ verbose=False
147
+ )
148
+
149
+ self.model = PredictionSet(
150
+ CatBoostClassifier(**self.params, **fast_cb),
151
+ level=self.level,
152
+ method=self.pi_method,
153
+ )
154
+ elif model_type in ("lightgbm", "lgb"):
155
+ self.model = PredictionSet(
156
+ LGBMClassifier(**self.params),
157
+ level=self.level,
158
+ method=self.pi_method,
159
+ )
160
+ elif model_type in ("gradientboosting", "gb"):
161
+ self.model = PredictionSet(
162
+ GradientBoostingClassifier(**self.params),
163
+ level=self.level,
164
+ method=self.pi_method,
165
+ )
147
166
  else:
148
167
  raise ValueError(f"Unknown model_type: {model_type}")
149
-
168
+
150
169
  else:
151
170
 
152
- if model_type == "xgboost":
171
+ if model_type in ("xgboost", "xgb"):
153
172
  self.model = XGBClassifier(**self.params)
173
+ <<<<<<< HEAD
154
174
  elif model_type == "catboost":
155
- self.model = CatBoostClassifier(**self.params)
175
+ fast_cb = dict(
176
+ thread_count=-1,
177
+ boosting_type="Plain",
178
+ grow_policy="Depthwise",
179
+ bootstrap_type="Bernoulli",
180
+ subsample=0.8,
181
+ verbose=False
182
+ )
183
+ self.model = CatBoostClassifier(**self.params, **fast_cb)
156
184
  elif model_type == "lightgbm":
185
+ =======
186
+ elif model_type in ("catboost", "cb"):
187
+ self.model = CatBoostClassifier(**self.params)
188
+ elif model_type in ("lightgbm", "lgb"):
189
+ >>>>>>> 0c97427b8cbd66d509a3cc24747eeea8b157779d
157
190
  self.model = LGBMClassifier(**self.params)
158
- elif model_type == "gradientboosting":
191
+ elif model_type in ("gradientboosting", "gb"):
159
192
  self.model = GradientBoostingClassifier(**self.params)
160
193
  else:
161
194
  raise ValueError(f"Unknown model_type: {model_type}")
@@ -40,12 +40,16 @@ class GBDTRegressor(GBDT, RegressorMixin):
40
40
 
41
41
  colsample: float
42
42
  percentage of features to use at each node split
43
-
43
+
44
44
  level: float
45
45
  confidence level for prediction sets
46
46
 
47
47
  pi_method: str
48
48
  method for constructing the prediction intervals: 'splitconformal', 'localconformal'
49
+
50
+ type_split: a string;
51
+ Only if `level` is not `None`
52
+ "random" (random split of data) or "sequential" (sequential split of data)
49
53
 
50
54
  verbose: int
51
55
  controls verbosity (default=0)
@@ -95,6 +99,7 @@ class GBDTRegressor(GBDT, RegressorMixin):
95
99
  print(f"Regression Mean Squared Error lightgbm: {mse3:.2f}")
96
100
  ```
97
101
  """
102
+
98
103
  def __init__(
99
104
  self,
100
105
  model_type="xgboost",
@@ -105,12 +110,14 @@ class GBDTRegressor(GBDT, RegressorMixin):
105
110
  colsample=1.0,
106
111
  level=None,
107
112
  pi_method="splitconformal",
113
+ type_split="random",
108
114
  verbose=0,
109
115
  seed=123,
110
116
  **kwargs,
111
117
  ):
112
118
 
113
- self.type_fit = "regression"
119
+ self.type_fit = "regression"
120
+ self.type_split = type_split
114
121
 
115
122
  super().__init__(
116
123
  model_type=model_type,
@@ -128,34 +135,68 @@ class GBDTRegressor(GBDT, RegressorMixin):
128
135
 
129
136
  if self.level is not None:
130
137
 
131
- if model_type == "xgboost":
132
- self.model = PredictionInterval(XGBRegressor(**self.params),
133
- level=self.level,
134
- method=self.pi_method)
138
+ if model_type in ("xgboost", "xgb"):
139
+ self.model = PredictionInterval(
140
+ XGBRegressor(**self.params),
141
+ level=self.level,
142
+ method=self.pi_method,
143
+ type_split=self.type_split
144
+ )
135
145
  elif model_type == "catboost":
136
- self.model = PredictionInterval(CatBoostRegressor(**self.params),
137
- level=self.level,
138
- method=self.pi_method)
139
- elif model_type == "lightgbm":
140
- self.model = PredictionInterval(LGBMRegressor(**self.params),
141
- level=self.level,
142
- method=self.pi_method)
143
- elif model_type == "gradientboosting":
144
- self.model = PredictionInterval(GradientBoostingRegressor(**self.params),
145
- level=self.level,
146
- method=self.pi_method)
146
+ fast_cb = dict(
147
+ thread_count=-1,
148
+ boosting_type="Plain",
149
+ grow_policy="Depthwise",
150
+ bootstrap_type="Bernoulli",
151
+ subsample=0.8,
152
+ verbose=False
153
+ )
154
+ self.model = PredictionInterval(
155
+ CatBoostRegressor(**self.params, **fast_cb),
156
+ level=self.level,
157
+ method=self.pi_method,
158
+ type_split=self.type_split
159
+ )
160
+ elif model_type in ("lightgbm", "lgb"):
161
+ self.model = PredictionInterval(
162
+ LGBMRegressor(**self.params),
163
+ level=self.level,
164
+ method=self.pi_method,
165
+ type_split=self.type_split
166
+ )
167
+ elif model_type in ("gradientboosting", "gb"):
168
+ self.model = PredictionInterval(
169
+ GradientBoostingRegressor(**self.params),
170
+ level=self.level,
171
+ method=self.pi_method,
172
+ type_split=self.type_split
173
+ )
147
174
  else:
148
175
  raise ValueError(f"Unknown model_type: {model_type}")
149
-
150
- else:
151
-
152
- if model_type == "xgboost":
176
+
177
+ else:
178
+
179
+ if model_type in ("xgboost", "xgb"):
153
180
  self.model = XGBRegressor(**self.params)
181
+ <<<<<<< HEAD
154
182
  elif model_type == "catboost":
155
- self.model = CatBoostRegressor(**self.params)
183
+ fast_cb = dict(
184
+ thread_count=-1,
185
+ boosting_type="Plain",
186
+ grow_policy="Depthwise",
187
+ bootstrap_type="Bernoulli",
188
+ subsample=0.8,
189
+ verbose=False
190
+ )
191
+ self.model = CatBoostRegressor(**self.params, **fast_cb)
156
192
  elif model_type == "lightgbm":
193
+ =======
194
+ elif model_type in ("catboost", "cb"):
195
+ self.model = CatBoostRegressor(**self.params)
196
+ elif model_type in ("lightgbm", "lgb"):
197
+ >>>>>>> 0c97427b8cbd66d509a3cc24747eeea8b157779d
157
198
  self.model = LGBMRegressor(**self.params)
158
- elif model_type == "gradientboosting":
199
+ elif model_type in ("gradientboosting", "gb"):
159
200
  self.model = GradientBoostingRegressor(**self.params)
160
201
  else:
161
202
  raise ValueError(f"Unknown model_type: {model_type}")
@@ -28,9 +28,9 @@ __all__ = [
28
28
  "RegressorAdapter",
29
29
  "ClassifierAdapter",
30
30
  "RegressorNc",
31
- "ClassifierNc",
31
+ "ClassifierNc",
32
32
  "RegressorNormalizer",
33
33
  "IcpRegressor",
34
34
  "IcpClassifier",
35
- "TcpClassifier"
35
+ "TcpClassifier",
36
36
  ]
@@ -108,7 +108,7 @@ class ClassifierAdapter(BaseModelAdapter, ClassifierMixin):
108
108
 
109
109
  def _underlying_predict(self, x):
110
110
  return self.model.predict_proba(x)
111
-
111
+
112
112
 
113
113
  class RegressorAdapter(BaseModelAdapter, RegressorMixin):
114
114
  def __init__(self, model, fit_params=None):
@@ -8,7 +8,13 @@ from sklearn.ensemble import ExtraTreesRegressor
8
8
  from sklearn.preprocessing import StandardScaler
9
9
  from scipy.stats import gaussian_kde
10
10
  from tqdm import tqdm
11
- from ..nonconformist import ClassifierAdapter, IcpClassifier, TcpClassifier, ClassifierNc, MarginErrFunc
11
+ from ..nonconformist import (
12
+ ClassifierAdapter,
13
+ IcpClassifier,
14
+ TcpClassifier,
15
+ ClassifierNc,
16
+ MarginErrFunc,
17
+ )
12
18
 
13
19
 
14
20
  class PredictionSet(BaseEstimator, ClassifierMixin):
@@ -47,21 +53,18 @@ class PredictionSet(BaseEstimator, ClassifierMixin):
47
53
  self.alpha_ = 1 - self.level / 100
48
54
  self.quantile_ = None
49
55
  self.icp_ = None
50
- self.tcp_ = None
56
+ self.tcp_ = None
51
57
 
52
58
  if self.method == "icp":
53
- self.icp_ = IcpClassifier(
59
+ self.icp_ = IcpClassifier(
54
60
  ClassifierNc(ClassifierAdapter(self.obj), MarginErrFunc()),
55
61
  )
56
62
  elif self.method == "tcp":
57
- self.tcp_ = TcpClassifier(
63
+ self.tcp_ = TcpClassifier(
58
64
  ClassifierNc(ClassifierAdapter(self.obj), MarginErrFunc()),
59
- )
60
- else:
61
- raise ValueError(
62
- "`self.method` must be in ('icp', 'tcp')"
63
65
  )
64
-
66
+ else:
67
+ raise ValueError("`self.method` must be in ('icp', 'tcp')")
65
68
 
66
69
  def fit(self, X, y):
67
70
  """Fit the `method` to training data (X, y).
@@ -74,13 +77,14 @@ class PredictionSet(BaseEstimator, ClassifierMixin):
74
77
 
75
78
  y: array-like, shape = [n_samples, ]; Target values.
76
79
 
77
- """
80
+ """
78
81
  if self.method == "icp":
79
82
 
80
83
  X_train, X_calibration, y_train, y_calibration = train_test_split(
81
- X, y, test_size=0.5, random_state=self.seed)
84
+ X, y, test_size=0.5, random_state=self.seed
85
+ )
82
86
  self.icp_.fit(X_train, y_train)
83
- self.icp_.calibrate(X_calibration, y_calibration)
87
+ self.icp_.calibrate(X_calibration, y_calibration)
84
88
 
85
89
  elif self.method == "tcp":
86
90
 
@@ -101,11 +105,9 @@ class PredictionSet(BaseEstimator, ClassifierMixin):
101
105
 
102
106
  if self.method == "icp":
103
107
  return self.icp_.predict(X, significance=self.alpha_)
104
-
108
+
105
109
  elif self.method == "tcp":
106
110
  return self.tcp_.predict(X, significance=self.alpha_)
107
-
111
+
108
112
  else:
109
- raise ValueError(
110
- "`self.method` must be in ('icp', 'tcp')"
111
- )
113
+ raise ValueError("`self.method` must be in ('icp', 'tcp')")
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: unifiedbooster
3
- Version: 0.7.0
3
+ Version: 0.10.0
4
4
  Summary: Unified interface for Gradient Boosted Decision Trees
5
5
  Home-page: https://github.com/thierrymoudiki/unifiedbooster
6
6
  Author: T. Moudiki
@@ -22,8 +22,18 @@ Requires-Dist: numpy
22
22
  Requires-Dist: scikit-learn
23
23
  Requires-Dist: xgboost
24
24
  Requires-Dist: lightgbm
25
- Requires-Dist: catboost
26
25
  Requires-Dist: GPopt
27
26
  Requires-Dist: nnetsauce
27
+ Dynamic: author
28
+ Dynamic: author-email
29
+ Dynamic: classifier
30
+ Dynamic: description
31
+ Dynamic: home-page
32
+ Dynamic: keywords
33
+ Dynamic: license
34
+ Dynamic: license-file
35
+ Dynamic: requires-dist
36
+ Dynamic: requires-python
37
+ Dynamic: summary
28
38
 
29
39
  Unified interface for Gradient Boosted Decision Trees
@@ -0,0 +1,23 @@
1
+ unifiedbooster/__init__.py,sha256=8FEkWCZ2tT8xcW46Z0X_BS9_r0kQWVAu37IncLq6QWU,301
2
+ unifiedbooster/gbdt.py,sha256=FSaZngKlFR943cq1QclZlsOFjM6tmX446e6GeoGtA6Q,5176
3
+ unifiedbooster/gbdt_classification.py,sha256=9buXrIR3By3rvyEaYiPv4o7gFAuqJA_L6_uIT1vqRO0,6614
4
+ unifiedbooster/gbdt_regression.py,sha256=Zcy2jok5NkT1hVFtbI5TDioWzxlyCvRURYgfKwBo73A,6538
5
+ unifiedbooster/gpoptimization.py,sha256=UoT20E5dfhREiY7Cqo0vCktBzDBRnnG_6Xyg426vdfk,15238
6
+ unifiedbooster/nonconformist/__init__.py,sha256=sHEakjPhqUhmZwawAv34bHcTDmF1uZvqvGLIMjOM0B0,739
7
+ unifiedbooster/nonconformist/acp.py,sha256=SrfBVCWjXvntkBJ7GXTFYE6i6NU3Pv-5ibwhpItDKDw,11553
8
+ unifiedbooster/nonconformist/base.py,sha256=3nvSL_rL1Kxkj-lI5rEuMuK7fZyfrFqKKS1-UMdcLNA,4024
9
+ unifiedbooster/nonconformist/cp.py,sha256=YKiBFKwvaJbWnJcgi-saiVD_2ci-LBDHgytf70jHvFg,6174
10
+ unifiedbooster/nonconformist/evaluation.py,sha256=b24buhhW3v3CKRSi69WKCq9Sb38Unmjr8TAZr66Cdns,15906
11
+ unifiedbooster/nonconformist/icp.py,sha256=wqOaoy22KiF2ebVQOjp8MR-zvEjT0hE0NiMfeNZOQEw,15982
12
+ unifiedbooster/nonconformist/nc.py,sha256=_ED8Yn068Ivio9Xr0SjwKh4Ts5MfUACZFY40ObxPJ60,19644
13
+ unifiedbooster/nonconformist/util.py,sha256=UBKlAEb0mj9MVWBOKCRAq_OQP5Z53FMqWlTyo7RIg5Q,242
14
+ unifiedbooster/predictioninterval/__init__.py,sha256=I1X1omp6Bsuzfm7z8TCSICe2175rHrdoXWEDOicOP8U,85
15
+ unifiedbooster/predictioninterval/predictioninterval.py,sha256=6XQnJQDpsWG-uu5yFxeZQewnrErAjZLzv21YvtarXZQ,11164
16
+ unifiedbooster/predictionset/__init__.py,sha256=IGhWVX8-VeZ15HeLFWu8QeKCz7DIE4TlEXMjTnB3VdE,70
17
+ unifiedbooster/predictionset/predictionset.py,sha256=C38rC1qAhhXa8YUJjVB3yjYjPXToU1HVXBRoBevsRxk,3308
18
+ unifiedbooster-0.10.0.dist-info/licenses/LICENSE,sha256=3rWw63btcdqbC0XMnpzCQhxDP8Vx7yKkKS7EDgJiY_4,1061
19
+ unifiedbooster-0.10.0.dist-info/METADATA,sha256=fWymK7HzbDfARFxbQEsRYQHinNDbtwHvmYFx2e1lCIo,1152
20
+ unifiedbooster-0.10.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
21
+ unifiedbooster-0.10.0.dist-info/entry_points.txt,sha256=OVNTsCzMYnaJ11WIByB7G8Lym_dj-ERKZyQxWFUcW30,59
22
+ unifiedbooster-0.10.0.dist-info/top_level.txt,sha256=gOMxxpRtx8_nJXTWsXJDFkNeCsjSJQPs6aUXKK5_nI4,15
23
+ unifiedbooster-0.10.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (74.0.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,23 +0,0 @@
1
- unifiedbooster/__init__.py,sha256=8FEkWCZ2tT8xcW46Z0X_BS9_r0kQWVAu37IncLq6QWU,301
2
- unifiedbooster/gbdt.py,sha256=oAG-dQRY3FG9Tdhdb0iZuupMOAj1_KcGQbp47AHc72o,5175
3
- unifiedbooster/gbdt_classification.py,sha256=c9MYlPeTjQ4pAy0CZtroid9UfhQAlQVHekCWbbTIMBQ,5798
4
- unifiedbooster/gbdt_regression.py,sha256=tHi8XJ1jS2LuXdQoRDsTkFK3qt3L-4kQ9IRsMNW37gI,5351
5
- unifiedbooster/gpoptimization.py,sha256=UoT20E5dfhREiY7Cqo0vCktBzDBRnnG_6Xyg426vdfk,15238
6
- unifiedbooster/nonconformist/__init__.py,sha256=rETO9FfHb_yWs4ttLa2FJb2NAy-KFnyESeBTltDwJQA,739
7
- unifiedbooster/nonconformist/acp.py,sha256=SrfBVCWjXvntkBJ7GXTFYE6i6NU3Pv-5ibwhpItDKDw,11553
8
- unifiedbooster/nonconformist/base.py,sha256=Ycyt6pwxo0QjD3qBAfDqjzFvFfknIMkX0_yIc6EtPFo,4028
9
- unifiedbooster/nonconformist/cp.py,sha256=YKiBFKwvaJbWnJcgi-saiVD_2ci-LBDHgytf70jHvFg,6174
10
- unifiedbooster/nonconformist/evaluation.py,sha256=b24buhhW3v3CKRSi69WKCq9Sb38Unmjr8TAZr66Cdns,15906
11
- unifiedbooster/nonconformist/icp.py,sha256=wqOaoy22KiF2ebVQOjp8MR-zvEjT0hE0NiMfeNZOQEw,15982
12
- unifiedbooster/nonconformist/nc.py,sha256=_ED8Yn068Ivio9Xr0SjwKh4Ts5MfUACZFY40ObxPJ60,19644
13
- unifiedbooster/nonconformist/util.py,sha256=UBKlAEb0mj9MVWBOKCRAq_OQP5Z53FMqWlTyo7RIg5Q,242
14
- unifiedbooster/predictioninterval/__init__.py,sha256=I1X1omp6Bsuzfm7z8TCSICe2175rHrdoXWEDOicOP8U,85
15
- unifiedbooster/predictioninterval/predictioninterval.py,sha256=6XQnJQDpsWG-uu5yFxeZQewnrErAjZLzv21YvtarXZQ,11164
16
- unifiedbooster/predictionset/__init__.py,sha256=IGhWVX8-VeZ15HeLFWu8QeKCz7DIE4TlEXMjTnB3VdE,70
17
- unifiedbooster/predictionset/predictionset.py,sha256=k9s2PYK2KvOfDoGfSGXUHwwNA9kL2VYiT2JPokwZ8YA,3415
18
- unifiedbooster-0.7.0.dist-info/LICENSE,sha256=3rWw63btcdqbC0XMnpzCQhxDP8Vx7yKkKS7EDgJiY_4,1061
19
- unifiedbooster-0.7.0.dist-info/METADATA,sha256=7vR-c8aCOeF-96Uv9uBTugKmA-QC71b_5NyejATpnDM,955
20
- unifiedbooster-0.7.0.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
21
- unifiedbooster-0.7.0.dist-info/entry_points.txt,sha256=OVNTsCzMYnaJ11WIByB7G8Lym_dj-ERKZyQxWFUcW30,59
22
- unifiedbooster-0.7.0.dist-info/top_level.txt,sha256=gOMxxpRtx8_nJXTWsXJDFkNeCsjSJQPs6aUXKK5_nI4,15
23
- unifiedbooster-0.7.0.dist-info/RECORD,,