Skip to main content

Wraps sklearn linear_model regression functions to allow Drop1, Add1, and VIF calculations

Project description

SKLearn Linear Model Modification

This class should act exactly like sklearn linear model to solve regression problems with the benefit of being able to use drop1 and add1 based on AIC.

Installation

Run the following to install:

pip install sklearn_linear_model_modification

Usage

import pandas as pd
from sklearn_linear_model_modification import LinearRegression, Add1LinearRegression, Drop1LinearRegression
from sklearn_linear_model_modification import Lasso, Add1Lasso, Drop1Lasso
from sklearn_linear_model_modification import ElasticNet, Add1ElasticNet, Drop1ElasticNet
from sklearn_linear_model_modification import Ridge, Add1Ridge, Drop1Ridge

def load_Xy():
    data = load_boston()
    X = pd.DataFrame( data['data'], columns=data['feature_names'] )
    y = data['target']
    return X, y



X, y = load_Xy()

lmod = Ridge()
lmod.fit(X, y)

lmod = Lasso()
lmod.fit(X, y)

lmod = ElasticNet()
lmod.fit(X, y)

lmod = LinearRegression()
lmod.fit(X, y)


lmod = Add1Ridge()
lmod.fit(X, y)

lmod = Add1Lasso()
lmod.fit(X, y)

lmod = Add1ElasticNet()
lmod.fit(X, y)

lmod = Add1LinearRegression()
lmod.fit(X, y)

lmod = Drop1Ridge()
lmod.fit(X, y)

lmod = Drop1Lasso()
lmod.fit(X, y)

lmod = Drop1ElasticNet()
lmod.fit(X, y)

lmod = Drop1LinearRegression()
lmod.fit(X, y)

Development sklearn_linear_model_modification

To install sklearn_linear_model_modification, along with the tools you need to develop and run tests, run the following in your virtualend:

$ pip install -e .[dev]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page