Skip to main content

automate_LinearRegression

  • This package is specific to build a Linear Regeression model on the dataset passed as the parameter with its features as well as label to be regressed against. And as such, it is presumed that the analysis and the feature engineering has already been done on the dataset.

  • This package will standardize the data via StandardScaler() so that all features can be on the same scale and obviously so that the model optimization could increase.

  • Accuracy of the model built by this package is computed using adjusted R-squared metric.

  • User will also have the flexibility of building the model with regularization modes viz. Lasso (L1, Ridge (L2) and ElasticNet and to compare their accuracies accordingly.

An Example of How to use:

from automate_LinearRegression import automate_linReg
import pandas as pd
import seaborn as sns

# loading a famous 'Iris' dataset from the seaborn module
df = sns.load_dataset("iris")
df.head()
sepal_length sepal_width petal_length petal_width species
0 5.1 3.5 1.4 0.2 setosa
1 4.9 3.0 1.4 0.2 setosa
2 4.7 3.2 1.3 0.2 setosa
3 4.6 3.1 1.5 0.2 setosa
4 5.0 3.6 1.4 0.2 setosa
# Assuming `sepal_width` is our label

features = df.drop(columns=['sepal_width', 'species'])
label = df['sepal_width']
features.head()
sepal_length petal_length petal_width
0 5.1 1.4 0.2
1 4.9 1.4 0.2
2 4.7 1.3 0.2
3 4.6 1.5 0.2
4 5.0 1.4 0.2
label.head()
0    3.5
1    3.0
2    3.2
3    3.1
4    3.6
Name: sepal_width, dtype: float64
# buidling a linear model

model = automate_linReg(dataframe=df, features=features, label=label)
model.split(testSize=0.2, random_state=1000)
model.build()
INFO 2022-10-22 18:57:26,717 logger activated!
INFO 2022-10-22 18:57:26,722 Model building initiates..
INFO 2022-10-22 18:57:26,731 data split is done successfully!
INFO 2022-10-22 18:57:26,733 readying the model...
INFO 2022-10-22 18:57:26,739 Model executed succesfully!
# Having a look at the training score 

model.accuracy(test_score=False)
INFO 2022-10-22 18:57:26,763 The Regression model appears to be 53.34250683053611% accurate.

53.343
# Accuracy on the test dataset

model.accuracy()
INFO 2022-10-22 18:57:26,779 The Regression model appears to be 49.19831544294634% accurate.

49.198
# Saving model in your local system

model.save(fileName='regression_model')
INFO 2022-10-22 18:57:26,795 The Regression model is saved at D:\ sucessfully!

Let's put some regularization on the top of our model:

# building the model with ElasticNet regularization

model.buildLasso()
INFO 2022-10-22 18:57:26,997 readying the L1 Model...
INFO 2022-10-22 18:57:27,000 L1 Model executed!
# training score

model.accuracy(mode='L1', test_score=False)
INFO 2022-10-22 18:57:27,018 The L1 model appears to be 53.317792187590655% accurate.

53.318
# test score

model.accuracy(mode='L1')
INFO 2022-10-22 18:57:27,051 The L1 model appears to be 49.1579197226467% accurate.

49.158

Note: Do not mind the accuracies, this dataset is just taken for the sake of an example.

Metadata

Release files for automate-LinearRegression 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for automate-LinearRegression 1.0.1
File Size Uploaded Provenance
automate_LinearRegression-1.0.1.tar.gz 8.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for automate-LinearRegression 1.0.1
File Interpreter ABI Platform
automate_LinearRegression-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.6 kB

Release files / automate_LinearRegression-1.0.1.tar.gz

Download URL automate_LinearRegression-1.0.1.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6fa054289977194216e0666c2a85d10f1792d21cd91042252178e6952358dc4c
BLAKE2b-256 checksum
How to use checksums
88c5971d9e0f6832ead14eebcd2c8c785a8c82123c2b7e2865f65834327787e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / automate_LinearRegression-1.0.1-py3-none-any.whl

Download URL automate_LinearRegression-1.0.1-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1b71db1e09959cd92244e9be2421d1bb54ce94aa6bace53e180a683561a03275
BLAKE2b-256 checksum
How to use checksums
a2ee48b5b781ee2870dad46e0200782a331a63eafe5fb2833d9631326e7b3d45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Security for automate-LinearRegression 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page