我正在使用Scikit Learn的线性回归模型来解释时间序列:
from sklearn import linear_model
import numpy as np
X = np.array([np.random.random(100), np.random.random(100)])
y = np.array(np.random.random(100))
regressor = linear_model.LinearRegression()
regressor.fit(X, y)
y_hat = regressor.predict(X)
我想交叉验证预测。据我所知,我不能使用sklearn的cross_val(如Kfold),因为它会随机分解结果,我需要按顺序折叠。例如,
data_set = [1 2 3 4 5 6 7 8 9 10]
# first train set
train = [1]
# first test set
test = [2 3 4 5 6 7 8 9 10]
#fit, predict, evaluate
# train set
train = [1 2]
# test set
test = [3 4 5 6 7 8 9 10]
#fit, predict, evaluate
...
# train set
train = [1 2 3 4 5 6 7 8]
# test set
test = [9 10]
#fit, predict, evaluate
是否可以使用sklearn进行此操作?
答案 0 :(得分:1)
这种折叠你不需要scikit。切片就足够了,例如:
<a href="#">test</a>
<a href="#">test</a>
<a id="noclick" href="#">test</a>
<a href="#">test</a>
<script>
$( "a" ).not( "#noclick" ).click(function(){
alert("clicked");
});
</script>