Skip to content

Commit

Permalink
Don't infer ncust, allow for easy override
Browse files Browse the repository at this point in the history
  • Loading branch information
StijnKas committed Oct 4, 2023
1 parent c82373d commit 91bf707
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions python/pdstools/valuefinder/ValueFinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(
df: Optional[Union[pd.DataFrame, pl.DataFrame, pl.LazyFrame]] = None,
verbose: bool = True,
import_strategy: Literal["eager", "lazy"] = "eager",
ncust: int = None,
**kwargs,
):
if path is None and df is None:
Expand Down Expand Up @@ -95,11 +96,12 @@ def __init__(
else:
self.th = pl.LazyFrame({"th": kwargs.pop("th")})

self.ncust = self.df.select(
(pl.lit(10) ** pl.col("CustomerID").n_unique().log10().ceil())
.cast(pl.UInt32)
.alias("ncust")
)
if ncust is None:
self.ncust = self.df.select(
pl.col("CustomerID").n_unique().cast(pl.UInt32).alias("ncust")
)
else:
self.ncust = pl.LazyFrame({"ncust": ncust}, schema={"ncust": pl.UInt32})

self.NBADStages = ["Eligibility", "Applicability", "Suitability", "Arbitration"]
self.StageOrder = (
Expand Down

0 comments on commit 91bf707

Please sign in to comment.