def get_X_y(self):
"""Builds an X, y feature/target pair from the data.
:returns: a tuple of (feature matrix, labels)
"""
# X
X = np.array(self.data[self.features])
X = scale(X)
# y
stock_change = np.array(self.data["stock_p_change"])
sp500_change = np.array(self.data["sp500_p_change"])
is_above_threshold = stock_change-sp500_change > self.threshold
y = is_above_threshold.astype('i')
return (X, y)
评论列表
文章目录