KEMBAR78
Final Homework | PDF | Machine Learning | Computational Neuroscience
0% found this document useful (0 votes)
11 views6 pages

Final Homework

Uploaded by

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

Final Homework

Uploaded by

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

Ricardo Rodriguez

Fabio Solórzano
Daniela Aguilar

Final Homework
1. Consider the database contained in the house.mat file. Rows 1 through 13 contain statistical
information for 506 neighborhoods that will be used to estimate the median house price in
thousands of dollars (Row 14).
The 13 variables are:
1) Per capita crime rate per town
2) Proportion of residential land zoned for lots over 25,000 sq. ft.
3) Proportion of non-retail business acres per town
4) 1 if tract bounds Charles river, 0 otherwise.
5) Nitric oxides concentration (parts per 10 million)
6) Average number of rooms per dwelling
7) Proportion of owner-occupied units built prior to 1940
8) Weighted distances to five Boston employment centers
9) Index of accessibility to radial highways
10) Full-value property-tax rate per $10,000
11) Pupil-teacher ratio by town
12) 1000(Bk - 0.63)^2, where Bk is the proportion of blacks by town
13) Percent lower status of the population

a) Use 90% of the data to train the neural model and estimate the remaining 10%.
b) Estimate the average price in thousands of dollars of a house with the following
parameters:
X1= 12.54, X2=45, X3=15.37, X4=1, X5=0.5150, X6=6.1621, X7=45.800, X8=3.3751, X9=7,
X10=193, X11=15.200, X12=347.88, X13=2.96
Ricardo Rodriguez
Fabio Solórzano
Daniela Aguilar
code:
clear all; %Clear all variables
close all; %Close all windows
clc; %clean the command window

%% first
load house.mat

X=house(1:13,:);
y=house(14,:);

n_size=round(0.9*size(y,2));

Xtrain=X(:,1:n_size);
Ytrain=y(:,1:n_size);

Xtest = X(:,n_size:end);
Ytest = y(:,n_size:end);

net=feedforwardnet([10 10]);
net.trainFcn='trainlm';
net=train(net,Xtrain,Ytrain);

Yctrain=net(Xtrain);
Jtrain=perform(net,Ytrain,Yctrain);

X1= 12.54;
X2=45;
Ricardo Rodriguez
Fabio Solórzano
Daniela Aguilar
X3=15.37;
X4=1;
X5=0.5150;
X6=6.1621;
X7=45.800;
X8=3.3751;
X9=7;
X10=193;
X11=15.200;
X12=347.88;
X13=2.96;

Xf = [X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13]';

Yc = net(Xf)

2. Load the database named ex_mia4_data1. In the database you will find an array named train,
with examples of data that have already been classified, with which you should train a neural
network to perform a supervised classification to classify the data contained in the array
test_unknown.
a) It is highly likely that your first attempt will not work. What is the error that prevents you
from classifying the data and how do you correct it?
b) Using only one neuron in the output layer provide classification of the data in
the test_unknown matrix.
c) Using three neurons in the output layer provides the classification of
the test_unknown_matrix data.
Ricardo Rodriguez
Fabio Solórzano
Daniela Aguilar
d) Compare the classes obtained in b) and c). Are you assigned the same classification by
both methods? Justify your answer

The classification is different because the model is different. they might have alike results
but theoretically the 3 neurons will be better because it has more capacity

Code:
%% second

clear all; %Clear all variables


close all; %Close all windows
clc; %clean the command window

load ex_mia4_data1.mat

Xtrain=train(:,1:3);
Ytrain=train(:,4);
clear train;

Ytrain_dummies=dummyvar(Ytrain);

net1=feedforwardnet([10 10]);
net2=feedforwardnet([10 10]);

net1.trainFcn='trainrp';
net2.trainFcn='trainrp';

net1=train(net1,Xtrain',Ytrain');
net2=train(net2,Xtrain',Ytrain_dummies');
Ricardo Rodriguez
Fabio Solórzano
Daniela Aguilar

Yctrain1=net1(Xtrain');
Yctrain2=net2(Xtrain');

Yctest1=net1(test_unknown');
Yctest1=round(Yctest1)';

Yctest2=net2(test_unknown');
Yctest2=round(Yctest2)';

for i = 1:size(Yctest1,1)
if Yctest1(i,1)<1
Yctest1(i,1)=1
end
if Yctest1(i,1)>3
Yctest1(i,1)=3
end
end

for j=1:3
for i=1:size(Yctest2,1)
if Yctest2(i,j)<0
Yctest2(i,j)=0;
end
Ricardo Rodriguez
Fabio Solórzano
Daniela Aguilar

if Yctest2(i,j)>1
Yctest2(i,j)=1;
end
end
end

You might also like