Uğur Özalp
Uğur Özalp

Reputation: 1

ANOVA Feature Selection

I got a warning message when trying to use the feature selection. I think something is missing or wrong here, but I can't figure out what it is.

Thanks in advance for the help.

from sklearn.feature_selection import SelectKBest, f_classif 
selector = SelectKBest(f_classif, k=30) 
selector.fit(X, y)  

cols = selector.get_support(indices=True) 
cols  

X_selected = X.iloc[:,cols]
/Users/.../anaconda3/lib/python3.11/site-packages/sklearn/feature_selection/_univariate_selection.py:112: UserWarning: Features [237 238 239 240 242 243 244 246 247 248 249 250 251 252 253 254 255 256
 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 275 276
 278 378 381 384 385 386 387 389 391 392 393 394 395 396 397 398 399 400
 401 402 403 404 405 406 407 408 409 410 411 412 413] are constant.
  warnings.warn("Features %s are constant." % constant_features_idx, UserWarning)
/Users/.../anaconda3/lib/python3.11/site-packages/sklearn/feature_selection/_univariate_selection.py:113: RuntimeWarning: invalid value encountered in divide
  f = msb / msw

Upvotes: 0

Views: 50

Answers (0)

Related Questions