Giter VIP home page Giter VIP logo

ft_linear_regression's Introduction

๐Ÿ”ฎ ft_linear_regression

This program is an introduction to machine learning. It predicts the price of a car by using a linear function training with a gradient descent algorithm

Basic concepts

Linear regression: way to explain the relationship between a dependent variable and one (or more) explanatory variables using a straight line (y = mx + b)

Gradient descent: optimization algorithm to find a local minimum of a function. In this case we are using a squared error cost function.

A linear equation has the form: y = mx + b We want to guess m and b for the line closest to all points in our dataset to predict y with x. We are using the squared error cost function, it has a convex shape and is calculated substracting the Y value between predicted values and real values. Why squared? to avoid sign differences between values that are above and below the predited line.

By taking the derivative at a definite point of the cost function we get the slope at that particular point. At the minimum of the curve that slope is 0, so that's where we want to get m and b. These ecuations to calculate m and b are given to us in the subject.

With the number of iterations and learning rate we are setting the speed at which we are going down the cost function until we reach the minimum.

Using the model

  • train.py: generate the prediction model and save it in thetas.csv
  • predict.py: make a prediction based on user input
  • accuracy.py: calculates R squared.
train.py <dataset> <"auto">
    - dataset: if empty uses "dataset.csv"
    - auto: with this keyword the model will stop automatically when the prediction is good enough

Good learning material

https://github.com/42-AI/bootcamp_python

https://github.com/42-AI/bootcamp_machine-learning

https://www.coursera.org/learn/machine-learning/

Other links

https://zhuanlan.zhihu.com/p/64201647

https://mashkarharis.medium.com/linear-regression-in-python-scikit-learn-526b57a11a09

https://en.wikipedia.org/wiki/Gradient_descent

https://en.wikipedia.org/wiki/Linear_regression

ft_linear_regression's People

Contributors

pruiz-ca avatar

Stargazers

d-r-e avatar

Watchers

 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.