Skip to content

Clarify DifferenceInDifferences.predict() support contract #579

Description

@shawcharles

Problem

DifferenceInDifferences.predict() exists on the estimator, but it raises NotImplementedError. The method docstring currently describes prediction as if it were supported, while TODO.md lists predict() as a known limitation.

That can confuse users coming from sklearn-style estimators: the method is discoverable, but the supported post-estimation surface is actually results_.fitted_values for fitted training-data predictions.

Proposed behaviour

Clarify the current contract without implementing new prediction semantics:

  • document that out-of-sample predict() is currently unsupported;
  • keep the method raising NotImplementedError after fitting;
  • point users to results_.fitted_values for fitted training-data predictions;
  • frame broader prediction support as pending a post-estimation result-object design.

Proposed scope

  • Update the DifferenceInDifferences.predict() docstring and error message.
  • Add a regression test for the unsupported fitted-predict contract.
  • Add a short API docs note under DifferenceInDifferences.
  • Do not implement prediction or change result-object semantics.

Validation

  • PYTHONPATH=. DIFF_DIFF_BACKEND=python pytest tests/test_methodology_did.py::TestResultsObject::test_predict_contract_points_to_fitted_values -q
  • PYTHONPATH=. DIFF_DIFF_BACKEND=python pytest tests/test_methodology_did.py::TestResultsObject -q
  • PYTHONPATH=. DIFF_DIFF_BACKEND=python pytest tests/test_methodology_did.py -q
  • PYTHONPATH=. DIFF_DIFF_BACKEND=python .venv-py39/bin/python -m pytest tests/test_methodology_did.py::TestResultsObject::test_predict_contract_points_to_fitted_values -q
  • python -m ruff check diff_diff/estimators.py
  • git diff --check

Note: make -C docs html SPHINXOPTS="-W" is currently blocked on pre-existing tutorial 19 DID unknown-target warnings, which are addressed separately in PR #572.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions