Giter VIP home page Giter VIP logo

priyanshusaxena2612 / linear-regression-gcc Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 548 KB

This is a Python ML method Linear Regression which is implemented in CPP just for practice. This header file is able to multiply two arrays like the NUMPY in Python, predict the output as of Linear Regression, just missing out the plotting area, if you have the knowledge of adding graphs to CPP, then feel free to add it in this repo also.

C++ 100.00%
cpp python machine-learning linear-regression

linear-regression-gcc's Introduction

Simple Linear Regression Library C++

A library made in c++ for simple linear regression.

How to use this library:

Download SimpleLinearRegression.h and include the following library in your program.

    #include "SimpleLinearRegression.h"
    using linearRegressionMaths;
  • Declare two double variables m and c in your main method.
    double m = 0, c = 0;
    // m is for slope and c is for intercept
  • Take two vectors of equal size and pass them to the respective functions as mentioned below.

Methods included in this library:

  • calculateSlope
  • calculateIntercept
  • mean
  • vectorMultiplication
  • predict
  • score

About all the methods used:

  • calculateSlope: Calculates the slope of the best fit line, takes an input of two vectors X and Y, to return a double value.
  • calculateIntercept: Calculates the intercept of the best fit line, same params like calculateSlope and returns a double value.
  • mean: Returns a double value of the mean of the vector passed as a parameter.
  • vectorMultiplication: Takes two vectors X and Y and returns a vector of the same size containing the multiplication of element by element of X and Y.
  • predict: Takes 3 params of a vector of testing data, slope, and intercept, and returns a vector of the predicted values of the testing data vector.
  • score: Takes 2 params of vectors of truth values and predicted values, and returns a score <=1, telling how good the fit line is.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

License

MIT

linear-regression-gcc's People

Contributors

priyanshusaxena2612 avatar

Stargazers

 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.