You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
159 lines
6.5 KiB
159 lines
6.5 KiB
"""
|
|
This type stub file was generated by pyright.
|
|
"""
|
|
|
|
from ._decorators import _deprecate_positional_args
|
|
|
|
"""Plotting functions for linear models (broadly construed)."""
|
|
_has_statsmodels = ...
|
|
__all__ = ["lmplot", "regplot", "residplot"]
|
|
class _LinearPlotter:
|
|
"""Base class for plotting relational data in tidy format.
|
|
|
|
To get anything useful done you'll have to inherit from this, but setup
|
|
code that can be abstracted out should be put here.
|
|
|
|
"""
|
|
def establish_variables(self, data, **kws): # -> None:
|
|
"""Extract variables from data or use directly."""
|
|
...
|
|
|
|
def dropna(self, *vars): # -> None:
|
|
"""Remove observations with missing data."""
|
|
...
|
|
|
|
def plot(self, ax):
|
|
...
|
|
|
|
|
|
|
|
class _RegressionPlotter(_LinearPlotter):
|
|
"""Plotter for numeric independent variables with regression model.
|
|
|
|
This does the computations and drawing for the `regplot` function, and
|
|
is thus also used indirectly by `lmplot`.
|
|
"""
|
|
def __init__(self, x, y, data=..., x_estimator=..., x_bins=..., x_ci=..., scatter=..., fit_reg=..., ci=..., n_boot=..., units=..., seed=..., order=..., logistic=..., lowess=..., robust=..., logx=..., x_partial=..., y_partial=..., truncate=..., dropna=..., x_jitter=..., y_jitter=..., color=..., label=...) -> None:
|
|
...
|
|
|
|
@property
|
|
def scatter_data(self): # -> tuple[ndarray[Any, dtype[Unknown]] | NDArray[floating[Any]], ndarray[Any, dtype[Unknown]] | NDArray[floating[Any]]]:
|
|
"""Data where each observation is a point."""
|
|
...
|
|
|
|
@property
|
|
def estimate_data(self): # -> tuple[list[Any], list[Unknown], list[Unknown]]:
|
|
"""Data with a point estimate and CI for each discrete x value."""
|
|
...
|
|
|
|
def fit_regression(self, ax=..., x_range=..., grid=...): # -> tuple[Unknown, Unknown | NDArray[float64] | Any, Unknown | None]:
|
|
"""Fit the regression model."""
|
|
...
|
|
|
|
def fit_fast(self, grid): # -> tuple[Any, None] | tuple[Any, Any]:
|
|
"""Low-level regression and prediction using linear algebra."""
|
|
...
|
|
|
|
def fit_poly(self, grid, order): # -> tuple[Unknown, None] | tuple[Unknown, NDArray[Unknown]]:
|
|
"""Regression using numpy polyfit for higher-order trends."""
|
|
...
|
|
|
|
def fit_statsmodels(self, grid, model, **kwargs): # -> tuple[Unknown | NDArray[float64], None] | tuple[Unknown | NDArray[float64], NDArray[Unknown]]:
|
|
"""More general regression function using statsmodels objects."""
|
|
...
|
|
|
|
def fit_lowess(self): # -> tuple[Unknown, Unknown]:
|
|
"""Fit a locally-weighted regression, which returns its own grid."""
|
|
...
|
|
|
|
def fit_logx(self, grid): # -> tuple[Any, None] | tuple[Any, Any]:
|
|
"""Fit the model in log-space."""
|
|
...
|
|
|
|
def bin_predictor(self, bins): # -> tuple[Any, Any]:
|
|
"""Discretize a predictor by assigning value to closest bin."""
|
|
...
|
|
|
|
def regress_out(self, a, b): # -> ndarray[Any, dtype[Unknown]]:
|
|
"""Regress b from a keeping a's original mean."""
|
|
...
|
|
|
|
def plot(self, ax, scatter_kws, line_kws): # -> None:
|
|
"""Draw the full plot."""
|
|
...
|
|
|
|
def scatterplot(self, ax, kws): # -> None:
|
|
"""Draw the data."""
|
|
...
|
|
|
|
def lineplot(self, ax, kws): # -> None:
|
|
"""Draw the model."""
|
|
...
|
|
|
|
|
|
|
|
_regression_docs = ...
|
|
@_deprecate_positional_args
|
|
def lmplot(*, x=..., y=..., data=..., hue=..., col=..., row=..., palette=..., col_wrap=..., height=..., aspect=..., markers=..., sharex=..., sharey=..., hue_order=..., col_order=..., row_order=..., legend=..., legend_out=..., x_estimator=..., x_bins=..., x_ci=..., scatter=..., fit_reg=..., ci=..., n_boot=..., units=..., seed=..., order=..., logistic=..., lowess=..., robust=..., logx=..., x_partial=..., y_partial=..., truncate=..., x_jitter=..., y_jitter=..., scatter_kws=..., line_kws=..., size=...): # -> FacetGrid:
|
|
...
|
|
|
|
@_deprecate_positional_args
|
|
def regplot(*, x=..., y=..., data=..., x_estimator=..., x_bins=..., x_ci=..., scatter=..., fit_reg=..., ci=..., n_boot=..., units=..., seed=..., order=..., logistic=..., lowess=..., robust=..., logx=..., x_partial=..., y_partial=..., truncate=..., dropna=..., x_jitter=..., y_jitter=..., label=..., color=..., marker=..., scatter_kws=..., line_kws=..., ax=...): # -> Axes:
|
|
...
|
|
|
|
@_deprecate_positional_args
|
|
def residplot(*, x=..., y=..., data=..., lowess=..., x_partial=..., y_partial=..., order=..., robust=..., dropna=..., label=..., color=..., scatter_kws=..., line_kws=..., ax=...): # -> Axes:
|
|
"""Plot the residuals of a linear regression.
|
|
|
|
This function will regress y on x (possibly as a robust or polynomial
|
|
regression) and then draw a scatterplot of the residuals. You can
|
|
optionally fit a lowess smoother to the residual plot, which can
|
|
help in determining if there is structure to the residuals.
|
|
|
|
Parameters
|
|
----------
|
|
x : vector or string
|
|
Data or column name in `data` for the predictor variable.
|
|
y : vector or string
|
|
Data or column name in `data` for the response variable.
|
|
data : DataFrame, optional
|
|
DataFrame to use if `x` and `y` are column names.
|
|
lowess : boolean, optional
|
|
Fit a lowess smoother to the residual scatterplot.
|
|
{x, y}_partial : matrix or string(s) , optional
|
|
Matrix with same first dimension as `x`, or column name(s) in `data`.
|
|
These variables are treated as confounding and are removed from
|
|
the `x` or `y` variables before plotting.
|
|
order : int, optional
|
|
Order of the polynomial to fit when calculating the residuals.
|
|
robust : boolean, optional
|
|
Fit a robust linear regression when calculating the residuals.
|
|
dropna : boolean, optional
|
|
If True, ignore observations with missing data when fitting and
|
|
plotting.
|
|
label : string, optional
|
|
Label that will be used in any plot legends.
|
|
color : matplotlib color, optional
|
|
Color to use for all elements of the plot.
|
|
{scatter, line}_kws : dictionaries, optional
|
|
Additional keyword arguments passed to scatter() and plot() for drawing
|
|
the components of the plot.
|
|
ax : matplotlib axis, optional
|
|
Plot into this axis, otherwise grab the current axis or make a new
|
|
one if not existing.
|
|
|
|
Returns
|
|
-------
|
|
ax: matplotlib axes
|
|
Axes with the regression plot.
|
|
|
|
See Also
|
|
--------
|
|
regplot : Plot a simple linear regression model.
|
|
jointplot : Draw a :func:`residplot` with univariate marginal distributions
|
|
(when used with ``kind="resid"``).
|
|
|
|
"""
|
|
...
|
|
|