If ninja is not installed, you can install it using one of the following methods:
conda install -c conda-forge ninjaconda create -n linear_reg_env -y
conda activate linear_reg_env
conda install -c conda-forge cmake
conda install matplotlibInstall xtensor and xtensor-blas from conda-forge:
conda install -c conda-forge xtensor xtensor-blas
conda install -c conda-forge cmakeUse CMake and Ninja to build the project:
mkdir build && cd build
cmake -G Ninja ..
ninja./main./tests/test_linear_regression./src/visualization-
src/main.cc: It generates a synthetic dataset, applies linear regression using both closed-form and gradient descent methods, and outputs the results. -
src/optim.handsrc/optim.cc: These files define the algorithms used in the project. TheClosedFormclass implements the closed-form solution for linear regression, while theGradientDescentclass implements the iterative gradient descent algorithm. -
src/loss.handsrc/loss.cc: Defines the loss functions used to evaluate the performance of the linear regression model. TheMSELossclass calculates the mean squared error, and theRMSELossclass calculates the root mean squared error. -
tests/test_linear_regression.cc: Unit tests for the linear regression model. -
src/visualization.cc: This file contains the code for the visualization of the data and the results.