Problem
The pipeline has two parallel model creation paths:
-
ModelFactory (model_factory.py, 727 lines) — Clean factory pattern with BaseModel, CNNModel, MLPModel, etc. Has register_model() and list_models() for extensibility. Not used by the pipeline — only used in tests.
-
ModelBuilder (model.py, 1,434 lines) — Legacy class with create_cnn_model(), create_mlp_model(), etc. that duplicate the factory's model definitions. This is what the pipeline actually calls via ModelManager.
Fix
- Make
ModelBuilder.build_model() delegate to ModelFactory.create_model() instead of its own create_* methods
- Delete the duplicate
create_cnn_model(), create_mlp_model(), create_logistic_regression(), create_random_forest(), create_xgboost_model() from ModelBuilder
- Keep
ModelBuilder for training logic (train_model(), _train_neural_network(), _train_sklearn_model()) and checkpoint management
- This would cut
model.py from ~1,434 lines to ~800 lines and make ModelFactory the single source of truth for model definitions
Impact
ModelFactory.register_model() and list_models() become actually useful
- Users can register custom models that work with the full pipeline
- Eliminates ~600 lines of duplicate code
Problem
The pipeline has two parallel model creation paths:
ModelFactory(model_factory.py, 727 lines) — Clean factory pattern withBaseModel,CNNModel,MLPModel, etc. Hasregister_model()andlist_models()for extensibility. Not used by the pipeline — only used in tests.ModelBuilder(model.py, 1,434 lines) — Legacy class withcreate_cnn_model(),create_mlp_model(), etc. that duplicate the factory's model definitions. This is what the pipeline actually calls viaModelManager.Fix
ModelBuilder.build_model()delegate toModelFactory.create_model()instead of its owncreate_*methodscreate_cnn_model(),create_mlp_model(),create_logistic_regression(),create_random_forest(),create_xgboost_model()fromModelBuilderModelBuilderfor training logic (train_model(),_train_neural_network(),_train_sklearn_model()) and checkpoint managementmodel.pyfrom ~1,434 lines to ~800 lines and makeModelFactorythe single source of truth for model definitionsImpact
ModelFactory.register_model()andlist_models()become actually useful