REF cleaner BaseTSFMSolver with richer default adaptation strategies#42
Open
rtavenar wants to merge 1 commit into
Open
REF cleaner BaseTSFMSolver with richer default adaptation strategies#42rtavenar wants to merge 1 commit into
rtavenar wants to merge 1 commit into
Conversation
- Add abstract model_id property; base class now caches the loaded model
across set_objective calls (no reload unless model_id changes).
- Replace abstract build_adapter with a non-abstract default that picks
the first available capability per task:
forecasting forecast_batch → windowed-embed ridge regression
classification embed_batch → pooled time_embed + LinearProbe
anomaly_detection embed_batch → forecast residuals
event_detection time_embed → causal-windowed embed + LogReg
- Add event_detection to the _Task type alias.
- Add embed() and time_embed() public methods (call embed_batch /
time_embed_batch and convert to numpy).
- Fix forecast() to convert numpy inputs to tensors before forecast_batch
and tensor outputs back to numpy before assembly.
- Fix swapped docstrings on embed_batch / time_embed_batch.
- Drop unused Callable import.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary (cf #39 )
model_idproperty + base-class model caching: the loaded model is now reused acrossset_objectivecalls and only reloaded whenmodel_idchanges (previously each call reloaded).build_adapteris no longer abstract: a non-abstract default covers all four tasks using the first available capability (see table below). Solvers only need to override it for genuinely custom adapter logic.embed()/time_embed()public methods: wrapembed_batch/time_embed_batchwith numpy conversion, making them directly usable in adapters and subclasses.event_detectionadded to the_Tasktype alias.forecast()type fix: numpy inputs are now converted to tensors beforeforecast_batch, and tensor outputs converted back to numpy before assembly (was a silent type mismatch).embed_batch/time_embed_batchcorrected;build_adapterdocstring now lists numbered fallback options instead of ambiguous→.Default adaptation strategies in
build_adapter(discussed in #31 )forecastingforecast_batch(zero-shot)embed_batch→ windowed ridge regressionclassificationembed_batch→ LinearProbetime_embed_batch→ mean-pooled + LinearProbeanomaly_detectionembed_batch→ distance-from-meanforecast_batch→ forecast-error residualsevent_detectiontime_embed_batch→ per-position LogRegembed_batch→ causal-windowed LogRegTest plan
BaseSolverdirectly and are unaffected by this PRforecast_batch+supported_tasks+model_id+load_modelshould work end-to-end for forecasting and anomaly detection without any further codemodel_idis unchanged🤖 Generated with Claude Code