@@ -2322,9 +2322,7 @@ def classifier_test_cli(
2322
2322
output_raster_probability : OUTPUT_FILE_OPTION ,
2323
2323
output_raster_classified : OUTPUT_FILE_OPTION ,
2324
2324
classification_threshold : float = 0.5 ,
2325
- validation_metrics : Annotated [List [ClassifierMetrics ], typer .Option (case_sensitive = False )] = [
2326
- ClassifierMetrics .accuracy
2327
- ],
2325
+ test_metrics : Annotated [List [ClassifierMetrics ], typer .Option (case_sensitive = False )] = [ClassifierMetrics .accuracy ],
2328
2326
):
2329
2327
"""Test trained machine learning classifier model by predicting and scoring."""
2330
2328
from eis_toolkit .evaluation .scoring import score_predictions
@@ -2343,8 +2341,8 @@ def classifier_test_cli(
2343
2341
predictions , reference_profile ["height" ], reference_profile ["width" ], nodata_mask
2344
2342
)
2345
2343
2346
- metrics_dict = score_predictions (y , predictions , validation_metrics )
2347
- json_str = json .dumps (metrics_dict )
2344
+ metrics_dict = score_predictions (y , predictions , test_metrics )
2345
+ # json_str = json.dumps(metrics_dict)
2348
2346
typer .echo ("Progress: 80%" )
2349
2347
2350
2348
out_profile = reference_profile .copy ()
@@ -2355,8 +2353,13 @@ def classifier_test_cli(
2355
2353
with rasterio .open (output_raster_classified , "w" , ** out_profile ) as dst :
2356
2354
dst .write (predictions_reshaped , 1 )
2357
2355
2358
- typer .echo ("Progress: 100%" )
2359
- typer .echo (f"Results: { json_str } " )
2356
+ typer .echo ("Progress: 100%\n " )
2357
+ # typer.echo(f"Results:")
2358
+
2359
+ for key , value in metrics_dict .items ():
2360
+ typer .echo (f"{ key } : { value } " )
2361
+
2362
+ typer .echo ("\n " )
2360
2363
2361
2364
typer .echo (
2362
2365
(
@@ -2373,7 +2376,7 @@ def regressor_test_cli(
2373
2376
target_labels : INPUT_FILE_OPTION ,
2374
2377
model_file : INPUT_FILE_OPTION ,
2375
2378
output_raster : OUTPUT_FILE_OPTION ,
2376
- validation_metrics : Annotated [List [RegressorMetrics ], typer .Option (case_sensitive = False )] = [RegressorMetrics .mse ],
2379
+ test_metrics : Annotated [List [RegressorMetrics ], typer .Option (case_sensitive = False )] = [RegressorMetrics .mse ],
2377
2380
):
2378
2381
"""Test trained machine learning regressor model by predicting and scoring."""
2379
2382
from eis_toolkit .evaluation .scoring import score_predictions
@@ -2385,23 +2388,27 @@ def regressor_test_cli(
2385
2388
2386
2389
model = load_model (model_file )
2387
2390
predictions = predict_regressor (X , model )
2388
- metrics_dict = score_predictions (y , predictions , validation_metrics )
2391
+ metrics_dict = score_predictions (y , predictions , test_metrics )
2389
2392
predictions_reshaped = reshape_predictions (
2390
2393
predictions , reference_profile ["height" ], reference_profile ["width" ], nodata_mask
2391
2394
)
2392
-
2393
2395
typer .echo ("Progress: 80%" )
2394
2396
2395
- json_str = json .dumps (metrics_dict )
2397
+ # json_str = json.dumps(metrics_dict)
2396
2398
2397
2399
out_profile = reference_profile .copy ()
2398
2400
out_profile .update ({"count" : 1 , "dtype" : np .float32 })
2399
2401
2400
2402
with rasterio .open (output_raster , "w" , ** out_profile ) as dst :
2401
2403
dst .write (predictions_reshaped , 1 )
2402
2404
2403
- typer .echo ("Progress: 100%" )
2404
- typer .echo (f"Results: { json_str } " )
2405
+ typer .echo ("Progress: 100%\n " )
2406
+ # typer.echo("Results: ")
2407
+
2408
+ for key , value in metrics_dict .items ():
2409
+ typer .echo (f"{ key } : { value } " )
2410
+
2411
+ typer .echo ("\n " )
2405
2412
2406
2413
typer .echo (f"Testing regressor model completed, writing raster to { output_raster } ." )
2407
2414
0 commit comments