yohou.testing¶
Systematic check functions for testing custom estimators. Use these to validate that your forecasters, transformers, scorers, and splitters conform to Yohou's API contracts.
Forecaster checks¶
| Name | Description |
|---|---|
check_clone_preserves_forecaster_params |
Check sklearn's clone() preserves init parameters. |
check_fit_sets_forecaster_attributes |
Check fit() sets required forecaster attributes. |
check_fit_predict_without_exogenous |
Check forecaster behavior when X=None at fit time. |
check_forecaster_methods_call_check_is_fitted |
Check all forecaster methods (except fit) raise NotFittedError when unfitted. |
check_forecaster_not_fitted_error |
Check accessing fitted attributes before fit() raises NotFittedError. |
check_forecaster_tags_accessible_before_fit |
Check __sklearn_tags__() is accessible before fit(). |
check_forecaster_tags_match_capabilities |
Check forecaster tags accurately reflect capabilities. |
check_forecaster_tags_static_after_fit |
Check forecaster tags remain static after fit(). |
check_forecasting_horizon_validation |
Check forecasting_horizon < 1 raises ValueError. |
check_observe_extends_observations |
Check observe() extends observation buffers correctly. |
check_predict_time_columns |
Check predictions have vintage_time and time columns. |
check_prediction_types_property |
Check forecaster_type tag is set correctly. |
check_rewind_propagates_to_transformers |
Check rewind() propagates to transformers in forecaster. |
check_rewind_replaces_observations |
Check rewind() replaces observation buffers correctly. |
Point forecaster checks¶
| Name | Description |
|---|---|
check_point_prediction_structure |
Check point predictions have correct column structure. |
check_point_prediction_types |
Check point forecaster has 'point' in forecaster_type tag. |
Interval forecaster checks¶
| Name | Description |
|---|---|
check_coverage_rates_parameter |
Check coverage_rates is list of floats in (0, 1). |
check_coverage_rates_validation |
Check invalid coverage_rates raise ValueError during fit and predict. |
check_interval_bounds |
Check upper >= lower for all coverage rates and time steps. |
check_interval_prediction_columns |
Check interval predictions have {col}lower} and {colupper format. |
check_interval_prediction_types |
Check interval forecaster has 'interval' in forecaster_type tag. |
Reduction forecaster checks¶
| Name | Description |
|---|---|
check_estimator_parameter |
Check estimator parameter is sklearn BaseEstimator. |
check_reduction_strategy |
Check reduction_strategy parameter is valid. |
Panel data checks¶
| Name | Description |
|---|---|
check_panel_data |
Check cross-learning with panel data predicts all groups by default. |
check_panel_invalid_group_raises |
Check that invalid panel_group raises ValueError. |
check_panel_single_group |
Check cross-learning filters to specified panel group. |
Transformer checks¶
| Name | Description |
|---|---|
check_fit_idempotent |
Check that fit(X).fit(X) equals fit(X). |
check_fit_sets_attributes |
Check fit() sets required attributes. |
check_fit_transform_equivalence |
Check fit_transform(X) == fit(X).transform(X). |
check_feature_names_out_match |
Check get_feature_names_out() matches transform() output columns. |
check_transform_output_structure |
Check transform() output has "time" column and valid structure. |
check_transform_drops_warmup_rows |
Check stateful transformers drop exactly observation_horizon rows. |
check_transformer_methods_call_check_is_fitted |
Check all transformer methods (except fit) raise NotFittedError when unfitted. |
check_transformer_preserve_dtypes |
Check transformer preserves input dtypes. |
check_transformers_unfitted_stateless |
Check stateless transformers work without fitting. |
check_observation_horizon_after_fit |
Check observation_horizon is valid after fit(). |
check_observation_horizon_not_fitted |
Check accessing observation_horizon before fit() raises NotFittedError. |
check_observe_concatenates_memory |
Check observe() appends new data and maintains horizon size. |
check_observe_transform_equivalence |
Check observe().transform() == fit().transform() for same final state. |
check_observe_transform_sequential_consistency |
Check observe_transform(A) then observe_transform(B) == observe_transform(A+B). |
check_rewind_transform_behavior |
Check rewind_transform() behavior and contract. |
check_rewind_updates_memory |
Check rewind() updates _X_observed to last observation_horizon rows. |
check_memory_bounded |
Check memory doesn't grow unbounded with sequential updates. |
check_insufficient_data_raises |
Check behavior when data length < observation_horizon. |
check_inverse_transform_identity |
Check inverse_transform(transform(X)) ≈ X. |
check_inverse_transform_round_trip |
Check inverse_transform(transform(X)) ≈ X with shape validation. |
check_inverse_observe_transform_identity |
Check inverse_transform(observe_transform(X)) ≈ X. |
check_panel_data_support |
Check transformer handles panel columns (panel data) correctly. |
check_panel_group_preservation |
Check that transformers preserve panel group names after transformation. |
check_tags_accessible_before_fit |
Check __sklearn_tags__() is accessible before fit(). |
check_tags_match_capabilities |
Check tags accurately reflect transformer capabilities. |
check_tags_static_after_fit |
Check tags remain static (don't change) after fit(). |
Scorer checks¶
| Name | Description |
|---|---|
check_scorer_aggregation_methods |
Check all aggregation_method combinations produce valid output. |
check_scorer_component_subselection |
Check components filtering works correctly. |
check_scorer_coverage_rate_subselection |
Check coverage_rates parameter filters interval predictions correctly. |
check_scorer_lower_is_better |
Check lower_is_better convention matches scoring direction. |
check_scorer_methods_call_check_is_fitted |
Check all scorer methods (except fit) raise NotFittedError when unfitted. |
check_scorer_panel_subselection |
Check groups filtering works correctly. |
check_scorer_parameter_validation |
Check parameter validation raises ValueError for invalid inputs. |
check_scorer_prediction_type_compatibility |
Check scorer works with correct forecaster output type. |
check_scorer_tags_accessible_before_fit |
Check __sklearn_tags__() is callable on scorer instance. |
check_scorer_tags_match_capabilities |
Check tag values match actual scorer behavior. |
check_scorer_tags_static_after_fit |
Check tags remain unchanged after fit. |
Splitter checks¶
| Name | Description |
|---|---|
check_splitter_n_splits_consistency |
Check get_n_splits() matches actual split count. |
check_splitter_non_overlapping_tests |
Check test sets don't overlap if produces_non_overlapping_tests=True. |
check_splitter_panel_data_support |
Check splitter handles panel data if supports_panel_data=True. |
check_splitter_parameter_constraints |
Check parameter constraints are enforced via sklearn validation. |
check_splitter_produces_valid_indices |
Check all train/test indices are valid row positions. |
check_splitter_tags_accessible_before_fit |
Check __sklearn_tags__() is callable on splitter instance. |
check_splitter_tags_match_capabilities |
Check tag values match actual splitter behavior. |
check_splitter_tags_static_after_fit |
Check tags remain unchanged after fit. |
Search checks¶
| Name | Description |
|---|---|
check_search_clone_preserves_params |
Check sklearn clone() preserves search CV parameters. |
check_search_fit_sets_attributes |
Check fit() sets required search CV attributes. |
check_search_not_fitted_error |
Check accessing fitted attributes before fit() raises NotFittedError. |
check_search_cv_results_structure |
Check cv_results_ has required structure. |
check_search_method_availability |
Check @available_if decorator logic with refit=True/False. |
check_search_predict_delegates |
Check predict() delegates to best_forecaster_.predict() correctly. |
check_search_observe_delegates |
Check observe() delegates to best_forecaster_.observe() correctly. |
check_search_rewind_delegates |
Check rewind() delegates to best_forecaster_.rewind() correctly. |
check_search_multimetric_scoring |
Check multi-metric scoring with dict scorer works correctly. |
check_search_error_score_handling |
Check error_score parameter handles failing fits correctly. |
check_search_refit_false_no_forecaster |
Check refit=False doesn't create best_forecaster_. |
check_search_return_train_score |
Check return_train_score=True adds train score keys to cv_results_. |
check_search_panel_data |
Check groups parameter propagates correctly. |
check_grid_search_exhaustive |
Check GridSearchCV evaluates all parameter combinations. |
check_grid_search_param_grid_validation |
Check param_grid format is validated (dict or list of dicts). |
check_randomized_search_distributions |
Check scipy.stats distributions work for parameter sampling. |
check_randomized_search_n_iter |
Check n_iter controls number of parameter combinations evaluated. |
check_randomized_search_reproducibility |
Check random_state produces same parameter samples. |
Metadata routing¶
| Name | Description |
|---|---|
check_metadata_routing_default_request |
Check that by default metadata routing request is empty. |
check_metadata_routing_get_metadata_routing |
Check that get_metadata_routing() is implemented correctly. |
assert_request_equal |
Assert metadata request matches expected dictionary. |
assert_request_is_empty |
Check if a metadata request dict is empty. |
check_recorded_metadata |
Check whether the expected metadata is passed to the object's method. |
record_metadata |
Utility function to store passed metadata to a method of obj. |