{"id":25237990,"url":"https://github.com/vspaz/wls-zig","last_synced_at":"2025-07-31T02:33:52.798Z","repository":{"id":273245370,"uuid":"919098185","full_name":"vspaz/wls-zig","owner":"vspaz","description":"WLS, weighted linear regression in pure Zig w/o any 3d party dependencies or frameworks.","archived":false,"fork":false,"pushed_at":"2025-03-06T23:45:47.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T18:52:20.831Z","etag":null,"topics":["least-square-fit","least-square-method","weighted-linear-regression","weighted-regression","wls","zig","ziglang"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vspaz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-19T17:46:01.000Z","updated_at":"2025-03-06T23:48:51.000Z","dependencies_parsed_at":"2025-01-19T18:39:09.302Z","dependency_job_id":"bf92b8cf-302f-487f-9378-39165c636c87","html_url":"https://github.com/vspaz/wls-zig","commit_stats":null,"previous_names":["vspaz/wls-zig"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/vspaz/wls-zig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vspaz%2Fwls-zig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vspaz%2Fwls-zig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vspaz%2Fwls-zig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vspaz%2Fwls-zig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vspaz","download_url":"https://codeload.github.com/vspaz/wls-zig/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vspaz%2Fwls-zig/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267977985,"owners_count":24175241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["least-square-fit","least-square-method","weighted-linear-regression","weighted-regression","wls","zig","ziglang"],"created_at":"2025-02-11T16:03:03.854Z","updated_at":"2025-07-31T02:33:52.777Z","avatar_url":"https://github.com/vspaz.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wls-zig\n\n`wls-zig` is the implementation of weighted linear regression in pure **Zig** w/o any 3d party dependencies or frameworks.\n\n## Installation\n1. Run the following command inside your project:\n```shell\nzig fetch --save git+https://github.com/vspaz/wls-zig.git#main\n```\nit should add the following dependency to your project _build.zig.zon_ file, e.g.\n```zig\n.dependencies = .{\n    .wls = .{\n        .url = \"git+https://github.com/vspaz/wls-zig.git?ref=main#f4dfc9a98f8f538d6d25d7d3e1e431fe77d54744\",\n        .hash = \"wls-0.1.0-NK6PrjMoAABYyveo97dzY5AugQxqcGgExHsaDVMxx1wm\",\n    },\n}\n```\n\n2. Navigate to _build.zig_ file located in the root directory and add the following 2 lines as shown below:\n\n```zig\n const exe = b.addExecutable(.{\n        .name = \"your project name\",\n        .root_module = exe_mod,\n    });\n    \n    // add these 2 lines!\n    const wlszig = b.dependency(\"wls\", .{});\n    exe.root_module.addImport(\"wls\", wlszig.module(\"wls\"));\n```\n3. Test the project build with `zig build`\n   There should be no error!\n\n4. mport `wls-zig` lib in your code as follows:\n```zig\nconst wls = @import(\"wls\");\n```\nand you're good to go! :rocket:\n\n## Examples\n```zig\npub const Wls = @import(\"wls\").Wls;\npub const asserts = @import(\"wls\").asserts;\n\npub fn main() !void {\n    const x_points = [_]f64{ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 };\n    const y_points = [_]f64{ 1.0, 3.0, 4.0, 5.0, 2.0, 3.0, 4.0 };\n    const weights = [_]f64{ 1.0, 2.0, 3.0, 1.0, 8.0, 1.0, 5.0 };\n\n    const wls_model = Wls.init(\u0026x_points, \u0026y_points, \u0026weights);\n    const fitted_model = wls_model.fit_linear_regression();\n\n    if (fitted_model) |line| {\n        asserts.assert_almost_equal(2.14285714, line.intercept, 1.0e-6);\n        asserts.assert_almost_equal(0.150862, line.slope, 1.0e-6);\n    }\n}\n```\n\n## Description\n\nWLS is based on the OLS method and help solve problems of model inadequacy or violations of the basic regression assumptions.\n\nEstimating a linear regression with WLS is can be hard w/o special stats packages, such as Python statsmodels or Pandas.\n\n## References\n\n- [Wikipedia: Weighted least squares](https://en.wikipedia.org/wiki/Weighted_least_squares)\n- [Introduction to Linear Regression Analysis, 5th edition](https://tinyurl.com/y3clfnrs)\n- [Least Squares Regression Analysis in Terms of Linear Algebra](https://tinyurl.com/y485qhlg) ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvspaz%2Fwls-zig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvspaz%2Fwls-zig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvspaz%2Fwls-zig/lists"}