Skip to content

Commit

Permalink
Merge pull request #29 from perpetual-ml/max_cat_fix
Browse files Browse the repository at this point in the history
max_cat fix
  • Loading branch information
deadsoul44 authored Nov 19, 2024
2 parents 21ac336 + a938441 commit 69e3bf5
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "perpetual"
version = "0.7.4"
version = "0.7.5"
edition = "2021"
authors = ["Mutlu Simsek <[email protected]>"]
homepage = "https://perpetual-ml.com"
Expand All @@ -22,7 +22,7 @@ codegen-units = 1
[dependencies]
rayon = "1.8"
thiserror = "2.0.3"
serde_json = { version = "1.0.132", features = ["float_roundtrip"] }
serde_json = { version = "1.0.133", features = ["float_roundtrip"] }
serde = { version = "1.0.215", features = ["derive"] }
approx = "0.5"
log = "0.4"
Expand Down
4 changes: 2 additions & 2 deletions python-package/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "py-perpetual"
version = "0.7.4"
version = "0.7.5"
edition = "2021"
authors = ["Mutlu Simsek <[email protected]>"]
homepage = "https://perpetual-ml.com"
Expand All @@ -19,7 +19,7 @@ crate-type = ["cdylib", "rlib"]

[dependencies]
pyo3 = { version = "0.22.6", features = ["extension-module"] }
perpetual_rs = {package="perpetual", version = "0.7.4", path = "../" }
perpetual_rs = {package="perpetual", version = "0.7.5", path = "../" }
numpy = "0.22.1"
ndarray = "0.16.1"
serde_plain = { version = "1.0" }
Expand Down
2 changes: 1 addition & 1 deletion python-package/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "maturin"

[project]
name = "perpetual"
version = "0.7.4"
version = "0.7.5"
description = "A self-generalizing gradient boosting machine which doesn't need hyperparameter optimization"
license = { file = "LICENSE" }
keywords = [
Expand Down
1 change: 0 additions & 1 deletion python-package/python/perpetual/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def convert_input_frame(
logger.warning(
f"Feature {features_[i]} will be treated as numerical since the number of categories ({len(categories)}) exceeds max_cat ({max_cat}) threshold."
)
continue
categories = [c for c in list(categories) if c != "nan"]
categories.insert(0, "nan")
cat_mapping[features_[i]] = categories
Expand Down
14 changes: 14 additions & 0 deletions python-package/tests/test_booster.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ def X_y() -> Tuple[pd.DataFrame, pd.Series]:
return X, y


def test_booster_max_cat(X_y):
df = pd.read_csv("../resources/titanic.csv")
X = df.drop(columns="survived").reset_index(drop=True)
y = df["survived"]

num_cols = X.select_dtypes(include=np.number).columns.tolist()
all_cols = X.columns.tolist()
cat_cols = [x for x in all_cols if x not in num_cols]
X[cat_cols] = X[cat_cols].astype("category")

model = PerpetualBooster(objective="LogLoss", max_cat=4)
model.fit(X, y)


def test_booster_no_variance(X_y):
X, y = X_y
X.iloc[:, 3] = 1
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-single-python-test.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Set-Location python-package
maturin develop --release
pytest tests/test_openml.py::test_sensory -s
pytest tests/test_booster.py::test_booster_max_cat -s
Set-Location ..

0 comments on commit 69e3bf5

Please sign in to comment.