Neataptic Machine-Learning - Flatten inputs or nested & based on features or samples

15 Views Asked by At

I am learning ML NEAT with Neataptic within NodeJS.

I am making a basic weather prediction model. Essentially predict the next temperature.

I have this type of data, where I want to give samples of the last 3 days with 2 features date and 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"
        }
      },
    ]

I am unsure on what format the network is expecting.

these are a few of the ideas I had:

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),
                }
            );


or which I think is most likely, I need to flatten the inputs. And if that's the case, how should I flatten it, like either of the below. and if I do need to flatten it I assume the would be the features*samples=inputLen And how will it know which are different features and which are like via the date, or does that not matter it will just find its own way of related the temps and dates.

genom.activate([date, temp, date, temp ...])
//or 
genom.activate([date, date, temp, temp ...])  

---- SIDE NOTES ----

  • Yes I will be normalizing my input values
  • I have about 600 blocks of samples I will be feeding it.
  • I did google this and looked on this site. Though I couldn't find much on neataptic spesfically and on wether its required to flatten the data, more so I found just how to .flatten() an array.
1

There are 1 best solutions below

0
Guilherme A C Zaluchi On

From the official repository:

// 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
});

This implies the data type for the samples is expected to be:

let trainingSet: { input: number[], output: number[] }[];

Which is an array of objects with a list of numbers for the property input, and a list of numbers for the property output.