【发布时间】:2015-05-24 16:52:10
【问题描述】:
使用 Scikit learn,基本思想(例如,使用回归)是在拟合模型后,在给定数据向量“x”的情况下预测一些“y”。典型代码如下所示(改编自 here):
from sklearn.svm import SVR
import numpy as np
n_samples, n_features = 10, 5
np.random.seed(0)
y = np.random.randn(n_samples)
X = np.random.randn(n_samples, n_features)
clf = SVR(C=1.0, epsilon=0.2)
clf.fit(X[:-1], y[:-1])
prediction = clf.predict(X[-1])
print 'prediction:', prediction[0]
print 'actual:', y[-1]
我的问题是:是否可以在给定“x”和“y”的情况下拟合某个模型(也许不是 SVR),然后在给定“y”的情况下预测“x”。换句话说,是这样的:
clf = someCLF()
clf.fit(x[:-1], y[:-1])
prediction = clf.predict(y[-1])
#where predict would return the data vector that could produce y[-1]
【问题讨论】:
标签: python machine-learning scikit-learn regression