Effacer les filtres
Effacer les filtres

error with Input data sizes in using sim

1 vue (au cours des 30 derniers jours)
arash rad
arash rad le 10 Oct 2022
Commenté : arash rad le 11 Oct 2022
Hi i write this code
but i have a problem when i use sim it has an error that "Input data sizes do not match net.inputs{1}.size."
I am new to ANN and i don't know what should i do
clc;clear all ; close all
%% Import Data
filename = 'zafar_queue.csv'; % abc = name of data file
flow_data = csv2struct(filename);
%% Variables
Y = flow_data.nVehContrib;
data = Y';
periods = flow_data.begin;
dates = seconds(periods);
trn = floor(0.95*(length(data)));
data_train = data(1:trn);
data_test = data(trn+1:end);
trnX = data_train(1:end);
trnY = data_train(1:end);
trndates = dates(1:trn);
testX = data_test(1:end);
testY = data_test(1:end);
testdates = dates(trn+1:end);
%% Neural (Model)
net = newfit(trnX',trnY',30);
[net,tr] = train(net, trnX', trnY');
%% Forecast and error
load_forecast = sim(net,testX)';
% err = testY - load_forecast;
% errp = (abs(err)./testY)*100;
%
% mae = mean(testY, load_forecast);
% mape = mean(errp);
%% Figures
h2 = figure;
plot(testY,'DisplayName','testY');hold on;plot(load_forecast,'DisplayName','forecast');hold off;
ylabel('Load');
h3 = figure;
plot(testdates, testY - load_forecast);
xlabel('Date'); ylabel('Error');
  2 commentaires
Benjamin Thompson
Benjamin Thompson le 10 Oct 2022
Can you attach your CSV file so the Community can run your example code?
arash rad
arash rad le 11 Oct 2022
Hi Benjamin
I attached my data

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Statistics and Machine Learning Toolbox dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by