OReg
- class omoment.OReg(mean_x: Number = nan, mean_y: Number = nan, var_x: Number = nan, var_y: Number = nan, cov: Number = nan, weight: Number = 0, handling_invalid: HandlingInvalid = HandlingInvalid.Drop)
Bases:
OBase
Online estimator of univariate regression of two variables.
Represents means, variances, covariance and total weight of a part of data. Two OReg objects can be added together to produce correct estimates for the combined dataset. Moments and weight are stored using __slots__ to allow for lightweight objects that can be used in fairly large quantities even in pandas DataFrame (however they are still Pythonm objects, not numpy types).
By default, invalid values are omitted in calculation; variances and covariance are based on ddof = 0, in agreement with numpy std method.
- property alpha: float
- property beta: float
- classmethod compute(x: Number | ndarray | Series, y: Number | ndarray | Series, w: Number | ndarray | Series | None = None, handling_invalid: HandlingInvalid = HandlingInvalid.Drop) OReg
Shortcut for initialization of an empty object and its update based on data.
- property corr: float
- cov
- mean_x
- mean_y
- classmethod of_frame(data: DataFrame, x: str, y: str, w: str | None = None, handling_invalid: HandlingInvalid = HandlingInvalid.Drop) OReg
Convenience function for calculation OReg of pandas DataFrame.
- Parameters:
data – input DataFrame
x – name of column with x variable
y – name of column with y variable
w – name of column with weights (optional)
handling_invalid – How to handle invalid values in calculation [‘drop’, ‘keep’, ‘raise’], default value ‘drop’. Provided either as enum or its string representation.
- Returns:
OReg object
- static of_groupby(data: pd.DataFrame, g: str | List[str], x: str, y: str, w: str | None = None, handling_invalid: HandlingInvalid = HandlingInvalid.Drop) pd.Series[OReg]
- property std_dev_x: float
- property std_dev_y: float
- update(x: Number | ndarray | Series, y: Number | ndarray | Series, w: Number | ndarray | Series | None = None, handling_invalid: HandlingInvalid = HandlingInvalid.Drop) OReg
Update the object based on new data. Subclasses have to implement how to aggregate the new data.
- var_x
- var_y
- weight