Skip to main content

For selecting the optimal features using the stepwise algorithm

Project description

Selection Method

Purpose of the Package

  • Selection Method is a Python module which implements a statistical learning method for selecting features (for predicting a target variable) in a given dataset.

Features

  • Collection of Feature Selection Methods
    • Forward Stepwise
    • Backward Stepwise

Getting Started

The package can be found on pypi hence you can install it using pip

Installation

pip install Selection_Method 

Usage

Forward_Stepwise

>>> from Selection_Method.Forward_Stepwise import forward_stepwise
>>>
>>> #initialize forward_stepwise object, and your already created regression model object.
>>> selection = forward_stepwise(linear_model)
>>>
>>> #input your already split train and test datasets into the .select_features() method, and select the optimal features using the stepwise algorithm.
>>> final_list, final_score = selection.select_features(x_train, x_test, y_train, y_test)

Example

>>> import pandas as pd
>>> from sklearn.linear_model import LinearRegression
>>> from Selection_Method.Forward_Stepwise import forward_stepwise
>>>
>>> #define your linear regression object
>>> linear_model = LinearRegression()
>>>
>>> #import your preferred dataset
>>> crime_xtrain = pd.read_csv('x_train.csv')
>>> crime_xtest = pd.read_csv('x_test.csv')
>>> crime_ytrain = pd.read_csv('y_train.csv')
>>> crime_ytest = pd.read_csv('y_test.csv')
>>>
>>> #initialize forward_stepwise object
>>> selection = forward_stepwise(linear_model) 
>>>
>>> #input your train and test dataset into the .select_features() method and execute.
>>> final_list, final_score = selection.select_features(x_train, x_test, y_train, y_test)
>>> print(forward_list, f_score)
['pctKids2Par', 'pctWhite', 'houseVacant', 'State', 'pctUrban', 'pctWorkMom18', 'persPoverty', 'pctRetire', 'pct1624', 'pctEmployMfg', 'ownHousLowQ', 'pct2Par', 'medOwnCostPctWO', 'numForeignBorn', 'medRentpctHousInc', 'pctEmploy', 'pctWwage', 'pctHousWOplumb', 'pctSameState5', 'otherPerCap', 'pctHousWOphone', 'pctPoverty', 'persPerOccupHous', 'persPerOwnOccup', 'persPerFam', 'rentMed', 'persHomeless', 'NAperCap'] 0.6315059907414283

Contribution

This Project is open to contribution and collaboration. Feel free to connect.

Author

  • Main Maintainer: Michael Dubem Igbomezie

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

Selection_Method-0.0.3.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Selection_Method-0.0.3-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file Selection_Method-0.0.3.tar.gz.

File metadata

  • Download URL: Selection_Method-0.0.3.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for Selection_Method-0.0.3.tar.gz
Algorithm Hash digest
SHA256 c015cde9a487eabba03e83fd53856fb66b4e61026024dfa7dcfccb84545fa5e9
MD5 c5ed7e33299039f18450f126c44001f4
BLAKE2b-256 b95b159d95e04a9a6d469502298f6198038abbfc77e64775bd90eadb2638f422

See more details on using hashes here.

File details

Details for the file Selection_Method-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for Selection_Method-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 71888b9e965b1febd835b614ac4639856f54dd5aea08d89c1bfd14094aed8404
MD5 796b9748ac50d10e75ede5e3ca30af9d
BLAKE2b-256 295866133790d3e13d4b4fd432aebf68e037aaa70835d48cbd09c7dd52ed8519

See more details on using hashes here.

Supported by

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