Skip to content

Commit

Permalink
Added composer installation instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdalpino committed Jun 18, 2020
1 parent 005e219 commit 6f731b2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,21 @@ This is a multilayer feed forward neural network for text sentiment classificati
- **Difficulty:** Hard
- **Training time:** Hours

## Installation
Clone the project locally using [Composer](https://getcomposer.org/):
```sh
$ composer create-project rubix/sentiment
```

> **Note:** Installation may take longer than usual because of the large dataset.
## Requirements
- [PHP](https://php.net) 7.2 or above

#### Recommended
- [Tensor extension](https://github.com/RubixML/Tensor) for faster training and inference
- 12G of system memory or more

## Installation
Clone the project locally with [Git](https://git-scm.com/):
```sh
$ git clone https://github.com/RubixML/Sentiment
```

> **Note:** Cloning may take longer than usual because of the large dataset.
Install project dependencies with [Composer](http://getcomposer.org/):
```sh
$ composer install
```

## Tutorial

### Introduction
Expand Down Expand Up @@ -142,6 +137,11 @@ Finally, we save the model so we can load it later in our other scripts.
$estimator->save();
```

Now you're ready to run the training script from the command line.
```php
$ php train.php
```

### Cross Validation
To test the generalization performance of the trained network we'll use the testing samples provided to us to generate predictions and then analyze them compared to their ground-truth labels using a cross validation report. Note that we do not use any training data for cross validation because we want to test the model on samples it has never seen before.

Expand Down Expand Up @@ -202,6 +202,11 @@ To generate the report, pass in the predictions along with the labels from the t
$results = $report->generate($predictions, $dataset->labels());
```

Execute the validation script from the command line like we see below.
```sh
$ php validate.php
```

Take a look at the report and see how well the model performs. According to the example report below, our model is 87% accurate.

```json
Expand Down Expand Up @@ -315,6 +320,11 @@ $prediction = $estimator->predictSample([$text]);
echo "The sentiment is: $prediction" . PHP_EOL;
```

To run the prediction script enter the following on the command line.
```sh
php predict.php
```

**Output**

```sh
Expand Down
8 changes: 8 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
"league/csv": "^9.5",
"rubix/ml": "^0.1.0-rc3"
},
"suggest": {
"ext-tensor": "For faster training and inference"
},
"scripts": {
"predict": "@php predict.php",
"train": "@php train.php",
"test": "@php validate.php"
},
"config": {
"preferred-install": "dist",
"sort-packages": true
Expand Down

0 comments on commit 6f731b2

Please sign in to comment.