{"id":18259998,"url":"https://github.com/hungrybluedev/linear_regression","last_synced_at":"2026-02-13T08:14:50.899Z","repository":{"id":199194555,"uuid":"702314491","full_name":"hungrybluedev/linear_regression","owner":"hungrybluedev","description":"Multiple Linear Regression in pure V.","archived":false,"fork":false,"pushed_at":"2023-10-10T06:19:37.000Z","size":75,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-14T18:36:26.170Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"V","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hungrybluedev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-10-09T04:39:22.000Z","updated_at":"2023-10-28T03:15:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"75fb59dd-4f40-4cc3-bbcb-9105450456a5","html_url":"https://github.com/hungrybluedev/linear_regression","commit_stats":null,"previous_names":["hungrybluedev/linear_regression"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungrybluedev%2Flinear_regression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungrybluedev%2Flinear_regression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungrybluedev%2Flinear_regression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungrybluedev%2Flinear_regression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hungrybluedev","download_url":"https://codeload.github.com/hungrybluedev/linear_regression/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247947825,"owners_count":21023058,"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","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":[],"created_at":"2024-11-05T10:41:26.946Z","updated_at":"2025-10-03T16:21:06.996Z","avatar_url":"https://github.com/hungrybluedev.png","language":"V","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Linear Regression\n\n## Introduction\n\nThis project demonstrates how to implement a Multiple Linear Regression model using pure V.\n\nThere are no dependencies, just a working V installation is required. All data processing and linear algebra operations are implemented from scratch.\n\n## Datasets\n\nThe following datasets are used for demonstration.\n\n1. [Student performance](https://archive.ics.uci.edu/dataset/320/student+performance).\n2. [Boston housing](https://www.kaggle.com/code/prasadperera/the-boston-housing-dataset/input).\n3. [Insurance cost](https://www.kaggle.com/datasets/mirichoi0218/insurance).\n\n## Usage\n\nIn `main.v`, we demonstrate how to use the `LinearRegression` struct to train a model and make predictions. There, we test a bunch of models and select the one with the highest score.\n\nSample usage for the `LinearRegression`, `TabularDataSet`, and `Matrix` structs:\n\n```v\n// Load the data\nfull_data := TabularDataSet.from_file(path: 'data/student/student-mat.csv', separator: ';')!\n\n// Indicate which columns are relevant for the model\nrelevant_cols := ['G1', 'G2', 'G3', 'traveltime', 'studytime', 'failures', 'famrel', 'health']\npredict_column := 'G3'\nattributes := relevant_cols.filter(it != predict_column)\n\n// Select the relevant columns\ndata := full_data.select_columns(relevant_cols)!\n\n// Separate input and output data\nx_data := data.select_columns(attributes)!\ny_data := data.select_column(predict_column)!\n\n// Split the data into training and testing sets\nx_train_data, y_train_data, x_test_data, y_test_data := train_test_split(\n  x_data: x_data\n  y_data: y_data\n  test_size: 0.2\n)!\n\n// Convert the data to matrices\nx_train, y_train, x_test, y_test := x_train_data.as_matrix()!, y_train_data.as_matrix()!, x_test_data.as_matrix()!, y_test_data.as_matrix()!\n\n// Train the model and calculate the accuracy\nmodel := LinearRegression.fit(attributes, x_train, y_train)!\naccuracy := model.score(x_test, y_test)!\n\n// Use the model to make predictions\npredictions := model.predict(x_test)!\n```\n\n## Running the Examples\n\nFrom the root of the project, run the following command to run the examples:\n\n```bash\nv run examples/((example_name)).v\n```\n\n## License\n\nThis demonstration is licensed under the MIT license. See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhungrybluedev%2Flinear_regression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhungrybluedev%2Flinear_regression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhungrybluedev%2Flinear_regression/lists"}