2424
2525# Ensure output directories exist
2626script_dir = os .path .dirname (os .path .abspath (__file__ ))
27- output_dir = os .path .join (script_dir , '..' , 'doc' , 'images' )
28- ml_output_dir = os .path .join (output_dir , 'ml_functions' )
29- os .makedirs (output_dir , exist_ok = True )
30- os .makedirs (ml_output_dir , exist_ok = True )
27+ main_images_dir = os .path .join (script_dir , '..' , 'doc' , 'images' )
28+ ml_functions_dir = os .path .join (main_images_dir , 'ml_functions' )
29+ ml_detailed_dir = os .path .join (ml_functions_dir , 'detailed' )
30+ os .makedirs (main_images_dir , exist_ok = True )
31+ os .makedirs (ml_functions_dir , exist_ok = True )
32+ os .makedirs (ml_detailed_dir , exist_ok = True )
3133
3234# ML Function configurations with reduced parameter spaces for faster evaluation
3335ML_FUNCTION_CONFIGS = {
@@ -100,9 +102,9 @@ def generate_ml_plots():
100102 reduced_space = config ['reduced_search_space' ]
101103 ml_func = create_reduced_ml_function (func_class , reduced_space )
102104
103- # Create function-specific output directory
104- func_output_dir = os .path .join (ml_output_dir , ml_func ._name_ )
105- os .makedirs (func_output_dir , exist_ok = True )
105+ # Create function-specific detailed output directory
106+ func_detailed_dir = os .path .join (ml_detailed_dir , ml_func ._name_ )
107+ os .makedirs (func_detailed_dir , exist_ok = True )
106108
107109 print (f"Search space: { ml_func .search_space ()} " )
108110
@@ -116,13 +118,13 @@ def generate_ml_plots():
116118 title = f"{ ml_func .name } - { param1 } vs { param2 } "
117119 )
118120
119- # Save as image
120- output_path = os .path .join (func_output_dir , f"{ param1 } _vs_{ param2 } _heatmap.jpg" )
121- fig .write_image (output_path , format = "jpeg" , width = 900 , height = 700 )
121+ # Save detailed image
122+ detailed_path = os .path .join (func_detailed_dir , f"{ param1 } _vs_{ param2 } _heatmap.jpg" )
123+ fig .write_image (detailed_path , format = "jpeg" , width = 900 , height = 700 )
122124
123- # Also save to main images directory for README
124- main_output_path = os .path .join (output_dir , f"{ ml_func ._name_ } _{ param1 } _vs_{ param2 } _heatmap.jpg" )
125- fig .write_image (main_output_path , format = "jpeg" , width = 900 , height = 700 )
125+ # Save main image for README
126+ main_path = os .path .join (ml_functions_dir , f"{ ml_func ._name_ } _{ param1 } _vs_{ param2 } _heatmap.jpg" )
127+ fig .write_image (main_path , format = "jpeg" , width = 900 , height = 700 )
126128
127129 print (f" ✓ Saved { param1 } vs { param2 } heatmap" )
128130
@@ -136,21 +138,21 @@ def generate_ml_plots():
136138 title = f"{ ml_func .name } - Dataset vs { hyperparameter } "
137139 )
138140
139- # Save as image
140- output_path = os .path .join (func_output_dir , f"dataset_vs_{ hyperparameter } _analysis.jpg" )
141- fig .write_image (output_path , format = "jpeg" , width = 1000 , height = 700 )
141+ # Save detailed image
142+ detailed_path = os .path .join (func_detailed_dir , f"dataset_vs_{ hyperparameter } _analysis.jpg" )
143+ fig .write_image (detailed_path , format = "jpeg" , width = 1000 , height = 700 )
142144
143- # Also save to main images directory for README
144- main_output_path = os .path .join (output_dir , f"{ ml_func ._name_ } _dataset_vs_{ hyperparameter } _analysis.jpg" )
145- fig .write_image (main_output_path , format = "jpeg" , width = 1000 , height = 700 )
145+ # Save main image for README
146+ main_path = os .path .join (ml_functions_dir , f"{ ml_func ._name_ } _dataset_vs_{ hyperparameter } _analysis.jpg" )
147+ fig .write_image (main_path , format = "jpeg" , width = 1000 , height = 700 )
146148
147149 print (f" ✓ Saved dataset vs { hyperparameter } analysis" )
148150
149151 print (f"✓ Completed { func_name } analysis" )
150152
151153 print (f"\n ✓ ML plot generation complete! Images saved to:" )
152- print (f" - Individual function plots: { ml_output_dir } " )
153- print (f" - README plots: { output_dir } " )
154+ print (f" - Detailed function plots: { ml_detailed_dir } " )
155+ print (f" - README plots: { ml_functions_dir } " )
154156
155157def generate_sample_plots ():
156158 """Generate a few sample plots for testing."""
@@ -175,15 +177,15 @@ def reduced_search_space_method(**kwargs):
175177 ml_func , 'n_neighbors' , 'algorithm' ,
176178 title = "Sample: KNN Hyperparameter Analysis"
177179 )
178- fig1 .write_image (os .path .join (output_dir , "sample_knn_hyperparams.jpg" ),
180+ fig1 .write_image (os .path .join (ml_functions_dir , "sample_knn_hyperparams.jpg" ),
179181 format = "jpeg" , width = 900 , height = 700 )
180182
181183 print ("Creating sample dataset analysis plot..." )
182184 fig2 = plotly_dataset_hyperparameter_analysis (
183185 ml_func , 'n_neighbors' ,
184186 title = "Sample: Dataset vs n_neighbors"
185187 )
186- fig2 .write_image (os .path .join (output_dir , "sample_knn_datasets.jpg" ),
188+ fig2 .write_image (os .path .join (ml_functions_dir , "sample_knn_datasets.jpg" ),
187189 format = "jpeg" , width = 1000 , height = 700 )
188190
189191 print ("✓ Sample plots generated successfully!" )
0 commit comments