在这里,我实现了方向对称性(DS)和平均绝对百分比误差(MAPE)作为函数
function mape( Y, Ypredict, indxtest)
smape = 0;
if isempty(indxtest)
for i = 1 :length(Y)
smape = smape + (abs((Ypredict(i) - Y(i))) / Y(i));
end
else
j = find(indxtest);
for i = 1 :length(j)
smape = smape + (abs((Ypredict(i) - Y(j(i)))) / Y((j(i))));
end
end
mape = smape * 100/length(Y)
end
-------------------------------------------------------
function ds( Y, Ypredict, indxtest)
sds = 0;
if isempty(indxtest)
for i = 2 :length(Y)
if (((Y(i)-Y(i-1))*(Ypredict(i)-Ypredict(i-1))) > 0)
sds = sds + 1;
end
end
else
j = find(indxtest);
for i = 2 :length(j)
if (((Y(j(i))-Y(j(i-1)))*(Ypredict((i))-Ypredict(i-1))) > 0)
sds = sds + 1;
end
end
end
ds = sds * 100/length(j)
end
虽然这对我来说很好,但如果有人帮助我改进它,无论是减少生产线的数量还是提高效率,我都将不胜感激。