Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

feature selection python

from sklearn.feature_selection import VarianceThreshold
sel = VarianceThreshold(threshold=(0.95 * (1 - 0.95)))
sel_=sel.fit_transform(features)
Comment

feature selection python

You can change the direction using the direction parameter
direction{'forward', 'backward'}, default='forward'

>>> from sklearn.feature_selection import SequentialFeatureSelector
>>> from sklearn.neighbors import KNeighborsClassifier
>>> from sklearn.datasets import load_iris
>>> X, y = load_iris(return_X_y=True)
>>> knn = KNeighborsClassifier(n_neighbors=3)
>>> sfs = SequentialFeatureSelector(knn, n_features_to_select=3)
>>> sfs.fit(X, y)
SequentialFeatureSelector(estimator=KNeighborsClassifier(n_neighbors=3),
                          n_features_to_select=3)
>>> sfs.get_support()
array([ True, False,  True,  True])
>>> sfs.transform(X).shape
(150, 3)
Comment

PREVIOUS NEXT
Code Example
Python :: zip multiple lists 
Python :: python extract list from string 
Python :: for in python 
Python :: tweepy aut code 
Python :: add image pptx python 
Python :: python index of string 
Python :: how to use dictionaries in python 
Python :: python openpyxl cell width 
Python :: count elements in columns pandas 
Python :: python csv writer row by row 
Python :: print random integers python 
Python :: python tkinter cursor types 
Python :: How to check if a given string is a palindrome, in Python? 
Python :: prolog avg of list 
Python :: python square a number 
Python :: python module install a whl 
Python :: sum of list in python 
Python :: how to select rows with specific values in pandas 
Python :: simple jwt 
Python :: make poetry env 
Python :: how to merge between two columns and make a new one in pandas dataframe 
Python :: clone keras model 
Python :: python script restart 
Python :: python namespace 
Python :: python random array 
Python :: python check if string in string 
Python :: Copying a list using deepcopy() in python 
Python :: streamlit bold 
Python :: python elapsed time module 
Python :: pandas read to a csv file 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =