Skip to content

Commit

Permalink
more hints
Browse files Browse the repository at this point in the history
  • Loading branch information
deadsoul44 committed Aug 1, 2024
1 parent b8c7c26 commit 65541fb
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "perpetual"
version = "0.3.5"
version = "0.3.6"
edition = "2021"
authors = ["Mutlu Simsek <msimsek@perpetual-ml.com>"]
homepage = "https://perpetual-ml.com"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pip install perpetual
To use in a Rust project, add the following to your Cargo.toml file to get the package from [crates.io](https://crates.io/crates/perpetual).

```toml
perpetual = "0.3.5"
perpetual = "0.3.6"
```

## Paper
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.3.5"
version = "0.3.6"
edition = "2021"
authors = ["Mutlu Simsek <msimsek@perpetual-ml.com>"]
homepage = "https://perpetual-ml.com"
Expand All @@ -19,7 +19,7 @@ crate-type = ["cdylib", "rlib"]

[dependencies]
pyo3 = { version = "0.21", features = ["extension-module"] }
perpetual_rs = {package="perpetual", version = "0.3.5", path = "../" }
perpetual_rs = {package="perpetual", version = "0.3.6", path = "../" }
numpy = "0.21"
ndarray = "0.15"
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.3.5"
version = "0.3.6"
description = "A self-generalizing gradient boosting machine which doesn't need hyperparameter optimization"
license = { file = "LICENSE" }
keywords = [
Expand Down
14 changes: 7 additions & 7 deletions python-package/python/perpetual/booster.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import inspect
import json
from typing import Any, Dict, Iterable, List, Tuple, Union, cast
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union, cast
from typing_extensions import Self
import warnings

Expand Down Expand Up @@ -44,7 +44,7 @@ def __init__(
missing: float = np.nan,
allow_missing_splits: bool = True,
create_missing_branch: bool = False,
terminate_missing_features: Iterable[Any] | None = None,
terminate_missing_features: Optional[Iterable[Any]] = None,
missing_node_treatment: str = "None",
log_iterations: int = 0,
feature_importance_method: str = "Gain",
Expand Down Expand Up @@ -423,7 +423,7 @@ def partial_dependence(
self,
X,
feature: Union[str, int],
samples: int | None = 100,
samples: Optional[int] = 100,
exclude_missing: bool = True,
percentile_bounds: Tuple[float, float] = (0.2, 0.98),
) -> np.ndarray:
Expand All @@ -439,7 +439,7 @@ def partial_dependence(
feature (Union[str, int]): The feature for which to calculate the partial
dependence values. This can be the name of a column, if the provided
X is a pandas DataFrame, or the index of the feature.
samples (int | None, optional): Number of evenly spaced samples to select. If None
samples (Optional[int]): Number of evenly spaced samples to select. If None
is passed all unique values will be used. Defaults to 100.
exclude_missing (bool, optional): Should missing excluded from the features? Defaults to True.
percentile_bounds (Tuple[float, float], optional): Upper and lower percentiles to start at
Expand Down Expand Up @@ -542,7 +542,7 @@ def partial_dependence(

def calculate_feature_importance(
self, method: str = "Gain", normalize: bool = True
) -> Dict[int, float] | dict[str, float]:
) -> Union[Dict[int, float], dict[str, float]]:
"""Feature importance values can be calculated with the `calculate_feature_importance` method. This function will return a dictionary of the features and their importance values. It should be noted that if a feature was never used for splitting it will not be returned in importance dictionary.
Args:
Expand Down Expand Up @@ -794,8 +794,8 @@ def get_node_lists(self, map_features_names: bool = True) -> List[List[Node]]:
```
"""
model = json.loads(self.json_dump())["trees"]
feature_map: Dict[int, str] | Dict[int, int]
leaf_split_feature: str | int
feature_map: Union[Dict[int, str], Dict[int, int]]
leaf_split_feature: Union[str, int]
if map_features_names and hasattr(self, "feature_names_in_"):
feature_map = {i: ft for i, ft in enumerate(self.feature_names_in_)}
leaf_split_feature = ""
Expand Down
6 changes: 3 additions & 3 deletions python-package/python/perpetual/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from abc import ABC, abstractmethod
from ast import literal_eval
from dataclasses import dataclass
from typing import Dict, Generic, List, TypeVar, Union
from typing import Dict, Generic, List, Tuple, TypeVar, Union

import numpy as np
import numpy.typing as npt
Expand Down Expand Up @@ -54,9 +54,9 @@ def deserialize(self, obj_repr: str) -> ObjectItem:

@dataclass
class NumpyData:
array: list[float] | list[int]
array: Union[List[float], List[int]]
dtype: str
shape: tuple[int, ...]
shape: Tuple[int, ...]


class NumpySerializer(BaseSerializer[npt.NDArray]):
Expand Down

0 comments on commit 65541fb

Please sign in to comment.