December 2018
Beginner to intermediate
684 pages
21h 9m
English
We continue the price prediction example but now we binarize the outcome variable so that it takes on the value 1 whenever the 10-day return is positive and 0 otherwise; see the notebook logistic_regression.ipynb in the sub directory stock_price_prediction:
target = 'Returns10D'label = (y[target] > 0).astype(int).to_frame(target)
With this new categorical outcome variable, we can now train a logistic regression using the default L2 regularization. For logistic regression, the regularization is formulated inversely to linear regression: higher values for λ imply less regularization and vice versa. We evaluate 11 parameter values using cross validation as follows:
nfolds = 250Cs = np.logspace(-