{"id":18137959,"url":"https://github.com/gorosgobe/regression-algorithms","last_synced_at":"2025-04-06T17:22:35.648Z","repository":{"id":87063111,"uuid":"100504950","full_name":"gorosgobe/regression-algorithms","owner":"gorosgobe","description":"Implementation of different regression algorithms in Java.","archived":false,"fork":false,"pushed_at":"2017-10-02T14:52:47.000Z","size":45,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-12T23:29:02.420Z","etag":null,"topics":["java","linear-regression","matrix-inversion","matrix-multiplication","multithreading","polynomial-regression","qr-decomposition","regression","regression-algorithms","regression-models"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gorosgobe.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":"2017-08-16T15:35:38.000Z","updated_at":"2022-09-02T14:40:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"b73b2796-2fa9-44a5-9410-123859d1c6d4","html_url":"https://github.com/gorosgobe/regression-algorithms","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorosgobe%2Fregression-algorithms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorosgobe%2Fregression-algorithms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorosgobe%2Fregression-algorithms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorosgobe%2Fregression-algorithms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gorosgobe","download_url":"https://codeload.github.com/gorosgobe/regression-algorithms/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247518579,"owners_count":20951829,"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":["java","linear-regression","matrix-inversion","matrix-multiplication","multithreading","polynomial-regression","qr-decomposition","regression","regression-algorithms","regression-models"],"created_at":"2024-11-01T15:07:49.554Z","updated_at":"2025-04-06T17:22:35.623Z","avatar_url":"https://github.com/gorosgobe.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# regression-algorithms\nImplementation of different regression algorithms in Java.\n\n# How to use the library\nCurrently, the library supports three types of regression: Simple linear regression, multiple linear regression and simple polynomial regression.\n\n- Simple linear regression:\n```java\n//create a List of points (here manually inputed, the training data)\nList\u003cPoint\u003e points = Arrays.asList(new Point(1, 1), new Point(2, 3), new Point(4, 3),\n                new Point(3, 2), new Point(5, 5));\n//create the linear regression object passing the training data as the argument\nSimpleLinearRegression regression = new SimpleLinearRegression(points);\n//get slope coefficient\ndouble slopeCoefficient = regression.getSlopeCoefficient();\n//get intercept coefficient\ndouble intercept coefficient = regression.getInterceptCoefficient();\n//get a prediction for the training data supplied\ndouble valueToPredict = 3.4;\ndouble predictedValue = regression.getPrediction(valueToPredict);\n//get root mean square error of training data\ndouble rmse = regression.getRootMeanSquareError();\n```\n\n- Multiple Linear Regression\n```java\n//example using the data in testData3.txt\nFile file = new File(\"src/testData3.txt\");\n        Scanner sc = new Scanner(file);\n        sc.nextLine(); //ignores first line with comment\n        \n        List\u003cMultiplePoint\u003e points = new ArrayList\u003c\u003e();\n\n        while (sc.hasNext()) {\n            //assume number of tokens is multiple of 3\n            String y = sc.next();\n            String x1 = sc.next();\n            String x2 = sc.next();\n            List\u003cDouble\u003e list = new ArrayList\u003c\u003e();\n            list.add(Double.parseDouble(x1));\n            list.add(Double.parseDouble(x2));\n            points.add(new MultiplePoint(list, Double.parseDouble(y)));\n        }\n        \n//creates the multiple linear regression object and computes the coefficients\nMultipleLinearRegression mlr = new MultipleLinearRegression(points);\n//get the coefficients\ndouble[][] coefficients = mlr.getCoefficients();\n//get the List of Multiple Points\nList\u003cMultiplePoint\u003e list = mlr.getPoints();\n//get a prediction for the given independent variables\ndouble prediction = mlr.getPrediction(1.3, 2.78);\ndouble[] values = new double[] {1.3, 2.78};\ndouble prediction2 = mlr.getPrediction(values);\n```\n\n- Simple polynomial regression\n```java\n//as with Simple Linear Regression, supply a List of Points and the polynomial degree desired for the regression\nint polynomialDegreeDesired = 3;\nPolynomialRegression plr = new PolynomialRegression(points, polynomialDegreeDesired);\n//get back the list with points\nList\u003cPoint\u003e list = plr.getPoints();\n//get the polynomial degree\nint pd = plr.getPolynomialDegree();\n//get the computed coefficients\ndouble[][] coefficients = plr.getCoefficients();\n//get a prediction\ndouble value = 3.54;\ndouble prediction = plr.getPrediction(value);\n//get RMSE error for training data:\ndouble rmse = plr.getTrainingDataRootMeanSquareError();\n//get RMSE error for test data (used in computation of optimal polynomial regression)\ndouble rmse = plr.getTestDataRootMeanSquareError(testData);\n```\n  \n - Given test data to optimise the polynomial regression:\n  ```java\n  //computes the optimal polynomial regression for the supplied training data and test data\n  //if we want to have standard output\n  boolean terminalOutput = true;\n  PolynomialRegression optimalPLR = PolynomialRegression.getOptimalPolynomialRegression(trainingData, testData, terminalOutput);\n  ```\n  Produced output for example in PolynomialRegression: \n  ```\n  Points to analyse: 201\nThread: 0, Degree: 0, Error: 2449.8470901997493\nThread: 1, Degree: 4, Error: 1191.6880922848914\nThread: 0, Degree: 28, Error: 693792.2722850717\nThread: 1, Degree: 32, Error: 825061.6243167162\nThread: 2, Degree: 36, Error: 1291602.8773571763\nThread: 3, Degree: 40, Error: 3179747.571711865\n...\nThread: 1, Degree: 7, Error: 169.2523672185814\n...\nThread: 5, Degree: 52, Error: 1.9553379536494124E8\nThread: 5, Degree: 80, Error: 9.498507018861318E12\nThread: 6, Degree: 195, Error: 1.1208697729287957E33\nThread: 6, Degree: 196, Error: 1.6800940740814055E33\nThread: 6, Degree: 197, Error: 2.5183654098890806E33\nThread: 6, Degree: 198, Error: 3.774943548418527E33\nThread: 6, Degree: 199, Error: 5.658595080232076E33\nTime required: 24.880461799s\nOptimal degree: 7\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgorosgobe%2Fregression-algorithms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgorosgobe%2Fregression-algorithms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgorosgobe%2Fregression-algorithms/lists"}