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"

3 次查看(过去 30 天)
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);

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by