This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
disp("Initilizing the best Linear Regression Program v1.0\n"); | |
% clear and initialize | |
clear; clc; close all; | |
sprintf("Initilizing paths...\n"); | |
% add paths | |
addpath('./lib'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6.1101,17.592 | |
5.5277,9.1302 | |
8.5186,13.662 | |
7.0032,11.854 | |
5.8598,6.8233 | |
8.3829,11.886 | |
7.4764,4.3483 | |
8.5781,12 | |
6.4862,6.5987 | |
5.0546,3.8166 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parameters = gradient_descent(X, Y, theta0, theta1, learning_rate, initial_cost) | |
i = 0; | |
previous_cost = initial_cost+1; | |
cost = initial_cost; | |
m = length(X); | |
while(i < 100) | |
H = theta0 + theta1.*X; | |
cost = compute_cost(H, Y, m); | |
format short | |
derivatives = compute_derivatives(X, Y, theta0, theta1, m); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function derivatives = compute_derivatives(X, Y, theta0, theta1, m) | |
derivatives(1) = (1/m)*sum((theta0+(theta1*X))-Y); | |
derivatives(2) = (1/m)*sum(X.*((theta0+(theta1*X))-Y)); | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Explanatory Variable | |
X2 = [1;1;2;3;3]; | |
% Response Variable | |
Y2 = [0.5;1.5;2;1.5;3]; | |
plot(X2, Y2, 'rx', 'linewidth',2); | |
axis([0 5 0 5]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cost = compute_cost(H, Y, m) | |
% H hypothesis matrix | |
% Y Response Variable | |
% m training examples | |
cost = (1/(2*m))*sum((H-Y).^2); | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
disp("Initilizing the best Linear Regression Program v1.0\n"); | |
% clear and initialize | |
clear; clc; close all; | |
sprintf("Initilizing paths...\n"); | |
% add paths | |
addpath('./lib'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS `country` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`iso` char(2) NOT NULL, | |
`name` varchar(80) NOT NULL, | |
`nicename` varchar(80) NOT NULL, | |
`iso3` char(3) DEFAULT NULL, | |
`numcode` smallint(6) DEFAULT NULL, | |
`phonecode` int(5) NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=MyISAM DEFAULT CHARSET=latin1; |