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
Release history Release notifications | RSS feed
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 hashes)
Built Distribution
Close
Hashes for Selection_Method-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71888b9e965b1febd835b614ac4639856f54dd5aea08d89c1bfd14094aed8404 |
|
MD5 | 796b9748ac50d10e75ede5e3ca30af9d |
|
BLAKE2b-256 | 295866133790d3e13d4b4fd432aebf68e037aaa70835d48cbd09c7dd52ed8519 |