| Start |
|---|
| Classification using PHP-ML Classification in Machine Learning is the problem that identifies to which set of categories does a new observation belong. Classification falls under the category of Any algorithm that implements classification is known as classifier The classifiers supported in PHP-ML are
The SVC (Support Vector Classification)Before we can start with predicting a new observation, we need to train our classifier. Consider the following code The code is pretty straight forward. Now that we have the classifier trained we can start making some actual predictions. Consider the following codes that we have for predictions The classifier in the case above can take unclassified samples and predicts there labels. k-Nearest NeighborsThe classfier for this algorithm takes in two parameters and can be initialized like
Following is a short example on how to use this classifier NaiveBayes Classifier
The following code demonstrates a simple prediction implementation Practical caseTill now we only used arrays of integer in all our case but that is not the case in real life. Therefore let me try to describe a practical situation on how to use classifiers. Suppose you have an application that stores characteristics of flowers in nature. For the sake of simplicity we can consider the color and length of petals. So there two characteristics would be used to train our data. |
| Regression In classification using
Regression has the same Support Vector RegressionThis is the regression version for SVM(Support Vector Machine).The first step like in classification is to train our model. In regression Note that the predictions return a value outside the target. LeastSquares Linear RegressionThis algorithm uses PHP-ML also provides with the option of
Practical caseNow let us take an application of regression in real life scenario. Suppose you run a very popular website, but the traffic keeps on changing. You want a solution that would predict the number of servers you need to deploy at any given instance of time. Lets assume for the sake that your hosting provider gives you an api to spawn out servers and each server takes 15 minutes to boot. Based on previous data of traffic, and regression you can predict the traffic that would hit your application at any instance of time. Using that knowledge you can start a server 15 minutes before the surge thereby preventing your application from going offline. |
| Clustering Clustering is about grouping similar objects together. It is widely used for pattern recognition.
k-Meansk-Means separates the data into Note that the output contains 3 arrays because because that was the value of
The default constructor DBSCANAs opposed to
A quick sample for the same is as follows The code is pretty much self explanatory. One major difference is that there is no way of knowing the number of elements in output array as opposed to KMeans. Practical CaseLet us now have a look on using clustering in real life scenario Clustering is widely used in RemarksThe topic uses PHP-ML for all machine learning algorithms. The installation of the library can be done using The github repository for the same can be found here (opens new window). Also it is worth noting that the examples given are very small data-set only for the purpose of demonstration. The actual data-set should be more comprehensive than that. |
Read Article
https://develop.horje.com/learn/1434/reference