Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pip install -U mostlyai-qa
On Linux, one can explicitly install the CPU-only variant of torch together with `mostlyai-qa`:

```bash
pip install -U torch==2.8.0+cpu torchvision==0.23.0+cpu mostlyai-qa --extra-index-url https://download.pytorch.org/whl/cpu
pip install -U torch==2.13.0+cpu torchvision==0.28.0+cpu mostlyai-qa --extra-index-url https://download.pytorch.org/whl/cpu
```

## Quick Start
Expand Down
14 changes: 12 additions & 2 deletions mostlyai/qa/_accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,13 @@ def _clip(col, bins):
if col.nunique() == 1:
# ensure 2 breaks for single-valued columns
val = col.dropna().iloc[0]
upper_limit = [val + np.timedelta64(1, "D")] if not pd.isna(val) else []
if not pd.isna(val):
try:
upper_limit = [val + np.timedelta64(1, "D")]
except (OverflowError, pd.errors.OutOfBoundsDatetime):
upper_limit = [val]
else:
upper_limit = []
breaks = [val] + upper_limit
else:
breaks = search_bin_boundaries(col, bins)
Expand Down Expand Up @@ -1165,7 +1171,11 @@ def _define_labels(breaks):
return labels

def _adjust_breaks(breaks):
return breaks[:-1] + [max(breaks[-1] + np.timedelta64(1, "D"), breaks[-1])]
try:
last = max(breaks[-1] + np.timedelta64(1, "D"), breaks[-1])
except (OverflowError, pd.errors.OutOfBoundsDatetime):
last = breaks[-1]
return breaks[:-1] + [last]

return bin_non_categorical(col, bins, _clip, _define_labels, _adjust_breaks, label_style=label_style)

Expand Down
Loading