在make_classification方法中,
X,y = make_classification(n_samples=10, n_features=8, n_informative=7, n_redundant=1, n_repeated=0 , n_classes=2,random_state=6)
关于n_redundant的
文档字符串的冗余特性的数量。这些特征作为信息特征的随机线性组合生成。关于n_repeated的文档字符串--从信息中随机抽取的重复特性的数量
选择features.
我的问题是:如何删除/突出显示冗余特性,它们的特点是什么。
附加的是所有特征之间的相关热图,这些特征在图像中是冗余的。
请帮帮忙。

发布于 2021-01-03 15:30:56
检查有多少独立列使用np.linalg.matrix_rank(X)
sympy.Matrix(X).rref()演示
生成数据集并检查独立列的数量(矩阵级别):
from sklearn.datasets import make_classification
from sympy import Matrix
X, _ = make_classification(
n_samples=10, n_features=8, n_redundant=2,random_state=6
)
np.linalg.matrix_rank(X, tol=1e-3)
# 6查找线性独立列的索引:
_, inds = Matrix(X).rref(iszerofunc=lambda x: abs(x)<1e-3)
inds
#(0, 1, 2, 3, 6, 7)删除相关列并检查矩阵级别(独立列的数值):
#linearly independent
X_independent = X[:,inds]
assert np.linalg.matrix_rank(X_independent, tol=1e-3) == X_independent.shape[1]https://stackoverflow.com/questions/65548856
复制相似问题