From 6f731b2582a4f1ad38adf8f970f7bda3c80e1e0e Mon Sep 17 00:00:00 2001 From: Andrew DalPino Date: Thu, 18 Jun 2020 15:12:36 -0500 Subject: [PATCH] Added composer installation instructions --- README.md | 36 +++++++++++++++++++++++------------- composer.json | 8 ++++++++ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index c17b8dd1..bc110aa9 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,14 @@ 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 @@ -11,19 +19,6 @@ This is a multilayer feed forward neural network for text sentiment classificati - [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 @@ -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. @@ -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 @@ -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 diff --git a/composer.json b/composer.json index ba6bebf5..b5f2013a 100644 --- a/composer.json +++ b/composer.json @@ -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