Skip to content
Draft
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 .github/workflows/pr_code_changes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: astral-sh/setup-uv@v8.1.0
- name: Install relevant dependencies
run: |
uv pip install "ruff>=0.9.0" --system
uv pip install "ruff>=0.9.0,<0.17.0" --system
- name: Check code formatting
run: make check-format

Expand Down
1 change: 1 addition & 0 deletions changelog.d/202.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fit preprocessing statistics on donor training rows and reuse them for receivers, including single-row predictions. Cross-validation fits transformations within each fold and scores inverse-transformed predictions on the original target scale. Returned fitted models now replay donor preprocessing on future raw-data predictions and restore target units.
1 change: 1 addition & 0 deletions changelog.d/203.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Compute deterministic zero-inflated quantiles by inverting the ordered negative, zero, and positive mixture CDF. Preserve stochastic draws when quantiles are omitted, and reject unsupported sequential marginal quantiles or component predictions outside their sign support.
1 change: 1 addition & 0 deletions changelog.d/204.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Run core autoimpute tests without optional Matching or MDN dependencies instead of failing with an undefined Matching name.
1 change: 1 addition & 0 deletions changelog.d/205.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Apply the configured QRF defaults with at least 20 training observations per leaf and full leaf distributions. Compute survey-weighted conditional quantiles using each tree's normalized leaf weights and bootstrap donor multiplicities, and query sampled quantiles without discretizing them onto a truncated grid.
1 change: 1 addition & 0 deletions changelog.d/206-distributions.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Validate and propagate numeric zero-inflated sample weights to gate classifiers and sign-specific component fits, including aligned Series and array weights. Give numeric components reproducible independent random seeds and forward component fit parameters.
1 change: 1 addition & 0 deletions changelog.d/206-matching-scoring.breaking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Matching donor draws are no longer presented as quantile forecasts or class probabilities. autoimpute excludes Matching from default distributional model selection and skips its unsupported scores if explicitly supplied. Direct Matching.predict without quantiles remains available. Rerun comparisons that previously scored replicated donor draws or fabricated probabilities.
1 change: 1 addition & 0 deletions changelog.d/206-models.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow QuantReg to fit requested prediction quantiles lazily on its original donor data; keep intercept columns on homogeneous receivers and reject nonfinite OLS/QuantReg inputs. Matching now explicitly rejects conditional quantile and class-probability requests instead of relabeling donor draws, retains and subsets donor weights during tuning, uses the documented weighted StatMatch API, and reports failed-record counts on returned data frames. Failed tuning trials remain pruned rather than scored using fallback values. Normalize OLS survey weights so arbitrary weight units cannot change predictive quantiles. Matching's R donor draws now use reproducible advancing child seeds while preserving the caller's R RNG state.
1 change: 1 addition & 0 deletions changelog.d/206-pipeline.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Honor autoimpute train_size by reproducibly sampling donor rows, forward random_state to model fitting, evaluate requested quantile grids, and retune final parameters on all training rows instead of selecting the luckiest outer test fold. Report the standard deviation of fold-average losses correctly. Distributional QRF comparisons use independent target fits so reported quantiles are conditional on the original predictors; stochastic sequential donor draws remain available through direct QRF use.
1 change: 1 addition & 0 deletions changelog.d/206-qrf-quantiles.breaking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add QRF(sequential=False) to estimate each target's conditional marginal quantiles using the original predictors only, with target-order-independent seeds. Sequential multi-target QRF now rejects explicit quantiles because same-quantile chaining does not calculate marginal quantiles; stochastic sequential draws remain supported. Distributional comparison and imputation helpers use independent QRF fits. Numeric hyperparameter tuning now evaluates the actual predicted median instead of scoring a random draw as a median.
1 change: 1 addition & 0 deletions changelog.d/207.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Per-variable QRF models now derive distinct seeds, so variables imputed together no longer share one random quantile per row and come out comonotonic. `QRF` also accepts a `seed` argument.
1 change: 1 addition & 0 deletions changelog.d/208.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Draw one independent OLS residual per receiver from a persistent random generator, advancing across targets and prediction calls while preserving reproducibility from the same seed. QuantReg random grid sampling also advances independently across calls and targets.
1 change: 1 addition & 0 deletions changelog.d/209-target-types.breaking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Numeric columns, including integer counts and 0/1 integers, now remain numeric regardless of cardinality or the values present in a fold. Declare categorical targets with target_types={"column": "categorical"}, pandas categorical dtype, or boolean dtype for binary categories. Log-loss comparisons require the probabilities returned by predict(return_probs=True).
1 change: 1 addition & 0 deletions changelog.d/209.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Compute categorical comparison and cross-validation log loss from actual model probabilities. Reject class-label inputs rather than fabricating 0.99/0.01 probabilities, and align classes when a cross-validation fold lacks a category.
1 change: 1 addition & 0 deletions changelog.d/210.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Matching hyperparameter tuning now prunes a trial when matching fails, instead of silently scoring it as if it had predicted the training mean. The predict path reports how many records could not be matched.
1 change: 1 addition & 0 deletions changelog.d/212.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Compute normalized mutual information from consistent paired discretizations and natural-log entropies, with configurable continuous-variable bins and explicit zero information for constants. Predictor analysis now scores categorical forecasts from their actual probabilities.
1 change: 1 addition & 0 deletions changelog.d/213-validation.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reject duplicate predictor/target names, predictor-target overlap, duplicate DataFrame columns, incompatible numeric/string predictor dtypes, and infinite sample weights with actionable errors. Treat numeric int/float predictor dtypes as compatible.
1 change: 1 addition & 0 deletions changelog.d/219-adversarial.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent integer overflow in quantile loss and Matching tuning; consistently honor numeric boolean targets, preserve survey weights when transforming a weight predictor, retain default constant-category probabilities, and support nullable numeric OLS predictors.
1 change: 1 addition & 0 deletions changelog.d/lint-on-main.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reformats five documentation files so the Lint job passes again, and bounds the ruff version the job installs.
12 changes: 6 additions & 6 deletions docs/imputation-benchmarking/cross-validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ Returns a dictionary containing separate results for each metric type:
```python
{
"quantile_loss": {
"results": pd.DataFrame, # rows: ["train", "test"], cols: quantiles (mean across folds)
"results": pd.DataFrame, # rows: ["train", "test"], cols: quantiles (mean across folds)
"results_std": pd.DataFrame, # rows: ["train", "test"], cols: quantiles (std across folds)
"mean_train": float,
"mean_test": float,
"std_train": float,
"std_test": float,
"variables": List[str] # numerical variables evaluated
"variables": List[str], # numerical variables evaluated
},
"log_loss": {
"results": pd.DataFrame, # rows: ["train", "test"], cols: quantiles
"results": pd.DataFrame, # rows: ["train", "test"], cols: quantiles
"results_std": pd.DataFrame, # rows: ["train", "test"], cols: quantiles (std across folds)
"mean_train": float,
"mean_test": float,
"std_train": float,
"std_test": float,
"variables": List[str] # categorical variables evaluated
}
"variables": List[str], # categorical variables evaluated
},
}
```

