Other¶
Other modules
core¶
Main setup utilities.
- statwrap.core.use_all(line)¶
Load the sheets and then fpp modules.
- Parameters:
line (str) – Unused parameter retained for compatibility with IPython line magic.
- Return type:
None
Examples
Using this function in IPython:
%use_all
- statwrap.core.use_fpp(line)¶
Load the fpp module.
This imports functions that adhere to the conventions found in “Statistics” by Freedman, Pisani, and Purves.
- Parameters:
line (str) – Unused parameter retained for compatibility with IPython line magic.
- Return type:
None
Examples
Using this function in IPython:
%use_fpp
- statwrap.core.use_sheets(line)¶
Load the sheets module.
This imports functions that adhere to the conventions specific to Google Sheets.
- Parameters:
line (str) – Unused parameter retained for compatibility with IPython line magic.
- Return type:
None
Examples
Using this function in IPython:
%use_sheets
utils¶
These are utilities agnostic to specific conventions.
- class statwrap.utils.Formula(func)¶
This class is used to modify the display behavior of functions that have a mathematical formula.
- class statwrap.utils.Hyperplane(*coefficients)¶
Represents a hyperplane in a multidimensional space.
The hyperplane is represented by the equation form:
\[y = c_0 + c_1 x_1 + c_2 x_2 + \ldots + c_n x_n\]where c_i are the coefficients and x_i are the independent variables.
- Parameters:
*coefficients (float) – The coefficients defining the hyperplane. c_0 is the constant term, and c_1, c_2, …, c_n are the coefficients of the variables x_1, x_2, …, x_n.
- coefficients¶
An array holding the coefficients of the hyperplane.
- Type:
ndarray
Examples
>>> plane = Hyperplane(1, 1, 1) >>> plane(0, 1) 2
- class statwrap.utils.RegressionLine(y, x, results)¶
RegressionLine class extends Hyperplane to model a univariate regression line with given coefficients, input values (x), and target values (y).
- y¶
Target values.
- Type:
array-like
- x¶
Input values.
- Type:
array-like
- coefficients¶
Coefficients for the hyperplane.
- Type:
tuple
- residuals¶
Residuals of the regression.
- Type:
array-like
- predictions¶
Predicted values based on input x.
- Type:
array-like
- rms_error¶
Root Mean Square Error of the regression.
- Type:
float
- partial_regression_plot(show=True)¶
Shows a partial regression plot for each predictor variable.
- plot(ax=None, show=True, scatter=True, **kwargs)¶
Make a plot with regression line. Only works for simple linear regression.
- property predictions¶
Returns the predicted values based on input x.
- residual_plot(**kwargs)¶
Shows a scatter plot of x vs the residuals.
- property residuals¶
Returns the residuals of the regression.
- property results¶
Returns the StatsModels results object.
- property rms_error¶
Returns the Root Mean Square Error of the regression.
- scatter_plot(**kwargs)¶
Shows a scatter plot for the data.
- property x¶
Returns the input values.
- property y¶
Returns the target values.
- statwrap.utils.args_to_array(args)¶
When args is a tuple of scalars, this returns them in one array. When args’ first element is iterable, this returns the first element.
- statwrap.utils.find_first_external_link(s)¶
Find the first external link in a string formatted as LinkText <URL>.
Parameters: s (str): The string to search in.
Returns: (str, str): The first external link text and URL found, or (None, None) if no link is found.
- statwrap.utils.formula(func)¶
Decorator to modify the display behavior of functions with a mathematical formula. The function should have its formula inside a math block in its docstring.
- statwrap.utils.hyperlink(func)¶
Decorator to modify the display behavior of functions with a hyperlink. The function should have its hyperlink inside its docstring.
- statwrap.utils.modify_std(original_method)¶
Modifies a standard deviation method to adjust the ‘ddof’ parameter.
- Parameters:
original_method (callable) – The original method for standard deviation or variance that accepts a ‘ddof’ parameter.
- Returns:
A tuple containing two modified methods: - pop_std for population standard deviation (ddof=0) - sample_std for sample standard deviation (ddof=1).
- Return type:
tuple of callables
Notes
If the ‘ddof’ parameter is already provided when calling the returned methods, it will not be overwritten.