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 :: os remove entire folder python 
Python :: conda install dash 
Python :: python for file in dir 
Python :: deleting all rows in pandas 
Python :: python install pylab 
Python :: split data validation python 
Python :: python how to count the lines in a file 
Python :: python add legend title 
Python :: django no such table 
Python :: how to make print float value without scientific notation in dataframe in jupyter notebook 
Python :: how to center plotly plot title 
Python :: rotation turtle python 
Python :: jupyter notebook plot larger 
Python :: sns figsize 
Python :: python flip a coin 
Python :: python get full path 
Python :: How to convert number string or fraction to float 
Python :: factorial sequence code in python with while loops 
Python :: how to find python location in cmd 
Python :: turn list to string with commas python 
Python :: read_csv only certain columns 
Python :: how to check in which directory python in running 
Python :: python tkinter underline text 
Python :: find rows not equal to nan pandas 
Python :: what to do in python when you get pygame.Surface object is not callable 
Python :: convert pandas datetime to day, weekday, month 
Python :: falsy python 
Python :: add text to plot python 
Python :: plural name django 
Python :: count number of islands python 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =