I am trying to plot the decision boundary for extreme learning machine but I am getting the error "To RESHAPE the number of elements must not change"

2 visualizaciones (últimos 30 días)
Can you please tell where i am doing the mistake in the below code.
data = load('example1.txt');
% Split the data into training and testing sets
train_data = data(1:30,1:2); % Features
train_label = data(1:30,3); % Labels
test_data = data(31:51,1:2);
test_label = data(31:51,3);
% Train ELM model
elm = elm_train([train_data train_label] , 1, 7, 'sigmoid')
% Create a grid of points covering the space of the input data
minX1 = min(data(:,1));
maxX1 = max(data(:,1));
minX2 = min(data(:,2));
maxX2 = max(data(:,2));
[x1Grid, x2Grid] = meshgrid(minX1:0.1:maxX1, minX2:0.1:maxX2);
% Predict the output for the grid of points
yGrid = elm_predict([test_data test_label]);
hold on;
scatter(test_data( test_label==0,1), test_data(test_label==0,2), 'b', 'o');
scatter(test_data(test_label==1,1), test_data(test_label==1,2), 'r', 'x');
y1=reshape(yGrid, size(x1Grid))
% Plot the decision boundary
contour(x1Grid, x2Grid, y1, [0.5, 0.5],'linewidth',1);

Respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by