Question 28
consider the below code :
keep following symbols in mind:
- >>>: Represents input code
- # : Represents comment in a code
- ... : Represents code continuation
- Without any symbols at the beginning of a line then it is output of just above input line of code.
- arrow pointing towards right is code continuation to another line.
>>> from sklearn.feature_selection import SelectKBest, chi2>>> from sklearn.datasets import load_wine>>> X,y = load_wine(return_X_y=True,as_frame=True)>>> print(X.shape)(178, 13)
>>> print(X.columns)['alcohol', 'malic_acid', 'ash', 'alcalinity_of_ash', 'magnesium',↪ 'total_phenols', 'flavanoids', 'nonflavanoid_phenols',↪ 'proanthocyanins', 'color_intensity', 'hue',↪ 'od280/od315_of_diluted_wines', 'proline']
>>> skb = SelectKBest(chi2, k=3)>>> X_selected = skb.fit_transform(X, y)
>>> print(skb.scores_)[5.44, 28.06, 0.74, 29.38, 45.02, 15.62, 63.33, 1.81, 9.36, 109.01, 5.18,↪ 23.38, 16540.06]
>>> print(skb.pvalues_)[6.56e-02, 8.03e-07, 0.68, 4.16e-07, 1.66e-10, 4.05e-04, 1.76e-14, 0.40,↪ 9.24e-03, 2.12e-24, 0.074, 8.33e-06, 0]
>>> print(skb.pvalues_.argsort())[12, 9, 6, 4, 3, 1, 11, 5, 8, 0, 10, 7, 2]Which of the following feature(s) will be selected in X_selected from X ?
malic_acid
magnesium
flavanoids
proanthocyanins
color_intensity
proline