Hei!

你是不是很威

8.特征选择

用过滤法对以下数据进行特征选择:

                             [[0,2,0,3],

                              [0,1,4,3],

                              [0,1,1,3]]

要求:

1、Variance Threshold(threshold =1.0)

2、将结果截图

 

答:

#删除低方差特征0-9
from sklearn.feature_selection import VarianceThreshold
import pandas as pd
import numpy as np

def test():
var = VarianceThreshold(threshold=1.0) #设置去掉方差为1 的列
data = var.fit_transform([[0, 2, 0, 3],

[0, 1, 4, 3],

[0, 1, 1, 3]]) #将数据带入
print(data)
return(data)

结果截图:

 

posted @ 2020-04-27 09:44  INacl  阅读(143)  评论(0编辑  收藏  举报