训练和测试拆分后的数据索引
Index of Data after train and test split
伙计们,我是数据科学的新手 Python。我正在研究回归问题。我的问题是,当我尝试绘制目标变量的测试部分时,我得到了奇怪的绘图类型
from sklearn.model_selection import train_test_split
train_input, test_input, train_target, test_target =
train_test_split(features, target, test_size = 0.25, random_state = 42)
# Remove the labels from the dataset
plt.xlim(0,100)
plt.plot(test_target , 'g');
是因为 test_target.. 附加了随机索引吗?
我怎样才能得到这样的连续曲线
如果数据索引有问题,则使用:
df_train = df_train.reset_index()
如果你想重置并将其设置为 df 的另一列让我们说 "A" 然后做:
df_train = df_train.reset_index().set_index('A')
伙计们,我是数据科学的新手 Python。我正在研究回归问题。我的问题是,当我尝试绘制目标变量的测试部分时,我得到了奇怪的绘图类型
from sklearn.model_selection import train_test_split
train_input, test_input, train_target, test_target =
train_test_split(features, target, test_size = 0.25, random_state = 42)
# Remove the labels from the dataset
plt.xlim(0,100)
plt.plot(test_target , 'g');
是因为 test_target.. 附加了随机索引吗?
我怎样才能得到这样的连续曲线
如果数据索引有问题,则使用:
df_train = df_train.reset_index()
如果你想重置并将其设置为 df 的另一列让我们说 "A" 然后做:
df_train = df_train.reset_index().set_index('A')