https://github.com/jolars/libslope
C++ library for Sorted L-One Penalized Estimation (SLOPE)
https://github.com/jolars/libslope
cpp machine-learning regularization slope statistics
Last synced: about 1 year ago
JSON representation
C++ library for Sorted L-One Penalized Estimation (SLOPE)
- Host: GitHub
- URL: https://github.com/jolars/libslope
- Owner: jolars
- License: gpl-3.0
- Created: 2023-11-21T12:56:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-09T11:26:44.000Z (about 1 year ago)
- Last Synced: 2025-04-09T11:30:43.452Z (about 1 year ago)
- Topics: cpp, machine-learning, regularization, slope, statistics
- Language: C++
- Homepage: https://jolars.github.io/libslope/
- Size: 6.08 MB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# SLOPE 
[](https://github.com/jolars/libslope/actions/workflows/ci.yaml)
[](https://codecov.io/gh/jolars/libslope)
Libslope is a C++ library for Sorted L-One Penalized Estimation (SLOPE). Its main
purpose is to serve as a backend for R and Python packages, but it can also be
used as a standalone library in the off-chance that you want to fit your models
entirely through C++.
## Getting Started
First, we define our model. Let's use logistic regression, by setting the
loss to `"logistic"`.
```cpp
#include "slope.h"
Slope::Model model;
model.setLoss("logistic");
```
Next, we set the data matrix `x` and the response vector `y`. Here we use some
toy data.
```cpp
Eigen::MatrixXd x(3, 2);
Eigen::VectorXd y(3);
x << 1.1, 2.3, 0.2, 1.5, 0.5, 0.2;
y << 0, 1, 0;
```
Finally, we call the `path()` method to fit the full SLOPE path.
```cpp
auto res = model.path(x, y);
```
Now we can retrieve the coefficients by calling `res.getCoefs()`.
## Dependencies
### Building
- A C++17 compiler
- CMake 3.15 or later
- Eigen 3.4 or later
### Documentation
- Doxygen
### Testing
- Catch2