我正在 NodeJS 中使用 Neaptic 学习 ML NEAT。
我正在制作一个基本的天气预报模型。本质上预测下一个温度。
我有这种类型的数据,我想提供过去 3 天的样本,其中包含 2 个特征日期和 avgTemp。
{
"inputs": [
{
"AvgTemperature": "47.9",
"Date": "1/1/2020"
},
{
"AvgTemperature": "47.8",
"Date": "1/2/2020"
},
{
"AvgTemperature": "48.8",
"Date": "1/3/2020"
},
],
"expectedOutput": {
"AvgTemperature": "46.9"
}
},
]
我不确定网络期望什么格式。
这些是我的一些想法:
genom.activate([
[47.9, 1/1/2020],
[50, 1/2/2020],
[55, 1/3/2020]
])
with a network setup of maybe
/*
const inputLen = 3 //To represent 3 samples
//or
const inputLen = 2 //To represent 2 features
const inputLen = [3,2] //To represent 3 samples and 2 features
*/
const outputLen = 1
this.neat = new Neat(
inputLen,
outputLen,
null,
{
elitism: 5,
popsize: 50,
mutationRate: 0.3,
network: new architect.Random(inputLen, 3, outputLen),
}
);
或者我认为最有可能的是,我需要扁平化输入。如果是这样的话,我应该如何压平它,就像下面的任何一个一样。如果我确实需要将其展平,我假设是 features*samples=inputLen 它如何通过日期知道哪些是不同的功能,哪些是相似的,或者这并不重要,它只会找到自己的方式来关联时间和日期。
genom.activate([date, temp, date, temp ...])
//or
genom.activate([date, date, temp, temp ...])
---- 旁注 ----
来自官方存储库:
// this network learns the XOR gate (through neuro-evolution)
var network = new Network(2,1);
var trainingSet = [
{ input: [0,0], output: [0] },
{ input: [0,1], output: [1] },
{ input: [1,0], output: [1] },
{ input: [1,1], output: [0] }
];
await network.evolve(trainingSet, {
equal: true,
error: 0.03
});
这意味着样本的数据类型预计为:
let trainingSet: { input: number[], output: number[] }[];
这是一个对象数组,其中包含属性
input
的数字列表,以及属性 output
的数字列表。