Reputation: 1
I'm using ml5js to train a model to predict the number of items that will be sold at a bakery given these fields:
day_of_week
next_holiday
days_until_next_holiday
avg_cloud_cover
avg_precip
avg_temp
highest_cloud_cover
highest_precip
highest_temp
lowest_cloud_cover
lowest_precip
lowest_temp
I've trained the model, creating the three usual files:
However, when I import the model and go to make a prediction using the model using a test input like this:
const input = {
day_of_week: "Thursday",
next_holiday: "Canada Day",
days_until_next_holiday: 10,
avg_cloud_cover: 0,
avg_precip: 0,
avg_temp: 0,
highest_cloud_cover: 0,
highest_precip: 0,
highest_temp: 0,
lowest_cloud_cover: 0,
lowest_precip: 0,
lowest_temp: 0
}
I get this error:
Error: Error when checking : expected dense_Dense1_input to have shape [null,2134] but got array with shape [1,37].
I think I'm getting this error because I'm not formatting the input correctly. I normalized the data when making the model, so it created many new fields, all of which have a value of 0 or 1.
For example, of day_of_week, the start of model_meta.json looks like this:
{
"inputUnits":[2134],
"outputUnits":1,
"inputs":{
"day_of_week":{
"dtype":"string",
"min":0,
"max":1,
"uniqueValues":["Thursday","Wednesday","Tuesday","Monday","Sunday","Saturday","Friday"],
"legend":{"Thursday":[1,0,0,0,0,0,0],"Wednesday":[0,1,0,0,0,0,0],"Tuesday":[0,0,1,0,0,0,0],"Monday":[0,0,0,1,0,0,0],"Sunday":[0,0,0,0,1,0,0],"Saturday":[0,0,0,0,0,1,0],"Friday":[0,0,0,0,0,0,1]
}
},
...
I'm wondering if I need to format the input to not use strings for fields like day_of_week. But if so, I'm not sure what to replace it with.
Any assistance?
Upvotes: 0
Views: 21