Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ratikaewkam/linreg
Building my own C++ library for the Linear Regression
https://github.com/ratikaewkam/linreg
cpp linear-regression mathematics
Last synced: about 23 hours ago
JSON representation
Building my own C++ library for the Linear Regression
- Host: GitHub
- URL: https://github.com/ratikaewkam/linreg
- Owner: ratikaewkam
- License: mit
- Created: 2024-10-23T12:38:30.000Z (25 days ago)
- Default Branch: main
- Last Pushed: 2024-10-27T00:57:32.000Z (21 days ago)
- Last Synced: 2024-10-27T08:16:59.527Z (21 days ago)
- Topics: cpp, linear-regression, mathematics
- Language: C++
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# linreg
Building my own C++ library for the Linear Regression![GitHub Release](https://img.shields.io/github/v/release/ratikaewkam/linreg)
![GitHub contributors](https://img.shields.io/github/contributors/ratikaewkam/linreg)
![GitHub repo size](https://img.shields.io/github/repo-size/ratikaewkam/linreg)
![GitHub forks](https://img.shields.io/github/forks/ratikaewkam/linreg)## Latest Feature
- Find a linear regression equation
- Fix invalid track value
- Update error handling (data size, invalid value)## Example
```c++
// main.cpp
#include
#include
#includeint main()
{
linreg::model model;
linreg::parameter param;std::vector x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
std::vector y = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13};double alpha = 0.01; // Learning rate
int epochs = 3333;
int track = 1; // Type 1 : track valueparam = model.fit(x, y, param, alpha, epochs, track);
std::cout << "y = " << param.w << "x + " << param.b << std::endl;
std::cout << "loss: " << param.mse << std::endl;return 0;
}
```## Run
Run the following command in the Developer CMD for VS
```cmd
cd build
```
```cmd
cmake ..
```
```cmd
cmake --build .
```
```cmd
cd Debug
```
```cmd
main
```
or
```cmd
g++ -I lib/include -c lib/src/mse.cpp -o build/obj/mse.og++ -I lib/include -c lib/src/gradient_descent.cpp -o build/obj/gradient_descent.o
g++ -I lib/include -c lib/src/linreg.cpp -o build/obj/linreg.o
g++ -I lib/include -o build/program/program main.cpp build/obj/mse.o build/obj/gradient_descent.o build/obj/linreg.o
```## 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.## References
[Gradient Descent](https://github.com/ratikaewkam/GradientDescent) |
[Linear Regression](https://github.com/ratikaewkam/LinearRegression)## License
[MIT](https://choosealicense.com/licenses/mit/)---
Developed by [Rati Kaewkam](https://github.com/ratikaewkam)