Skip to content

Commit 10d17e3

Browse files
committed
Trendline results summary
1 parent 73e7fdb commit 10d17e3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

docs/notes/dataviz/trendlines.qmd

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,17 @@ Under the hood, `plotly` uses the `statsmodels` package to calculate the trend,
7171

7272
A linear trend assumes that there is a straight-line relationship between the independent and dependent variables. In the context of US GDP data, a linear trend suggests that GDP changes at a constant rate over time. When applying linear regression, the goal is to find the best-fit line that minimizes the residuals (differences between the predicted and actual values) under the assumption that the underlying relationship is linear.
7373

74-
Linear regression is simple and interpretable but can be overly restrictive when the real-world data follows a more complex, non-linear pattern.
74+
For linear trends only, `plotly` provides access to the underlying regression results summary, to tell us more about how well the trend line fits the data:
75+
76+
```{python}
77+
from plotly.express import get_trendline_results
7578
79+
results = get_trendline_results(fig)
80+
print(results.px_fit_results.iloc[0].summary())
81+
```
82+
83+
84+
Linear regression is simple and interpretable but can be overly restrictive when the real-world data follows a more complex, non-linear pattern.
7685

7786
## Non-linear Trends
7887

0 commit comments

Comments
 (0)