Add support for recursive components in DashAI Models#368
Merged
Conversation
…initialization and improved handling of nested models and optimizable parameters
…Model by removing unnecessary transformation methods
…ulations for consistency
…ed hyperparameter handling
…n HyperOptOptimizer for improved parameter handling
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the parameter extraction and optimization process to support nested model components with optimizable parameters. The main changes include restructuring how models and their sub-components are instantiated, and updating optimizers to work with the new parameter structure.
Key Changes:
- Refactored
ModelFactoryto recursively instantiate nested DashAI components and collect optimizable parameter references - Updated optimizers (Optuna, Hyperopt) to work with list-based parameter structure instead of dictionary
- Simplified recursive optimizer detection functions in the frontend to work with any nested structure
- Fixed placeholder value for
lower_boundin SVC max_iter parameter
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| DashAI/back/models/model_factory.py | Complete refactor of parameter extraction to recursively build nested models and collect optimizable refs as list of tuples |
| DashAI/back/optimizers/optuna_optimizer.py | Updated to iterate over list-based parameters structure instead of dict |
| DashAI/back/optimizers/hyperopt_optimizer.py | Updated search space generation and objective function for new parameter format |
| DashAI/back/optimizers/base_optimizer.py | Updated importance_plot to destructure tuple-based parameters |
| DashAI/back/models/scikit_learn/bow_text_classification_model.py | Removed manual parameter transformation logic, simplified to direct assignment |
| DashAI/back/models/scikit_learn/svc.py | Fixed max_iter lower_bound from 1 to -1 |
| DashAI/front/src/utils/schema.js | Added unused import and refactored optimizer check functions for better recursion |
| DashAI/front/src/pages/results/components/ResultsDetailsLayout.jsx | Updated to use boolean return from checkIfHaveOptimazers instead of count |
Comments suppressed due to low confidence (3)
DashAI/back/models/model_factory.py:14
- The docstring indicates
optimizable_parametersis a dict, but the refactored code now returns a list of tuples (object reference, parameter name, bounds). The documentation should be updated to reflect this change.
optimizable_parameters : dict
DashAI/back/optimizers/optuna_optimizer.py:114
- After optimization, the code sets parameters directly on the best_model using parameter names from best_params. However, with nested models, the parameters may belong to sub-models, not the top-level model. This should iterate over self.parameters to get the correct object reference for each parameter:
for obj, key, _ in self.parameters: if key in best_params: setattr(obj, key, best_params[key])
for hyperparameter, value in best_params.items():
setattr(best_model, hyperparameter, value)
DashAI/front/src/utils/schema.js:3
- Unused import isObject.
import { isObject } from "formik";
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cristian-tamblay
approved these changes
Nov 10, 2025
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.
This pull request introduces significant improvements to how model parameters are extracted, instantiated, and optimized across the backend and frontend of DashAI. The main focus is on refactoring the model factory to support recursive instantiation of nested components and optimizable parameters, as well as updating optimizers and frontend logic to work with the new parameter structure.
Backend Model Factory and Optimizer Refactor:
Recursive extraction and instantiation of model parameters:
ModelFactoryclass now recursively instantiates models and their subcomponents from a parameter dictionary, collecting references to all optimizable parameters (object, name, bounds). This enables seamless optimization of both top-level and nested parameters. (DashAI/back/models/model_factory.py)_extract_parametersand_process_parammethods have been rewritten to support nested DashAI components, optimizable parameters, and primitive values, ensuring all optimizable parameters are correctly bound to their respective objects.Optimizer updates for new parameter format:
optuna_optimizer, andhyperopt_optimizernow expect parameters as a list of tuples (object, parameter name, bounds) and set parameter values directly on the correct objects during optimization. This change supports nested models and improves parameter importance calculation. (DashAI/back/optimizers/base_optimizer.py,DashAI/back/optimizers/optuna_optimizer.py,DashAI/back/optimizers/hyperopt_optimizer.py)Frontend Improvements:
checkIfHaveOptimazersnow recursively checks for optimizable parameters in nested objects, enabling accurate UI logic for enabling/disabling tabs related to hyperparameter optimization. (DashAI/front/src/utils/schema.js,DashAI/front/src/pages/results/components/ResultsDetailsLayout.jsx)Other Notable Changes:
DashAI/back/models/scikit_learn/bow_text_classification_model.py)