verticapy.vDataFrame.regr¶
- vDataFrame.regr(columns: Annotated[str | list[str], 'STRING representing one column or a list of columns'] | None = None, method: Literal['avgx', 'avgy', 'count', 'intercept', 'r2', 'slope', 'sxx', 'sxy', 'syy', 'beta', 'alpha'] = 'r2', show: bool = True, chart: PlottingBase | TableSample | Axes | mFigure | Highchart | Highstock | Figure | None = None, **style_kwargs) PlottingBase | TableSample | Axes | mFigure | Highchart | Highstock | Figure¶
Calculates the regression matrix for the given vDataFrame. This matrix is essential in regression analysis, enabling the modeling of relationships between variables and predicting outcomes. It plays a crucial role in understanding how independent variables influence the dependent variable, which can be invaluable for various data analysis and modeling tasks.
Parameters¶
- columns: SQLColumns, optional
List of the vDataColumns names. If empty, all numerical vDataColumns are used.
method: str, optional
Method to use to compute the regression matrix.
- avgx:
Average of the independent expression in an expression pair.
- avgy:
Average of the dependent expression in an expression pair.
- count:
Count of all rows in an expression pair.
- alpha:
Intercept of the regression line determined by a set of expression pairs.
- r2:
Square of the correlation coefficient of a set of expression pairs.
- beta:
Slope of the regression line, determined by a set of expression pairs.
- sxx:
Sum of squares of the independent expression in an expression pair.
- sxy:
Sum of products of the independent expression multiplied by the dependent expression in an expression pair.
- syy:
Returns the sum of squares of the dependent expression in an expression pair.
- show: bool, optional
If set to True, the Plotting object is returned.
- chart: PlottingObject, optional
The chart object used to plot.
- **style_kwargs
Any optional parameter to pass to the plotting functions.
Returns¶
- obj
Plotting Object.
Examples¶
Import VerticaPy.
import verticapy as vp
Import numpy to create a random dataset.
import numpy as np
Generate a dataset using the following data.
N = 30 # Number of records data = vp.vDataFrame( { "score1": np.random.normal(5, 1, N), "score2": np.random.normal(8, 1.5, N), "score3": np.random.normal(10, 2, N), "score4": np.random.normal(14, 3, N), } )
Draw the regression matrix using the Beta coefficient.
data.regr(method = "beta")
Draw the regression matrix using the Alpha coefficient.
data.regr(method = "alpha")
Draw the regression matrix using the R2 correlation coefficient.
data.regr(method = "r2")
For more examples, please look at the Correlation Matrix page of the Chart Gallery. Those ones are related to correlation matrix, but the customization stays the same for the regression matrix.
See also
vDataFrame.corr(): Computes the correlation matrix.