Code Monkey home page Code Monkey logo

linearregressionfromscratch's Introduction

Simple Linear Regression Implementation

Overview

This project is an investigation into the fundamental ideas that underpin machine learning, with a particular emphasis on the use of a straightforward linear regression model. The analytic solution and gradient descent are the two primary approaches that are incorporated into the project in order to locate the line that provides the greatest fit for a particular dataset. The primary goal is to compare the effectiveness of different strategies on synthetic datasets and to gain an understanding of how these methods operate.

Features

  • Analytic Solution: Calculates the optimal weights for the regression model analytically using the normal equation.
  • Gradient Descent: Iteratively adjusts the weights to minimize the cost function, showcasing the practical application of this widely used optimization technique.

Getting Started

Prerequisites

  • Python 3.x
  • numpy

Data Files

This project uses synthetic datasets provided in .in files for training the linear regression models. Each .in file contains multiple lines, each representing a data point. A line consists of space-separated real numbers, where the last number is the target variable (y) and the preceding numbers are the feature variables (x1, x2, ..., xM).

Example:

x1 x2 y
14 20 69
16 3 -1
24 30 99
11 62 240
30 -4 -43

In this example, each line represents a data point with two features and one target variable.

Configuration Files

Hyperparameters for the gradient descent method are specified in .json files. Each .json file corresponds to an .in file and contains the learning rate and the number of iterations.

1.json Example:

{
	"learning rate": 0.0001,
	"num iter": 1000
}

2.json Example:

{
	"learning rate": 0.01,
	"num iter": 1000
}

Installation

Clone this repository to your local machine:

git clone https://github.com/SatvikVarshney/LinearRegressionFromScratch.git

After cloning, navigate to the project directory:

cd LinearRegressionFromScratch

Install the required dependencies:

pip install -r requirements.txt

linearregressionfromscratch's People

Contributors

satvikvarshney avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.