Skip to content

deltastateonline/ml-php

Repository files navigation

Machine Learning Using PHP-ML, implementing image classification.

Attempt to use supervised machine learning to classify email attachment images as either being logos or photos of damages. When emails are being processed, any attachments which are images (png, jpg or gif) can either be logos or be valid images which have to be kept for further processing. Features about the images have to be obtained and used to train a model which the PHP-ML library can use to make predictions.

Libraries Used

  • PHP-ML - Machine Learning library for PHP
  • pChart - a PHP Charting library

Installation

  • Create two folders , one to hold logo training sample and one for the photos training sample,
  • Create a subfolder called "images" in each folder.
  • Create features from training sets , all features are stored in csv files in the features folder
php image.creation.php {training sample folder} {target class} > "{features folder}"

For example
echo "Create Features for Logos"
php image.creation.php training.logos 0 > "features\\logo.csv"

echo "Create Features for Photos"
php image.creation.php training.photos 1 > "features\\photos.csv"

echo "Create Features for other data set"
php image.creation.php sample.photos 99 > "features\\samples.csv"
  • Train model
"C:\xampp718\php\php.exe" "predictions\prediction.php"
  • Validate Model
"C:\xampp718\php\php.exe" "predictions\prediction.validate.php" "{csv files in the features folder}"

For example
"C:\xampp718\php\php.exe" "predictions\prediction.validate.php"  "logo.csv"
"C:\xampp718\php\php.exe" "predictions\prediction.validate.php"  "photos.csv"
"C:\xampp718\php\php.exe" "predictions\prediction.validate.php"  "samples.csv"
  • Make a Prediction on images
"C:\xampp718\php\php.exe" "image.prediction.php" {image file name}
For example
"C:\xampp718\php\php.exe" "image.prediction.php" "C:\Development\logos\misc.images\thumbnail_image3.jpg"
"C:\xampp718\php\php.exe" "image.prediction.php" "C:\Development\logos\misc.images\baffy.jpg"
"C:\xampp718\php\php.exe" "image.prediction.php" "C:\Development\logos\misc.images\pillow.jpg"

PHP-ML - Machine Learning library for PHP

Fresh approach to Machine Learning in PHP. Algorithms, Cross Validation, Neural Network, Preprocessing, Feature Extraction and much more in one library. PHP-ML requires PHP >= 7.0.

Official Documentation

Documentation for this library can be found on the PHP-ML website.

pChart - a PHP Charting library

pChart is a PHP library that will help you to create anti-aliased charts or pictures directly from your web server. You can then display the result in the client browser, sent it by mail or insert it into PDFs. pChart provide object oriented coding syntax and is fully in line with the new web standards allowing you to enhance your web2.0 applications. This library must use 5.6 or less.

  • Create Histogram Allows you to create histograms from the csv files. The Historgram file will be created in the 'folder.histogram' directory.
"C:\xampp\php\php.exe" "create.histograms.php" "training.logos"

Histogram of Logos

Brisbane Collision Center BMW

Histogram of Photos

Photos 1 Photos 2

About

Machine Learning Using PHP-ML, implementing image classification

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published