question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to find regression parameters

See original GitHub issue

Working off the transform_regression example, can you please show me how to find the coef array when you pass parms=True as an argument?

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

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()
chart +  b

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jakevdpcommented, Aug 27, 2020

From above:

Install it with:

pip install git+https://github.com/altair-viz/altair-transform.git
1reaction
jakevdpcommented, Jul 13, 2020

Transforms are computed in the frontend, so the results are generally not directly available in Python.

The altair_transform package has some experimental support for extracting them, however.

Install it with:

pip install git+https://github.com/altair-viz/altair-transform.git

And then extract the parameters this way:

import altair_transform
print(altair_transform.extract_data(b))
#                                        coef  rSquared
# 0  [-4.935556907797029, 0.9420166005081777]  0.903174
Read more comments on GitHub >

github_iconTop Results From Across the Web

Regression Coefficients - Formula, Definition, Examples
The steps to calculate the regression coefficients are as follows: Substitute values to find a (coefficient of X). Substitute values for b (constant...
Read more >
Linear Regression: Simple Steps, Video. Find Equation ...
How to Find the Regression Coefficient. A regression coefficient is the same thing as the slope of the line of the regression equation....
Read more >
Regression Formula | Step by Step Calculation (with Examples)
It is represented by equation Y is equal to aX plus b where Y is the dependent variable, a is the slope of...
Read more >
How to Calculate Regression Coefficient - Sciencing
The independent variable is usually called "x" and the dependent variable is usually called "y." The goal of the technique is to identify...
Read more >
Simple Linear Regression: Interpreting Model Parameters
A look at the interpretation of the parameters (beta_0, beta_1, sigma^2), and their corresponding estimates in simple linear regression.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found