we will now look at various ways of selecting features including statistical and model based techniques by using some sample datasets threshold-based methods this is filter based feature selection strategywhere you can use some form of cut-off or thresholding for limiting the total number of features during feature selection thresholds can be of various forms some of them can be used during the feature engineering process itselfwhere you can specify threshold parameters simple example of this would be to limit feature terms in the bag of words modelwhich we used for text based feature engineering earlier the scikit-learn framework provides parameters like min_df and max_ df which can be used to specify thresholds for ignoring terms which have document frequency above and below user specified thresholds the following snippet depicts way to do this in [ ]from sklearn feature_extraction text import countvectorizer cv countvectorizer(min_df= max_df= max_features= cv out[ ]countvectorizer(analyzer='word'binary=falsedecode_error='strict'dtype=encoding='utf- 'input='content'lowercase=truemax_df= max_features= min_df= ngram_range=( )preprocessor=nonestop_words=nonestrip_accents=nonetoken_pattern='(? )\\ \\ \\ +\\ 'tokenizer=nonevocabulary=nonethis basically builds count vectorizer which ignores feature terms which occur in less than of the total corpus and also ignores terms which occur in more than of the total corpus besides this we also put hard limit of maximum features in the feature set another way of using thresholds is to use variance based thresholding where features having low variance (below user-specified thresholdare removed this signifies that we want to remove features that have values that are more or less constant across all the observations in our datasets we can apply this to our pokemon datasetwhich we used earlier in this first we convert the generation feature to categorical feature as follows in [ ]df pd read_csv('datasets/pokemon csv'poke_gen pd get_dummies(df['generation']poke_gen head(out[ ]gen gen gen gen gen gen nextwe want to remove features from the one hot encoded features where the variance is less than we can do this using the following snippet