3

how can I extract R-squared value from the following summary():

import plotly.express as px
df = ...
fig = px.scatter(df, x="...", y="...", trendline="ols") 
a = px.get_trendline_results(fig).px_fit_results.iloc[0].summary()

I know how to extract coefficients of trendline with params:coef in the picture

print(fit_results.params)

but I need to extract R-squared value from the results to annotate it in static saved figs.

Marzie Gh
  • 121
  • 1
  • 8

1 Answers1

9

I found it :)

a = px.get_trendline_results(fig).px_fit_results.iloc[0].rsquared

that's it.

Marzie Gh
  • 121
  • 1
  • 8