Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rohanvashisht1234/simplelinearregression.zig
A simple linear regression model built from scratch in Zig programming language.
https://github.com/rohanvashisht1234/simplelinearregression.zig
Last synced: about 1 month ago
JSON representation
A simple linear regression model built from scratch in Zig programming language.
- Host: GitHub
- URL: https://github.com/rohanvashisht1234/simplelinearregression.zig
- Owner: RohanVashisht1234
- License: mit
- Created: 2024-11-25T18:56:26.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-11-25T19:08:25.000Z (about 1 month ago)
- Last Synced: 2024-11-25T20:18:48.975Z (about 1 month ago)
- Language: Zig
- Size: 11.4 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SimpleLinearRegression Library for Zig programming language
## How to use?
- Run the fetch command:
```zig
zig fetch --save https://github.com/RohanVashisht1234/SimpleLinearRegression.zig/archive/refs/tags/v0.0.0.tar.gz
```- Add the following to your build.zig file just above `b.installArtifact(exe);`:
```zig
const SimpleLinearRegression = b.dependency("SimpleLinearRegression", .{
.target = target,
.optimize = optimize,
});exe.root_module.addImport("SimpleLinearRegression", SimpleLinearRegression.module("SimpleLinearRegression"));
```- Now, you can add the following code to `src/main.zig`:
```zig
const std = @import("std");
const SimpleLinearRegression = @import("SimpleLinearRegression");pub fn main() void {
const data = &.{
// x , y
.{ 1.2, 39344.0 },
.{ 1.4, 46206.0 },
// ...
};
var SLR = SimpleLinearRegression.init(data);
const y = SLR.predict(11.0);
std.debug.print("Y: {d}\n", .{y});
std.debug.print("M: {d}\n", .{SLR.m});
std.debug.print("C: {d}\n", .{SLR.c});
}
```
- You can check the examples folder for better examples.