{"id":13408993,"url":"https://github.com/torian257x/ai-php-rubix-wrap","last_synced_at":"2025-03-14T14:30:53.942Z","repository":{"id":57071934,"uuid":"383273497","full_name":"torian257x/ai-php-rubix-wrap","owner":"torian257x","description":"AI PHP is a wrapper for rubix ml to make AI very approachable","archived":false,"fork":false,"pushed_at":"2024-07-01T14:44:55.000Z","size":1220,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-07-31T20:32:30.955Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","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/torian257x.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":"2021-07-05T22:00:19.000Z","updated_at":"2024-07-01T14:44:59.000Z","dependencies_parsed_at":"2024-10-26T04:53:07.227Z","dependency_job_id":"172a1f87-0540-402e-b5a8-610228dc1082","html_url":"https://github.com/torian257x/ai-php-rubix-wrap","commit_stats":{"total_commits":49,"total_committers":1,"mean_commits":49.0,"dds":0.0,"last_synced_commit":"6c460b56249a3453964de7c9b63627dd30547d8e"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torian257x%2Fai-php-rubix-wrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torian257x%2Fai-php-rubix-wrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torian257x%2Fai-php-rubix-wrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torian257x%2Fai-php-rubix-wrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/torian257x","download_url":"https://codeload.github.com/torian257x/ai-php-rubix-wrap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243593263,"owners_count":20316157,"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-07-30T20:00:57.158Z","updated_at":"2025-03-14T14:30:53.452Z","avatar_url":"https://github.com/torian257x.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"\n# AI PHP Rubix Wrap\n\nA wrapper for  [Rubix ML](https://github.com/RubixML/ML) to make it very approachable\n\n\nExample:\n\n```php\n    $report = RubixService::train($data, 'column_with_label');\n```\n\nWhere `column_with_label` is the key of the multi dimensional array `$data` that contains the value that you want to predict.\n\nLet's make a simple example:\n\n```php\n$apartment_data = [\n        ['space_m2' =\u003e  10, 'price' =\u003e 100],\n        ['space_m2' =\u003e  20, 'price' =\u003e 200],\n        ['space_m2' =\u003e  30, 'price' =\u003e 300],\n        ['space_m2' =\u003e  40, 'price' =\u003e 400],\n        //...\n        ['space_m2' =\u003e 280, 'price' =\u003e 2800],\n        ['space_m2' =\u003e 290, 'price' =\u003e 2900],\n        ['space_m2' =\u003e 300, 'price' =\u003e 3000],\n];\n\n$report = RubixService::train($apartment_data, 'price');\n\nvar_export($report);\n\n/* \n  array (\n    'mean absolute error' =\u003e 68.88888888888889,\n    ...\n    'r squared' =\u003e 0.9796739130434783,\n    ...\n  )\n*/ \n\n$prediction = RubixService::predict(['space_m2' =\u003e 250]);\n//$prediciton ~2440\n    \n```\n\n[See full example of above code here](https://github.com/torian257x/ai-php-rubix-wrap/blob/master/tests/Unit/ReadmeExamplesTest.php)\n\n\n## Reports / Errors / Accuracy\n\nMean absolute error is basically the actual error you can expect in average. So _in average_ if trying to predict an apartment given the space, you'd be off, in average, by 68.88$\n\n`r squared` on the other hand gives more of a feeling how good the algorithm is in %. A high r squared means it works well. For categorical features like `cat` or `dog` a [different report is returned](https://docs.rubixml.com/latest/cross-validation.html#classification-and-anomaly-detection)\n\n\n\n\n\n## Estimators / Machine Learning Algorithm\n\n`RubixService::train()` will use a default estimator (machine learning algorithm) depending on the data. If you want to choose a different estimator I recommend reading here\n\n[rubix ml choosing an estimator](https://docs.rubixml.com/latest/choosing-an-estimator.html)\n\nNotice: Neural network is called **Multilayer Perceptron** in Rubix. Linear regression is called **Ridge**.\n\nPer default it uses [K-d Neighbors](https://docs.rubixml.com/latest/classifiers/kd-neighbors.html) or [K-d Neighbors Regressor](https://docs.rubixml.com/latest/regressors/kd-neighbors-regressor.html)\n\n`RubixService::train()` takes as well [transformers](https://docs.rubixml.com/latest/preprocessing.html) \n\n\nIn detail `RubixService:train()` does\n\n1. shuffle of `$data`\n2. train against 70% of `$data`\n3. test against 30% of `$data`\n\nYou can change that behaviour by using the argument `train_part_size` e.g. if you want to train on 80%, and test on 20% you would do `RubixService::train(... train_part_size: 0.8)`.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorian257x%2Fai-php-rubix-wrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftorian257x%2Fai-php-rubix-wrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorian257x%2Fai-php-rubix-wrap/lists"}