Skip to content

Commit

Permalink
Trendline results summary
Browse files Browse the repository at this point in the history
s2t2 committed Jan 2, 2025
1 parent 73e7fdb commit 10d17e3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion docs/notes/dataviz/trendlines.qmd
Original file line number Diff line number Diff line change
@@ -71,8 +71,17 @@ Under the hood, `plotly` uses the `statsmodels` package to calculate the trend,

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.

Linear regression is simple and interpretable but can be overly restrictive when the real-world data follows a more complex, non-linear pattern.
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:

```{python}
from plotly.express import get_trendline_results
results = get_trendline_results(fig)
print(results.px_fit_results.iloc[0].summary())
```


Linear regression is simple and interpretable but can be overly restrictive when the real-world data follows a more complex, non-linear pattern.

## Non-linear Trends

0 comments on commit 10d17e3

Please sign in to comment.