@@ -500,20 +500,6 @@ def create_plot(self, grid_area, clipped_gdf, title, out_fn,xmax=None, ymax=None
500500 ## Calculate MedAE percent
501501 MedAE_percent = (MedAE / int (grid_area )) * 100
502502
503- ## Theil-Sen Regressor
504- # Fit Theil-Sen Regressor
505- # Compute Theil-Sen estimator
506- ts_slope , ts_intercept , _ , _ = stats .theilslopes (Y , X )
507-
508- # Generate predictions
509- y_pred = ts_slope * X + ts_intercept
510-
511- # Equation of the line
512- ts_equation = f'Y = { ts_slope :.4f} * X + { ts_intercept :.2f} '
513-
514- # Plot Theil-Sen Line
515- plt .plot (X , y_pred , color = 'orange' , linestyle = '-' , label = 'Theil-Sen Line' )
516-
517503 # Set the figure size
518504 plt .figure (figsize = (8 , 6 ))
519505
@@ -532,6 +518,20 @@ def create_plot(self, grid_area, clipped_gdf, title, out_fn,xmax=None, ymax=None
532518 plt .plot ([0 , max (clipped_gdf ['ActualDef' ])], [0 , max (clipped_gdf ['ActualDef' ])], color = 'crimson' , linestyle = '--' ,
533519 label = '1:1 Line' )
534520
521+ ## Theil-Sen Regressor
522+ # Fit Theil-Sen Regressor
523+ # Compute Theil-Sen estimator
524+ ts_slope , ts_intercept , _ , _ = stats .theilslopes (Y , X )
525+
526+ # Generate predictions
527+ y_pred = ts_slope * X + ts_intercept
528+
529+ # Equation of the line
530+ ts_equation = f'Y = { ts_slope :.4f} * X + { ts_intercept :.2f} '
531+
532+ # Plot Theil-Sen Line
533+ plt .plot (X , y_pred , color = 'orange' , linestyle = '-' , label = 'Theil-Sen Line' )
534+
535535 # Add a legend in the bottom right position
536536 plt .legend (loc = 'lower right' )
537537
0 commit comments