You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(us-if-003): implement ifullmodel interfaces in predictionmodelresult (#245)
* fix(us-if-003): implement ifullmodel interfaces in predictionmodelresult
- add constructor accepting IFullModel parameter
- implement Train method throwing InvalidOperationException
- implement GetParameters, SetParameters, ParameterCount methods
- implement WithParameters method
- implement GetActiveFeatureIndices, SetActiveFeatureIndices methods
- implement IsFeatureUsed method
- implement GetFeatureImportance method
- implement DeepCopy and Clone methods
- all methods delegate to underlying Model property
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix(us-if-003): implement train delegation in predictionmodelresult
Update PredictionModelResult.Train() to delegate training to the inner model instead of throwing an exception. This completes the IFullModel implementation and allows the model to be trained through the wrapper.
Changes:
- Modified Train() method to check for null Model and delegate to Model.Train()
- Updated XML documentation to reflect the delegation behavior
- Ensures consistency with acceptance criteria for US-IF-003
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* refactor(us-if-003): enforce immutability in predictionmodelresult
PredictionModelResult represents an already-trained model snapshot and should
not allow mutation. This aligns with the architectural vision that users must
use PredictionModelBuilder to create and train models.
Changes:
1. Remove redundant IPredictiveModel interface (IFullModel is superset)
2. Revert Train() to throw InvalidOperationException (was delegating)
3. SetParameters() now throws InvalidOperationException (was delegating)
4. SetActiveFeatureIndices() now throws exception (was delegating)
5. Update IPredictionModelBuilder and PredictionModelBuilder to use
PredictionModelResult<T, TInput, TOutput> directly
Rationale:
- PredictionModelResult is a snapshot with OptimizationResult and metadata
- Retraining/mutation would invalidate the optimization results
- Users can still: Predict(), GetParameters(), Clone(), DeepCopy(), Save/Load
- Mutation is prevented: Train(), SetParameters(), SetActiveFeatureIndices()
- Even DeepCopy() returns PredictionModelResult, so copies can't be retrained
This enforces correct usage: use PredictionModelBuilder for training.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix(us-nf-009): ensure optimizationresult.bestsolution references correct model instance
**Changes:**
- WithParameters(): deep-copy OptimizationResult and update BestSolution to reference newModel
- Clone(): delegate to WithParameters for consistency
- DeepCopy(): update clonedOptimizationResult.BestSolution to reference clonedModel
- All methods now preserve BiasDetector and FairnessEvaluator components
**Rationale:**
Previously WithParameters() and Clone() reused the existing OptimizationResult instance,
which meant OptimizationResult.BestSolution still pointed to the old model instead of
the new model with updated parameters. This created inconsistent metadata.
Now all three methods (WithParameters, Clone, DeepCopy) ensure that
OptimizationResult.BestSolution always references the correct model instance.
Addresses code review feedback on PR #245.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix(testconsole): update examples to use predictionmodelresult instead of ipredictivemodel
**Changes:**
- TimeSeriesExample.cs: fix pattern matching to check model.Model instead of model
- EnhancedTimeSeriesExample.cs:
- Add using AiDotNet.Models.Results
- Change return types from IPredictiveModel to PredictionModelResult
- Update EvaluateModel parameter type to PredictionModelResult
- RegressionExample.cs: update model property access to use model.Model
- EnhancedRegressionExample.cs: update model property access to use model.Model
**Rationale:**
These testconsole examples were broken by removing IPredictiveModel from
PredictionModelResult's interface declaration (PR #245). The examples now
correctly work with PredictionModelResult and access the wrapped model
via the Model property when needed.
Fixes build errors introduced by PR #245 architectural changes.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
---------
Co-authored-by: Claude <[email protected]>
/// <exception cref="InvalidOperationException">Always thrown - PredictionModelResult represents an already-trained model and cannot be retrained.</exception>
352
+
/// <remarks>
353
+
/// PredictionModelResult is a snapshot of a trained model with its optimization results and metadata.
354
+
/// Retraining would invalidate the OptimizationResult and metadata.
355
+
/// To train a new model or retrain with different data, use PredictionModelBuilder.Build() instead.
0 commit comments