0% found this document useful (0 votes)
4 views

Newral Networks-task

The project involves creating a MATLAB-based neural network to classify two sets of randomly generated points on a 2D plane into two classes. Students will generate data, prepare training and testing sets, build and train a neural network, and evaluate its performance using confusion matrices and decision boundary visualizations. The expected deliverables include a MATLAB script and a short report summarizing the results.

Uploaded by

peror23614
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Newral Networks-task

The project involves creating a MATLAB-based neural network to classify two sets of randomly generated points on a 2D plane into two classes. Students will generate data, prepare training and testing sets, build and train a neural network, and evaluate its performance using confusion matrices and decision boundary visualizations. The expected deliverables include a MATLAB script and a short report summarizing the results.

Uploaded by

peror23614
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Project Assignment: Classification of Simple Data Using a Neural Network

Objective:
The student is tasked with creating a MATLAB-based neural network to classify simple data into two
classes. The data will consist of two randomly generated sets of points on a 2D plane. The project
aims to demonstrate how a neural network functions and can be applied for classification tasks.

Task Description:

1. Generate Data:

o Generate two random sets of points on a 2D plane:

▪ Class 1: Points centered around (−2,−2)(-2, -2).

▪ Class 2: Points centered around (2,2)(2, 2).

o Add random noise to make the classes not perfectly separable.

2. Prepare Training Data:

o Split the data into a training set (70%) and a testing set (30%).

3. Build and Train a Neural Network:

o Create a simple neural network with:

▪ Input layer (2 inputs).

▪ One hidden layer (10 neurons, tansig activation).

▪ Output layer (1 neuron, logsig activation).

o Use the train function to train the network.

4. Evaluate the Model:

o Evaluate the classification performance on the test set by displaying a confusion


matrix and accuracy.

o Visualize the decision boundary of the neural network (using meshgrid for
visualization).

5. Conclusion:

o Describe your results and impressions of working with neural networks.

Expected Deliverables:
Submit a MATLAB script containing the complete code, results (plots, test results), and a short report
in PDF format.
Guide for Students

Introduction to Neural Networks

Neural networks are models inspired by the human brain's functioning. They are widely used for
tasks like classification, regression, and image recognition. The core building block of a neural
network is the neuron, which performs mathematical operations on inputs to produce an output.

Structure of a Neural Network:

1. Input Layer: Accepts input data.

2. Hidden Layers: Learns features from the data.

3. Output Layer: Generates results (e.g., class labels).

Example in MATLAB: Point Classification

% Set parameters
rng(0); % Fixed seed for reproducibility
numPoints = 50;

% Class 1
x1 = -2 + randn(numPoints, 2);
y1 = zeros(numPoints, 1); % Label: 0

% Class 2
x2 = 2 + randn(numPoints, 2);
y2 = ones(numPoints, 1); % Label: 1

% Combine data
inputs = [x1; x2]';
targets = [y1; y2]';
% Split into training and testing sets
trainRatio = 0.7;
testRatio = 0.3;

[trainInd,~,testInd] = dividerand(size(inputs, 2),


trainRatio, 0, testRatio);

trainInputs = inputs(:, trainInd);


trainTargets = targets(:, trainInd);

testInputs = inputs(:, testInd);


testTargets = targets(:, testInd);
% Create the network
hiddenLayerSize = 5;
net = patternnet(hiddenLayerSize);

% Train the network


net = train(net, trainInputs, trainTargets);

% Test the network


testOutputs = net(testInputs);
testPredictions = round(testOutputs);

% Display results
confMat = confusionmat(testTargets, testPredictions);
disp('Confusion Matrix:');
disp(confMat);

% Decision boundary
[xGrid, yGrid] = meshgrid(-5:0.1:5, -5:0.1:5);
gridPoints = [xGrid(:), yGrid(:)]';

gridOutputs = net(gridPoints);
gridPredictions = reshape(gridOutputs, size(xGrid));

% Plot
figure;
hold on;
scatter(x1(:,1), x1(:,2), 'b', 'filled');
scatter(x2(:,1), x2(:,2), 'r', 'filled');
contour(xGrid, yGrid, gridPredictions, [0.5 0.5], 'k',
'LineWidth', 2);
title('Neural Network Decision Boundary');
legend('Class 1', 'Class 2', 'Decision Boundary');
hold off;

Summary:

This example demonstrates step-by-step how to build a simple neural network in MATLAB for data
classification. The project provides hands-on experience and an understanding of the fundamentals
of neural networks.

You might also like