PHPackages                             divineomega/eloquent-attribute-value-prediction - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. divineomega/eloquent-attribute-value-prediction

Abandoned → [jord-jd/eloquent-attribute-value-prediction](/?search=jord-jd%2Feloquent-attribute-value-prediction)Library[Utility &amp; Helpers](/categories/utility)

divineomega/eloquent-attribute-value-prediction
===============================================

Predict attribute values for your Laravel Eloquent models using machine learning!

v2.0.0(2mo ago)1481.6k9[3 issues](https://github.com/Jord-JD/eloquent-attribute-value-prediction/issues)LGPL-3.0-onlyPHPPHP ^7.4 || ^8.0CI failing

Since Nov 7Pushed 2mo ago7 watchersCompare

[ Source](https://github.com/Jord-JD/eloquent-attribute-value-prediction)[ Packagist](https://packagist.org/packages/divineomega/eloquent-attribute-value-prediction)[ GitHub Sponsors](https://github.com/DivineOmega)[ RSS](/packages/divineomega-eloquent-attribute-value-prediction/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (6)Versions (7)Used By (0)

---

🖥️🧠💪 Eloquent Attribute Value Prediction
========================================

[](#️-eloquent-attribute-value-prediction)

 ❤️ **Machine Learning For Laravel Developers!** ❤️

 [ ![](https://github.com/Jord-JD/eloquent-attribute-value-prediction/workflows/Tests/badge.svg) ](https://github.com/Jord-JD/eloquent-attribute-value-prediction/actions) [ ![](https://camo.githubusercontent.com/fd847df209b95ad5524882794c6be3c4a75c0f5e563d46d171b7e92ff8a6274a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f4a6f72642d4a442f656c6f7175656e742d6174747269627574652d76616c75652d70726564696374696f6e2e737667) ](https://packagist.org/packages/jord-jd/eloquent-attribute-value-prediction/stats)

---

With this package you'll be able to predict attribute values for your Laravel Eloquent models using the power of machine learning! 🌟

With an intuitive syntax you can predict the values of both categorical (string) and continuous (numeric) attributes. Take a look at the examples below.

```
$animal = new \App\Models\Animal();
$animal->size = 'small';
$animal->has_wings = false;
$animal->domesticated = true;

$animal->name = $animal->predict('name');

// 'cat'

$predictions = $animal->getPredictions('name');

// [
//   'cat' => 0.43,
//   'dog' => 0.40,
//   'bird' => 0.10,
//   'elephant => 0.9,
// ]

$house = new \App\Models\House();
$house->num_bedrooms = 3;
$house->num_bathrooms = 1;

$house->value = $house->predict('value');

// 180000
```

Installation
------------

[](#installation)

To install just run the following Composer command.

```
composer require jord-jd/eloquent-attribute-value-prediction
```

After installation, you need to set up your model for attribute prediction.

Setup
-----

[](#setup)

Let's say you have an `IrisFlowers` table that contains data about each of three species of the Iris flower. In this example, we want to be able to predict the flower's species given the sepal length and width, and petal length and width.

First, we need to set up out `IrisFlower` model for attribut prediction.

This is done by adding the `HasPredictableAttributes` interface and `PredictsAttributes` trait to our model as shown below.

```
