c50py 0.2.1__tar.gz → 0.2.2__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.
@@ -1,11 +1,11 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: c50py
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: C5.0-like Decision Trees in Python (scikit-learn style)
5
5
  Author-email: David Díaz <daviddiazsolis@gmail.com>
6
6
  License: MIT
7
- Project-URL: Homepage, https://github.com/daviddiazsolis/c5py
8
- Project-URL: Issues, https://github.com/daviddiazsolis/c5py/issues
7
+ Project-URL: Homepage, https://github.com/daviddiazsolis/c50py
8
+ Project-URL: Issues, https://github.com/daviddiazsolis/c50py/issues
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: License :: OSI Approved :: MIT License
11
11
  Classifier: Operating System :: OS Independent
@@ -18,7 +18,6 @@ Requires-Dist: numpy>=1.21
18
18
  Requires-Dist: scikit-learn>=1.2
19
19
  Provides-Extra: graphviz
20
20
  Requires-Dist: graphviz>=0.20; extra == "graphviz"
21
- Dynamic: license-file
22
21
 
23
22
  # c5py — C5.0‑style Decision Trees for Python (clean 0.2.0)
24
23
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "c50py"
7
- version = "0.2.1"
7
+ version = "0.2.2"
8
8
  description = "C5.0-like Decision Trees in Python (scikit-learn style)"
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -27,8 +27,8 @@ classifiers = [
27
27
  graphviz = ["graphviz>=0.20"]
28
28
 
29
29
  [project.urls]
30
- Homepage = "https://github.com/daviddiazsolis/c5py"
31
- Issues = "https://github.com/daviddiazsolis/c5py/issues"
30
+ Homepage = "https://github.com/daviddiazsolis/c50py"
31
+ Issues = "https://github.com/daviddiazsolis/c50py/issues"
32
32
 
33
33
  [tool.setuptools.packages.find]
34
34
  where = ["src"]
@@ -212,7 +212,7 @@ class C5Regressor:
212
212
 
213
213
  # ----------------------------- Public API -----------------------------
214
214
 
215
- def fit(self, X, y, sample_weight: Optional[np.ndarray] = None):
215
+ def fit(self, X, y, sample_weight: Optional[np.ndarray] = None, feature_names: Optional[List[str]] = None):
216
216
  X = np.asarray(X, dtype=object)
217
217
  y = _as_float_array(y)
218
218
  n, m = X.shape
@@ -223,9 +223,16 @@ class C5Regressor:
223
223
  if w.shape[0] != n:
224
224
  raise ValueError("sample_weight must have same length as y")
225
225
 
226
- if self.feature_names is not None and len(self.feature_names) != m:
226
+ if feature_names is not None:
227
+ if len(feature_names) != m:
228
+ raise ValueError("feature_names length must match X.shape[1]")
229
+ self.feature_names_ = list(feature_names)
230
+ elif self.feature_names is not None and len(self.feature_names) != m:
227
231
  raise ValueError("feature_names length must match X.shape[1]")
228
- self.feature_names_ = list(self.feature_names) if self.feature_names is not None else None
232
+ elif self.feature_names is not None:
233
+ self.feature_names_ = list(self.feature_names)
234
+ else:
235
+ self.feature_names_ = None
229
236
 
230
237
  self.is_cat_ = self._infer_categorical_features(X)
231
238
  # Gather categorical values up to cap
@@ -269,7 +269,7 @@ class C5Classifier(BaseEstimator, ClassifierMixin):
269
269
  self.classes_ = None
270
270
  self.n_features_ = None
271
271
 
272
- def fit(self, X, y, sample_weight=None):
272
+ def fit(self, X, y, sample_weight=None, feature_names=None):
273
273
  X = np.asarray(X)
274
274
  y = np.asarray(y)
275
275
  if sample_weight is None:
@@ -281,7 +281,11 @@ class C5Classifier(BaseEstimator, ClassifierMixin):
281
281
 
282
282
  # Map categorical feature names to indices
283
283
  n_features = X.shape[1]
284
- if self.feature_names_ is None:
284
+ if feature_names is not None:
285
+ if len(feature_names) != n_features:
286
+ raise ValueError("feature_names length must match X.shape[1]")
287
+ self.feature_names_ = list(feature_names)
288
+ elif self.feature_names_ is None:
285
289
  self.feature_names_ = [f"f{i}" for i in range(n_features)]
286
290
  cf = self.categorical_features
287
291
  if cf is not None:
@@ -1,11 +1,11 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: c50py
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: C5.0-like Decision Trees in Python (scikit-learn style)
5
5
  Author-email: David Díaz <daviddiazsolis@gmail.com>
6
6
  License: MIT
7
- Project-URL: Homepage, https://github.com/daviddiazsolis/c5py
8
- Project-URL: Issues, https://github.com/daviddiazsolis/c5py/issues
7
+ Project-URL: Homepage, https://github.com/daviddiazsolis/c50py
8
+ Project-URL: Issues, https://github.com/daviddiazsolis/c50py/issues
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: License :: OSI Approved :: MIT License
11
11
  Classifier: Operating System :: OS Independent
@@ -18,7 +18,6 @@ Requires-Dist: numpy>=1.21
18
18
  Requires-Dist: scikit-learn>=1.2
19
19
  Provides-Extra: graphviz
20
20
  Requires-Dist: graphviz>=0.20; extra == "graphviz"
21
- Dynamic: license-file
22
21
 
23
22
  # c5py — C5.0‑style Decision Trees for Python (clean 0.2.0)
24
23
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes