kartben / Regressino

Calculate potential, exponential, logarithmic, lineal and logistic regressio in Arduino.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Regressino     Buy Me a Coffee at ko-fi.com

Library to calculate potential, exponential, logarithmic, lineal and logistic regression in Arduino.

Lineal: Y = a*X + b
Exponential: Y = b * e^(a*X)
Logarithmic: Y = a*ln(X) + b
Potential: Y = b * x^a
Logistic: Y = 1 / (1 + e^-(a*x+b))
Polynomial: Y = a1x^2 + a2x + b
Linear2d: Y = a1x1 + a2x2 + b
Logistic2d:Y = 1 / (1 + e^-(1x1 + a2x2 + b))

Graphs with a = 2 and b = 3:

Logistic regression:

Polynomial regression:

Linear and Logistic 2 variables

Use

Include

1 variable

Linear

#include <LinearRegression.h>

LinearRegression lr = LinearRegression();

Exponential

#include <ExponentialRegression.h>

ExponentialRegression er = ExponentialRegression;

Logarithmic

#include <LogarithmicRegression.h>

LogarithmicRegression lr = LogarithmicRegression();

Potential

#include <PotentialRegression.h>

PotentialRegression pr = PotentialRegression();

Logistic

#include <LogisticRegression.h>

LogisticRegression pr = LogisticRegression();

Polynomial

#include < PolynomialRegression.h>

 PolynomialRegression pr =  PolynomialRegression();

2 variables

Linear2d

#include <LinearRegression2d.h>

LinearRegression lr = LinearRegression2d();

Logistic2d

#include <LogisticRegression2d.h>

LogisticRegression pr = LogisticRegression2d();

Methods 1 variable

void learn(double x, double y);  

Learns one example.

  • x: value of X
  • y: value of Y

double calculate(double x1);  

Estimates value of Y for X

  • x: value of x

double correlation();  

Return correlation value

void reset();  

Reset values. Start learning since zero.

void parameters(double values[]);

Return parameters of the regression y = mx + b

  • values[0] = m;
  • values[1] = b;

In polynomial values are y = b1x^2 + b2x + a :

  • values[0] = b1;
  • values[1] = b2;
  • values[2] = a;

double error(double x, double y);  

Return estimation error. If you need more options to calculate error you can use error module from SimpleStatisticsArduino

void samples();

Return number of examples learned

Methods 2 variables

void learn(double x1, double x2, double y);  

Learns one example.

  • x1: value of X1
  • x2: value of X2
  • y: value of Y

double calculate(double x1, double x2);  

Estimates value of Y

  • x1: value of x1
  • x2: value of x2

double correlation();  

Return correlation value

double correlationX1Y();  

Return correlation value between X1 and Y

double correlationX1Y();  

Return correlation value between X1 and Y

double correlationX2Y();  

Return correlation value between X2 and Y

double correlationX1X2();  

Return correlation value between X1 and X2

void reset();  

Reset values. Start learning since zero.

void parameters(double values[]);

Return parameters of the regression y = b1x1 + b2x2 + a

  • values[0] = b1;
  • values[1] = b2;
  • values[2] = a;

double error(double x1, double x2, double y);  

Return estimation error. If you need more options to calculate error you can use error module from SimpleStatisticsArduino

void samples();

Return number of examples learned

About

Calculate potential, exponential, logarithmic, lineal and logistic regressio in Arduino.

License:GNU General Public License v3.0


Languages

Language:C++ 100.0%