This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sklearn.datasets import make_regression | |
| from sklearn.feature_selection import SelectKBest | |
| from sklearn.feature_selection import f_regression | |
| import pandas as pd | |
| # generate dataset | |
| X, y = make_regression(n_samples=100, n_features=50, n_informative=10) | |
| #assign column names | |
| col_list = ['col_' + str(x) for x in range(0,50)] | |
| #create a dataframe table |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sklearn.datasets import make_classification | |
| from sklearn.feature_selection import SelectKBest | |
| from sklearn.feature_selection import f_classif | |
| import pandas as pd | |
| # generate dataset | |
| X, y = make_classification(n_samples=100, n_features=50, n_informative=10) | |
| #assign column names | |
| col_list = ['col_' + str(x) for x in range(0,50)] | |
| #create a dataframe table |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sklearn.feature_selection import SelectKBest | |
| from sklearn.feature_selection import chi2 | |
| import pandas as pd | |
| #import raw data, data can be found in Github directory | |
| #https://github.com/jackty9/Feature_Selection_in_Python/blob/master/car_data.csv | |
| df = pd.read_csv("car_data.csv") | |
| X = df1.iloc[:,0:5] | |
| X = pd.get_dummies(X) | |
| y = df1.iloc[:,-1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sklearn.feature_selection import SelectKBest | |
| from sklearn.feature_selection import mutual_info_classif | |
| import pandas as pd | |
| #import raw data, data can be found in Github directory | |
| #https://github.com/jackty9/Feature_Selection_in_Python/blob/master/car_data.csv | |
| df1 = pd.read_csv("car_data.csv") | |
| X = df1.iloc[:,0:5] | |
| X = pd.get_dummies(X) | |
| y = df1.iloc[:,-1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Load needed libraries | |
| from sklearn.datasets import load_boston | |
| from sklearn.feature_selection import RFE | |
| from sklearn.linear_model import LinearRegression | |
| import pandas as pd | |
| import numpy as np | |
| # load_boston() sklearn dataset to boston | |
| boston = load_boston() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Load needed libraries | |
| from sklearn.datasets import load_boston | |
| from mlxtend.feature_selection import SequentialFeatureSelector as SFS | |
| from sklearn.linear_model import LinearRegression | |
| import pandas as pd | |
| import numpy as np | |
| # load_boston() sklearn dataset to boston | |
| boston = load_boston() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Load needed libraries | |
| from sklearn.datasets import load_boston | |
| from mlxtend.feature_selection import SequentialFeatureSelector as SFS | |
| from sklearn.linear_model import LinearRegression | |
| import pandas as pd | |
| import numpy as np | |
| # load_boston() sklearn dataset to boston | |
| boston = load_boston() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Load needed libraries | |
| from mlxtend.feature_selection import SequentialFeatureSelector as SFS | |
| from mlxtend.plotting import plot_sequential_feature_selection as plot_sfs | |
| from sklearn.linear_model import LinearRegression | |
| from sklearn.datasets import load_boston | |
| import matplotlib.pyplot as plt | |
| #import and prepare data | |
| boston = load_boston() | |
| X, y = boston.data, boston.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #PART 1 | |
| # import random undersampling and other necessary libraries | |
| from collections import Counter | |
| from imblearn.under_sampling import RandomUnderSampler | |
| from sklearn.model_selection import train_test_split | |
| import pandas as pd | |
| import numpy as np | |
| import warnings | |
| warnings.simplefilter(action='ignore', category=FutureWarning) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #PART 1 | |
| # import SMOTE oversampling and other necessary libraries | |
| from collections import Counter | |
| from imblearn.over_sampling import SMOTE | |
| from sklearn.model_selection import train_test_split | |
| import pandas as pd | |
| import numpy as np | |
| import warnings | |
| warnings.simplefilter(action='ignore', category=FutureWarning) |
OlderNewer