November 2019
Beginner
394 pages
10h 31m
English
Support vector machine (SVM) is a supervised machine learning method. As previously seen, we can use this method for regression, but also for classification. The principle of this algorithm is to find a hyper plan that separates the data into two classes.
Let's have a look at the following code, that implements the same:
# Fit the modelsvc=SVC()svc.fit(X_train, Y_train)# Forecast valuegoog_data['Predicted_Signal']=svc.predict(X)goog_data['GOOG_Returns']=np.log(goog_data['Close']/ goog_data['Close'].shift(1))cum_goog_return=calculate_return(goog_data,split_value=len(X_train),symbol='GOOG')cum_strategy_return= calculate_strategy_return(goog_data,split_value=len(X_train))plot_chart(cum_goog_return, cum_strategy_return,symbol='GOOG') ...