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.
I found it :)
a = px.get_trendline_results(fig).px_fit_results.iloc[0].rsquared
that's it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With