Skip to content

Instantly share code, notes, and snippets.

@achrafsoltani
Created April 18, 2022 20:40
Show Gist options
  • Save achrafsoltani/7e1adf351b197db2b0ee7aab193b7531 to your computer and use it in GitHub Desktop.
Save achrafsoltani/7e1adf351b197db2b0ee7aab193b7531 to your computer and use it in GitHub Desktop.
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');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sprintf("Loading data files...\n");
% load data file
file = load("data/data1.txt");
X = file(:,1);
Y = file(:,2);
m = length(Y); % examples count
sprintf("Plotting the data...\n");
% plot the data
% plot_data(X,Y)
theta0 = ones(97, 1);
theta1 = 1;
learn_rate = 0.0211;
gradient_data = gradient_descent(X, Y, theta0, theta1, learn_rate, 1000)
hold on
plot_data(X,Y)
Hx = gradient_data(1) + gradient_data(2)*X;
plot(X,Hx)
hold off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment