我有两个系列:range(20)和range(0,40,2)。 我试图用pyflux.GARCH预测下一个值。 我期望第一个系列的结果是:20 21 22 23 24 我期望第二个系列的结果是:39 41 43 45 47
对于第一个我得到:222.604657 233.956042 245.563616 256.949521 268.109078 对于第二个,我得到:889.877348 934.948259 980.351219 1025.914387 1071.470460
这些不是我期望的预测值。
有人可以解释结果吗?
代码:
var inputtedUID = "0"; // doesn't matter
db.foo.aggregate(
[
// This $match finds the docs with our input UID:
{$match: {"uid": inputtedUID }}
// ... and the $addFields/$filter will strip out those entries in contacts where contacts.uid does NOT exist. We wish we could use {cond: {$zz.name: {$exists:true} }} but
// we cannot use $exists here so we need the convoluted $ifNull treatment. Note we
// overwrite the original contacts with the filtered contacts:
,{$addFields: {contacts: {$filter: {
input: "$contacts",
as: "zz",
cond: {$ne: [ {$ifNull:["$$zz.uid",null]}, null]}
}}
}}
,{$limit:1} // just get 1 like findOne()
]);
show(c);
{
"_id" : 0,
"uid" : 0,
"contacts" : [
{
"uid" : "buzz",
"n" : 1
},
{
"uid" : "dave",
"n" : 2
}
]
}
结果:
import pandas as pd
import pyflux as pf
df = pd.DataFrame(
{
'a': list(range(20)),
'b': list(range(0, 40, 2))
}
)
model = pf.GARCH(df, target='a', p=1, q=1)
model.fit()
predictions_a = model.predict(5)
print(predictions_a)
model = pf.GARCH(df, target='b', p=1, q=1)
model.fit()
predictions_b = model.predict(5)
print(predictions_b)