File: loess.rst

package info (click to toggle)
python-altair 5.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,952 kB
  • sloc: python: 25,649; sh: 14; makefile: 5
file content (41 lines) | stat: -rw-r--r-- 1,027 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
.. currentmodule:: altair

.. _user-guide-loess-transform:

LOESS
~~~~~
The LOESS transform (LOcally Estimated Scatterplot Smoothing) uses a
locally-estimated regression  to produce a trend line.
LOESS performs a sequence of local weighted regressions over a sliding
window of nearest-neighbor points. For standard parametric regression options,
see the :ref:`user-guide-regression-transform`.

Here is an example of using LOESS to smooth samples from a Gaussian random walk:

.. altair-plot::

   import altair as alt
   import pandas as pd
   import numpy as np

   np.random.seed(42)

   df = pd.DataFrame({
       'x': range(100),
       'y': np.random.randn(100).cumsum()
   })

   chart = alt.Chart(df).mark_point().encode(
       x='x',
       y='y'
   )

   chart + chart.transform_loess('x', 'y').mark_line()


Transform Options
^^^^^^^^^^^^^^^^^
The :meth:`~Chart.transform_loess` method is built on the
:class:`~LoessTransform` class, which has the following options:

.. altair-object-table:: altair.LoessTransform