Skip to content

Commit

Permalink
Fix/S0 dataset initialization fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
L-M-Sherlock committed Jan 2, 2025
1 parent 4a48b43 commit 96cea5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "FSRS-Optimizer"
version = "5.6.2"
version = "5.6.3"
readme = "README.md"
dependencies = [
"matplotlib>=3.7.0",
Expand Down
11 changes: 11 additions & 0 deletions src/fsrs_optimizer/fsrs_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ def loss(stability):
class Optimizer:
float_delta_t: bool = False
enable_short_term: bool = True
S0_dataset_group = None

def __init__(
self, float_delta_t: bool = False, enable_short_term: bool = True
Expand Down Expand Up @@ -1007,6 +1008,16 @@ def pretrain(self, dataset=None, verbose=True):
]
if self.dataset.empty:
raise ValueError("Training data is inadequate.")
if self.S0_dataset_group is None:
self.dataset["first_rating"] = self.dataset["r_history"].map(
lambda x: x[0] if len(x) > 0 else ""
)
self.S0_dataset_group = (
self.dataset[self.dataset["i"] == 2]
.groupby(by=["first_rating", "delta_t"], group_keys=False)
.agg({"y": ["mean", "count"]})
.reset_index()
)
rating_stability = {}
rating_count = {}
average_recall = self.dataset["y"].mean()
Expand Down

0 comments on commit 96cea5f

Please sign in to comment.