I am trying to get the Altair regression line parameters in a variable, but I can't quite figure out how to do it.
I managed to show them on my plot, but I can't access them in any other way.
I read this post, but after trying to use the altair_transform package, i get the following error:
NotImplementedError: transform of type <class 'altair.vegalite.v4.schema.core.RegressionTransform'>
Is there any other way of getting these values?
Thanks in advance!
Here is the code from the post I linked above:
import altair as alt
import pandas as pd
import numpy as np
import altair_transform
np.random.seed(42)
x = np.linspace(0, 10)
y = x - 5 + np.random.randn(len(x))
df = pd.DataFrame({'x': x, 'y': y})
chart = alt.Chart(df).mark_point().encode(
x='x',
y='y'
)
b = chart.transform_regression('x', 'y', params=True).mark_line()
print(altair_transform.extract_data(b))
My version of altair_transform is 0.3.0.dev0