Overview
TheExperimentDesigner uses Gemini 3 to design machine learning experiments based on data profiles, previous results, and user constraints. It maintains conversation context for Thought Signature continuity and provides intelligent fallbacks when the API is unavailable.
Key Features
- Hypothesis-driven experiment design
- Learns from previous experiment results
- Parses and respects user constraints from Markdown
- Maintains conversation context across iterations
- Intelligent fallback when Gemini fails
- Filters template-managed parameters to prevent duplicates
Class Definition
Constructor
Shared
GeminiClient instance for API calls. Sharing the same client across cognitive components preserves conversation history and enables Thought Signature continuity.Methods
design_experiment
Design the next experiment based on data profile and historical results.Parameters
Profile of the dataset from
DataProfiler, containing:n_rows: Number of rowsn_columns: Number of columnsnumeric_columns: List of numeric column namescategorical_columns: List of categorical column namestarget_column: Name of target columntarget_type: Type of target (numeric/categorical)missing_values: Dictionary of column names to missing value countstarget_stats: Optional statistics about the target variable
List of previous experiment results. Each
ExperimentResult contains metrics, model type, hypothesis, and success status.Type of ML task. Must be either
"classification" or "regression".Optional user constraints as Markdown text. Can include:
- Preferred/avoided models
- Primary metric preferences
- Preprocessing hints
- Termination rules
Current iteration number in the experiment loop.
Returns
Experiment specification ready for code generation, containing:
experiment_name(str): Descriptive name for the experimenthypothesis(str): What is being tested and whymodel_type(str): sklearn model class name (e.g., “RandomForestRegressor”)model_params(dict): Model hyperparameters (template-managed params filtered out)preprocessing(PreprocessingConfig): Preprocessing configurationreasoning(str): Detailed explanation of design choices
parse_constraints
Parse Markdown constraints text into structured configuration.Parameters
Raw Markdown text containing user constraints. Supports sections like:
## Metrics: Primary metric specification## Models: Preferred/avoided models## Preprocessing: Preprocessing hints## Termination: Termination rules
Returns
Structured constraints object containing:
primary_metric(Optional[str]): Primary metric namepreferred_models(list[str]): List of preferred model typesavoided_models(list[str]): List of models to avoidpreprocessing_hints(list[str]): Preprocessing suggestionstermination_rules(dict): Termination conditionsraw_text(str): Original constraint text
select_primary_metric
Select the primary metric based on task type and constraints.Parameters
Type of ML task:
"classification" or "regression".Parsed constraints that may include a primary metric preference.
Returns
Primary metric name. Defaults to:
"rmse"for regression tasks"f1"for classification tasks
get_design_count
Get the number of experiments designed so far.Returns
The total number of experiments designed by this instance.
get_parsed_constraints
Get the parsed constraints if available.Returns
The parsed constraints object, or
None if no constraints have been parsed.Data Classes
ParsedConstraints
System Prompt
The designer uses a comprehensive system prompt that guides Gemini to:- Apply hypothesis-driven experimentation principles
- Learn from both successes and failures
- Consider data characteristics when selecting models
- Balance exploration vs exploitation
- Avoid repeating previous experiments
Available Models
Regression:- LinearRegression, Ridge, Lasso, ElasticNet
- RandomForestRegressor, GradientBoostingRegressor, DecisionTreeRegressor
- SVR, KNeighborsRegressor
- XGBRegressor, LGBMRegressor
- LogisticRegression, GaussianNB
- RandomForestClassifier, GradientBoostingClassifier, DecisionTreeClassifier
- SVC, KNeighborsClassifier
- XGBClassifier, LGBMClassifier
Preprocessing Options
- missing_values:
"drop","mean","median","mode","constant" - scaling:
"standard","minmax","none" - encoding:
"onehot","ordinal" - target_transform:
"log","none"(regression only)
Usage Examples
Basic Experiment Design
With User Constraints
Iterative Design Loop
Parsing Constraints
Accessing Parsed Constraints
Fallback Handling
Template-Managed Parameters
The following parameters are automatically managed by Jinja2 templates and are filtered out frommodel_params to prevent duplicate keyword arguments:
random_staten_jobsverbosemax_iter(for certain models)probabilityverbositynthreadnum_threads
See Also
- GeminiClient - Underlying API client
- ResultsAnalyzer - Analyzes experiment results
- HypothesisGenerator - Generates testable hypotheses
- DataProfiler - Generates data profiles for design input