Expand All @@ -77,7 +77,7 @@ results = cross_validate_model(
data=diabetes_df,
predictors=["age", "sex", "bmi", "bp"],
imputed_variables=["s1", "s4"],
n_splits=5
n_splits=5,
)

# Check performance for numerical variables
Expand Down
8 changes: 4 additions & 4 deletions docs/imputation-benchmarking/preprocessing.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ result = autoimpute(
predictors=["age", "education"],
imputed_variables=["income", "wealth"],
preprocessing={
"income": "log", # Log transform (positive values only)
"wealth": "asinh", # Asinh transform (handles zeros/negatives)
"age": "normalize" # Z-score normalization
}
"income": "log", # Log transform (positive values only)
"wealth": "asinh", # Asinh transform (handles zeros/negatives)
"age": "normalize", # Z-score normalization
},
)
```

Expand Down
8 changes: 2 additions & 6 deletions docs/imputation-benchmarking/visualizations.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ comparison_viz = method_comparison_results(
)

# Generate plot
fig = comparison_viz.plot(
title="Method comparison",
show_mean=True,
plot_type="bar"
)
fig = comparison_viz.plot(title="Method comparison", show_mean=True, plot_type="bar")
fig.show()

# Get summary statistics
Expand Down Expand Up @@ -165,7 +161,7 @@ perf_viz = model_performance_results(
results=cv_results,
model_name="QRF",
method_name="Cross-validation",
metric="quantile_loss"
metric="quantile_loss",
)

fig = perf_viz.plot(title="QRF performance")
Expand Down
4 changes: 1 addition & 3 deletions docs/models/imputer/implement-new-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ class NewModelResults(ImputerResults):

except Exception as e:
self.logger.error(f"Error during Model prediction: {str(e)}")
raise RuntimeError(
f"Failed to predict with Model: {str(e)}"
) from e
raise RuntimeError(f"Failed to predict with Model: {str(e)}") from e
```

## Implementing the main model class
Expand Down
12 changes: 6 additions & 6 deletions docs/use_cases/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@ Before imputation, make sure both datasets have compatible variables. Identify c

```python
# Identify common variables
common_variables = ['age', 'income', 'education', 'marital_status', 'region']
common_variables = ["age", "income", "education", "marital_status", "region"]

# Ensure variable formats match (example: education coding)
education_mapping = {
1: "less_than_hs",
2: "high_school",
3: "some_college",
4: "bachelor",
5: "graduate"
5: "graduate",
}

# Apply standardization to both datasets
for dataset in [scf_data, cps_data]:
dataset['education'] = dataset['education'].map(education_mapping)
dataset["education"] = dataset["education"].map(education_mapping)

# Convert income to same units (thousands)
if 'income' in dataset.columns:
dataset['income'] = dataset['income'] / 1000
if "income" in dataset.columns:
dataset["income"] = dataset["income"] / 1000

# Identify target variable in donor dataset
target_variable = ['networth']
target_variable = ["networth"]
```

## Performing imputation
Expand Down
Loading