# prepare model and set parameters
svr_model = SVR(kernel='linear', C=1e3)
# fit your model with the training set
svr_model.fit(TRAINIG_SET, TAINING_LABEL)
#predict on a test set
svr_model.predict(TEST_SET)
所以,这里的问题是你有一套训练集,但没有测试集来测量模型的准确性 . 唯一的解决方案是使用训练集的一部分作为测试集 ex: 80% for train 20% for test
EDIT
希望我很好地理解你的意见 .
因此,您想预测火车组中最后一小时的下一个标签,以下是您想要的示例:
from sklearn.svm import SVR
import random
import numpy as np
'''
data: the train set, 24 elements
label: label for each time
'''
data = [10+y for y in [x * .5 for x in range(24)]]
label = [z for z in [random.random()]*24]
# reshaping the train set and the label ...
DATA = np.array([data]).T
LABEL = np.array(label)
# Declaring model and fitting it
clf = SVR(kernel='linear', C=1e3)
clf.fit(DATA, LABEL)
# predict the next label
to_predict = DATA[DATA[23,0]+0.5]
print clf.predict(to_predict)
>> 0.94407674
1 回答
你应该这样使用
SVR
:所以,这里的问题是你有一套训练集,但没有测试集来测量模型的准确性 . 唯一的解决方案是使用训练集的一部分作为测试集
ex: 80% for train 20% for test
EDIT
希望我很好地理解你的意见 .
因此,您想预测火车组中最后一小时的下一个标签,以下是您想要的示例: