[scikit-learn] Support Vector Regression

James Melenkevitz jmmelen at yahoo.com
Thu May 24 14:43:37 EDT 2018


I have an SVR model that uses custom kernel as follows:
1)
sgk = dual_laplace_gaussian_swarm(ss)
svr_cust_sig = SVR(kernel=sgk, C=C_Value, epsilon = epsilon_value)
svr_fit = svr_cust_sig.fit(X, y) 
#X is an array shape is [93, 24]  where each row is a time in the columns are variables for the model at each time 
#y is an array of the value that the model should fit shape of [93,]

#I can do the following without any error 
yp = svr_cust_sig.predict(X) 
#This gives predictions for the times and variables in X

#If I attempt this
yy = svr_cust_sig.predict(X[0:1])#I get the error: "ValueError: X.shape[1] = 1 should be equal to 93, the number of samples at training time"  

#The code above is based on code in http://scikit-learn.org/stable/tutorial/basic/tutorial.html

2) To get code that can give new predictions without error I need to do the following:Use data I have and do the "fit" with X as in 1) above
numsteps =93 XR = np.zeros(( numsteps*2, 24)) 
#I set the first half of XR to be the same data that is in X#then set the second half of XR to be that same as the first half
XR[numsteps:, :] = XR[:numsteps,:]
#I then set the values in XR[numsteps, :] to be the row for the data I want a prediction for#and get the prediction from 

ypp = svr_fit.predict(XR[numsteps:, :]) #second half same size as X above with only the first row being different
#this gives results (when tested with known value for the prediction) that with some calls give the correct prediction but if I make the#call multiple times I get results that can differ by 10%.  

My questions are:1) Is it OK to get predictions the way I'm doing this?2) If yes, then why do predictions on the same data inputs differ at times by 10%3) Why didn't my initial call "yy = svr_cust_sig.predict(X[0:1])" work and gave the error: "ValueError: X.shape[1] = 1 should be equal to 93, the number of samples at training time"4) Is there a better way for me to get predictions out of the model

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20180524/68d4529d/attachment.html>


More information about the scikit-learn mailing list