Linear regression (pynance.learn.linreg)

pynance.learn.linreg.predict(features, model)[source]

Generate predictions from features and model.

New in version 0.5.0.

Parameters:

features : ndarray

Features from which to generate predictions

model : ndarray

Regression model.

Returns:

predicted : ndarray

Predictions generated from features using model.

pynance.learn.linreg.run(features, labels, regularization=0.0, constfeat=True)[source]

Run linear regression on the given data.

New in version 0.5.0.

If a regularization parameter is provided, this function is a simplification and specialization of ridge regression, as implemented in scikit-learn. Setting solver to ‘svd’ in sklearn.linear_model.Ridge and equating our regularization with their alpha will yield the same results.

Parameters:

features : ndarray

Features on which to run linear regression.

labels : ndarray

Labels for the given features. Multiple columns of labels are allowed.

regularization : float, optional

Regularization parameter. Defaults to 0.

constfeat : bool, optional

Whether or not the first column of features is the constant feature 1. If True, the first column will be excluded from regularization. Defaults to True.

Returns:

model : ndarray

Regression model for the given data.