error with Input data sizes in using sim

2 Ansichten (letzte 30 Tage)
arash rad
arash rad am 10 Okt. 2022
Kommentiert: arash rad am 11 Okt. 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 Kommentare
Benjamin Thompson
Benjamin Thompson am 10 Okt. 2022
Can you attach your CSV file so the Community can run your example code?
arash rad
arash rad am 11 Okt. 2022
Hi Benjamin
I attached my data

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by