When doing data preprocessing, excess rate of return is a proper term in the stock industry, which refers to the rate of return that is greater than that of risk-free investment. In my country, the rate of return of risk-free investment is bank time deposits.
Developed by pycharm + anaconda3.6, the third-party libraries involved include pandas, numpy, matplotlib, and skllearn.
Some are also written in the basic function comments of the Python code. The function implemented by these three parts of the code is to read the data and preprocess the data. I have arranged the most primitive data in an excel sheet, and put the parameters of all stocks in the first month in an excel.
#6
print('Select model')
if para.method == 'SVM':
model = svm.SVC (kernel = para.svm_kernel, C = para.svm_c)
print('Model selection is SVM')
#7 Use the trained model to put it into the training set and the validation set to predict, to adjust the parameters
print('Model starts training')
if para.method == 'SVM':
model.fit(X_train, y_train)
y_pred_train = model.predict(X_train)
y_score_train = model.decision_function(X_train)
y_pred_cv = model.predict(X_cv)
y_score_cv = model.decision_function(X_cv)
print('Model training ended')
This is also easier to understand, that is, to select the svm module in the sklearn library to train the data. The svm model is integrated and packaged.
Now that the stock fall and rise prediction model is trained, then run the trained model on the test set.
General arrays cannot operate with numbers, but after processing ordinary arrays with np.array(), they become numpy arrays, which have a broadcast attribute and can operate directly with numbers. This line of python code is to decrement each element in the array by 1.