Python 2.7 X=X的含义[:-forecast_out+;1]

Python 2.7 X=X的含义[:-forecast_out+;1],python-2.7,machine-learning,linear-regression,Python 2.7,Machine Learning,Linear Regression,股票价格数据的回归代码片段- forecast_col='Adj. Close' forecast_out=int(math.ceil(0.01*len(df))) df['label']=df[forecast_col].shift(-forecast_out) X=X[:-forecast_out+1] X=X[:-forecast\u out+1]的含义是什么?这是切片索引的情况,也使用负索引。这意味着将讨论X的最后一个forecast\u out+1元素。比如说, >>&

股票价格数据的回归代码片段-

forecast_col='Adj. Close'
forecast_out=int(math.ceil(0.01*len(df)))
df['label']=df[forecast_col].shift(-forecast_out)

X=X[:-forecast_out+1]

X=X[:-forecast\u out+1]的含义是什么?

这是切片索引的情况,也使用负索引。这意味着将讨论
X
的最后一个
forecast\u out+1
元素。比如说,

>>> my_list = [1, 2, 3, 4, 5]
>>> my_list[:-2]
[1, 2, 3]