Please help me solve this problem.
Linear Algebra using Octave with some more knowledge of machine learning
Here is the assignment:
You will investigate linear regression using gradient descent and the normal equations
The training set of housing prices in Portland, Oregon is in files ex3x and ex3y, where
$y are the prices and the inputs $x are the living area and the number of bedrooms. We will use only living area in this assignment
First part of the assignment is to calculate linear estimator using normal equation, and then use the parameters to calculate price of the house with 1650sf,
File to modify: gradinet3student_neq
Second part of the assignment is to calculate linear estimator using gradient descent, and then use the parameters to calculate price of the house with 1650sf,
File to modify: gradinet3student_GD
Note: Recall when you are applying GD, it is good practice to normalize the input data (subtract the average and scale by standard deviation), to bring all data in the similar range. During prediction you need to do the same.
Send me house price estimate and weights for part one and two, in following format:
In this exercise, you will investigate linear regression using gradient descent and the normal equations
The training set of housing prices in Portland, Oregon is in files ex3x and ex3y, where
$y are the prices and the inputs $x are the living area and the number of bedrooms. We will use only living area in this assignment
First part of the assignment is to calculate linear estimator using normal equation, and then use the parameters to calculate price of the house with 1650sf,
File to modify: gradinet3student_neq
Second part of the assignment is to calculate linear estimator using gradient descent, and then use the parameters to calculate price of the house with 1650sf,
File to modify: gradinet3student_GD
Note: Recall when you are applying GD, it is good practice to normalize the input data (subtract the average and scale by standard deviation), to bring all data in the similar range. During prediction you need to do the same.
Send me house price estimate and weights for part one and two, in following format:
Normal eq model
GD model
Price of 1650sf
W0
W1
%in this exercise, you will investigate linear regression using gradient descent
% and the normal equations
%This is a training set of housing prices in Portland, Oregon, where
%y are the prices and the inputs $x are the living area and the number of bedrooms.
%we will use only living area in this assigment
% initialize samples of x and y training dataset
%
x2 = load(‘ex3x.dat’);
y = load(‘ex3y.dat’); %house cost
x=x2(:,1); %only living area
m = length(y); % store the number of training examples
x = [ones(m, 1), x]; % Add a column of ones to x
%the area values from your training data are actually in the second column of x
#Gradient descent
xorg=x(:,2);
#normilze the data
sigma = std(x);
mu = mean(x);
x(:,2) = (x(:,2) – mu(2))./ sigma(2);
mse = zeros(100, 100); % initialize mse to 100×100 matrix of 0’s
w0 = linspace(100000,500000,100);
w1 = linspace(1000,300000,100);
for i = 1:length(w0)
for j = 1:length(w1)
t = [w0(i); w1(j)];
mse(i,j) =1/m* (y-x*t)’*(y-x*t);
end
end
% Plot the surface plot
% Because of the way meshgrids work in the surf command, we need to
% transpose mse before calling surf, or else the axes will be flipped
mse = mse’;
figure;
surf(w0, w1, mse);
xlabel(‘\w0’); ylabel(‘\w1’);
w = zeros(2, 1);
iterations = 100
alpha = 0.07
cost=zeros(iterations,1);
for iter = 1:iterations
%insert your code here
% cost(iter)=…
% this is the code to calculate weights
% w=w – your code * alpha;
%end of your code
wdraw0(iter)=w(1);
wdraw1(iter)=w(2);
end
disp(“w0g w1g”),disp(w);
% now plot Cost
% technically, the first cost at the zero-eth iteration
% but Matlab/Octave doesn’t have a zero index
figure;
plot(0:iterations-1, cost(1:iterations), ‘-‘)
xlabel(‘Number of iterations’)
ylabel(‘Cost – mean square error ‘)
#normilize 1650sf
%caling 1650sf your code here:
%newxs= your code
newxs=
disp(“house prediction for 1650s, gradient descent:”),disp([1,newxs]*w);
#plot data and regression line
figure % open a new figure window
# plot your training set (and label the axes):
plot(xorg,y,’o’);
ylabel(‘house cost’)
xlabel(‘house sf’)
hold
yp=x*w;
plot(xorg,yp,’-‘);
%in this exercise, you will investigate linear regression using gradient descent
% and the normal equations
%This is a training set of housing prices in Portland, Oregon, where
%y are the prices and the inputs $x are the living area and the number of bedrooms.
%we will use only living area in this assigment
% initialize samples of x and y training dataset
%
x2 = load(‘ex3x.dat’);
y = load(‘ex3y.dat’); %house cost
x=x2(:,1); %only living area
m = length(y); % store the number of training examples
x = [ones(m, 1), x]; % Add a column of ones to x
%the area values from your training data are actually in the second column of x
%calculate parametar w using normal equation
%your code here
%
%w=
%code end
disp(“w0 w1”),disp(wn);
#predict the house price with 1650sf
disp(“house prediction for 1650s, normal eq:”),disp([1,1650]*wn);
yp=x*wn;
#plot data and regression line
figure % open a new figure window
# plot your training set (and label the axes):
plot(x(:,2),y,’o’);
ylabel(‘house cost’)
xlabel(‘house sf’)
hold
plot(x(:,2),yp,’-‘);
2.1040000e+03 3.0000000e+00
1.6000000e+03 3.0000000e+00
2.4000000e+03 3.0000000e+00
1.4160000e+03 2.0000000e+00
3.0000000e+03 4.0000000e+00
1.9850000e+03 4.0000000e+00
1.5340000e+03 3.0000000e+00
1.4270000e+03 3.0000000e+00
1.3800000e+03 3.0000000e+00
1.4940000e+03 3.0000000e+00
1.9400000e+03 4.0000000e+00
2.0000000e+03 3.0000000e+00
1.8900000e+03 3.0000000e+00
4.4780000e+03 5.0000000e+00
1.2680000e+03 3.0000000e+00
2.3000000e+03 4.0000000e+00
1.3200000e+03 2.0000000e+00
1.2360000e+03 3.0000000e+00
2.6090000e+03 4.0000000e+00
3.0310000e+03 4.0000000e+00
1.7670000e+03 3.0000000e+00
1.8880000e+03 2.0000000e+00
1.6040000e+03 3.0000000e+00
1.9620000e+03 4.0000000e+00
3.8900000e+03 3.0000000e+00
1.1000000e+03 3.0000000e+00
1.4580000e+03 3.0000000e+00
2.5260000e+03 3.0000000e+00
2.2000000e+03 3.0000000e+00
2.6370000e+03 3.0000000e+00
1.8390000e+03 2.0000000e+00
1.0000000e+03 1.0000000e+00
2.0400000e+03 4.0000000e+00
3.1370000e+03 3.0000000e+00
1.8110000e+03 4.0000000e+00
1.4370000e+03 3.0000000e+00
1.2390000e+03 3.0000000e+00
2.1320000e+03 4.0000000e+00
4.2150000e+03 4.0000000e+00
2.1620000e+03 4.0000000e+00
1.6640000e+03 2.0000000e+00
2.2380000e+03 3.0000000e+00
2.5670000e+03 4.0000000e+00
1.2000000e+03 3.0000000e+00
8.5200000e+02 2.0000000e+00
1.8520000e+03 4.0000000e+00
1.2030000e+03 3.0000000e+00
3.9990000e+05
3.2990000e+05
3.6900000e+05
2.3200000e+05
5.3990000e+05
2.9990000e+05
3.1490000e+05
1.9899900e+05
2.1200000e+05
2.4250000e+05
2.3999900e+05
3.4700000e+05
3.2999900e+05
6.9990000e+05
2.5990000e+05
4.4990000e+05
2.9990000e+05
1.9990000e+05
4.9999800e+05
5.9900000e+05
2.5290000e+05
2.5500000e+05
2.4290000e+05
2.5990000e+05
5.7390000e+05
2.4990000e+05
4.6450000e+05
4.6900000e+05
4.7500000e+05
2.9990000e+05
3.4990000e+05
1.6990000e+05
3.1490000e+05
5.7990000e+05
2.8590000e+05
2.4990000e+05
2.2990000e+05
3.4500000e+05
5.4900000e+05
2.8700000e+05
3.6850000e+05
3.2990000e+05
3.1400000e+05
2.9900000e+05
1.7990000e+05
2.9990000e+05
2.3950000e+05
We provide professional writing services to help you score straight A’s by submitting custom written assignments that mirror your guidelines.
Get result-oriented writing and never worry about grades anymore. We follow the highest quality standards to make sure that you get perfect assignments.
Our writers have experience in dealing with papers of every educational level. You can surely rely on the expertise of our qualified professionals.
Your deadline is our threshold for success and we take it very seriously. We make sure you receive your papers before your predefined time.
Someone from our customer support team is always here to respond to your questions. So, hit us up if you have got any ambiguity or concern.
Sit back and relax while we help you out with writing your papers. We have an ultimate policy for keeping your personal and order-related details a secret.
We assure you that your document will be thoroughly checked for plagiarism and grammatical errors as we use highly authentic and licit sources.
Still reluctant about placing an order? Our 100% Moneyback Guarantee backs you up on rare occasions where you aren’t satisfied with the writing.
You don’t have to wait for an update for hours; you can track the progress of your order any time you want. We share the status after each step.
Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.
Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.
From brainstorming your paper's outline to perfecting its grammar, we perform every step carefully to make your paper worthy of A grade.
Hire your preferred writer anytime. Simply specify if you want your preferred expert to write your paper and we’ll make that happen.
Get an elaborate and authentic grammar check report with your work to have the grammar goodness sealed in your document.
You can purchase this feature if you want our writers to sum up your paper in the form of a concise and well-articulated summary.
You don’t have to worry about plagiarism anymore. Get a plagiarism report to certify the uniqueness of your work.
Join us for the best experience while seeking writing assistance in your college life. A good grade is all you need to boost up your academic excellence and we are all about it.
We create perfect papers according to the guidelines.
We seamlessly edit out errors from your papers.
We thoroughly read your final draft to identify errors.
Work with ultimate peace of mind because we ensure that your academic work is our responsibility and your grades are a top concern for us!
Dedication. Quality. Commitment. Punctuality
Here is what we have achieved so far. These numbers are evidence that we go the extra mile to make your college journey successful.
We have the most intuitive and minimalistic process so that you can easily place an order. Just follow a few steps to unlock success.
We understand your guidelines first before delivering any writing service. You can discuss your writing needs and we will have them evaluated by our dedicated team.
We write your papers in a standardized way. We complete your work in such a way that it turns out to be a perfect description of your guidelines.
We promise you excellent grades and academic excellence that you always longed for. Our writers stay in touch with you via email.