【发布时间】:2016-06-29 11:30:27
【问题描述】:
我正在尝试应用未来的选择。问题是使用整个数据帧会引发内存错误。所以我决定削减我的数据框以便能够应用使用下一个未来的选择:
# this is original dataframes
X_full = df_train[df_train.columns[0:size]] # 76000(rows)*300(cols)
y_full = df_train[[len(df_train.columns)-1]] # 76000(rows)*1(col)
y_full 包含 0 和 1,数字 1 低于 5%。所有其他列仅包含数字,但我们不知道它们的意思。
#this is way, I reduce the number of rows to 10%
test_frac = 0.10
count = len(X_full)
X = X_full.iloc[-int(count*test_frac):]
y = y_full.iloc[-int(count*test_frac):]
#Then I use Linear models penalized with the L1 norm to reduce the dimensionality of the data
lsvc = LinearSVC(C=0.01, penalty="l1", dual=False).fit(X, y)
model = SelectFromModel(lsvc, prefit=True)
X_new = model.transform(X)
print "X_new.shape", X_new.shape
print X_new
问题是我需要获取已删除的列列表,以便从原始数据框中删除它们。我该怎么做?
【问题讨论】:
-
你能告诉我们更多关于 rhe 数据集的信息吗?
标签: python python-2.7 machine-learning scikit-learn dataframe