Applications of Machine Learning Algorithms Speaker: Mohamed Elwakdy Date: 16/02/2017 Email: mohamed.elwakdy@statslab-bi.co.nz
Sponsors
Outline & Content What is Machine Learning? Machine Learning Algorithms Training and Testing Types of Classifiers Naive Bayes Classifier Support Vector Machine (SVM) Classifier Examples of Naive Bayes Classifier and SVM Classifier Using R Applications of Machine Learning Algorithms Emotion Recognition Speech Recognition
What is Machine Learning? Machine learning is the subfield of computer science that gives computers the ability to learn from data and this is very different than traditional computer programming. Traditional Programming Data Program Output
What is Machine Learning Machine Learning Data Training / Testing Program (System Classifier) Output Classification Accuracy
Machine Learning Algorithms The algorithms should extract useful information from samples to make training of the classifier and then getting a classification accuracy through making evaluation of the algorithms using testing samples. Training is the process of making the system able to learn using different types of Data, Signals or Images. Testing is the process to test the system and know its ability to discriminate between different types of Data, Signals or Images.
Training and testing Data/Images/Signals acquisition (Training/Testing) A Practical usage B Universal set A Practical usage B Training set (Training of Data/ Signals/ Images ) Testing set (Testing of Data/Signals /Images)
Machine Learning Algorithms Machine Learning tasks include: 1- Supervised Machine Learning task: Classification (discrete labels) A B C Supervised learning
Machine Learning Algorithms 2- Unsupervised Machine Learning task Clustering
Types of Classifiers There are two kinds of classifiers will be presented in this workshop: Naive Bayes Classifier Support Vector Machine (SVM)Classifier
Naive Bayes Classifier Naive Bayes is a simple technique for constructing classifier that is used to represent the vectors of features values of some objects for training and then use some other features of some other vectors of feature values for testing. For example, a fruit may be considered to be an apple if it is red, round, and about 5-7 cm in diameter. A Naive Bayes classifier will use these features for training. If I give the Naive Bayes classifier some other features of another apple, It will recognize that this fruit is an apple regardless if there is any possible correlation between the color, roundness, and diameter features or not.
Example of Naive Bayes Classifier using R Example of Naive Bayes Classifier using R We have features of three kinds of flowers: Setosa, Versicolor and Virginica in IRIS Data Set. We need to discriminate between these three kinds of flowers through their features so we will take some of three features as a training of Naive Bayes classifier and some of these features as a testing of this classifier to know the ability of this classifier to discriminate between these three kinds of flowers.
Example of Naive Bayes Classifier using Microsoft R The features, which are collected of these flowers, are Sepal length, Sepal width, Petal length and Petal width.
Example of Naive Bayes Classifier using R head function is used to get the first several rows of a matrix or data frame of iris Data Set: head (iris)
Example of Naive Bayes Classifier using Microsoft R summary function is used to get a meaningful summary of a data set; for each column of iris Data-Set such as the minimum value, maximum value and the mean value. summary (iris)
Example of Naive Bayes Classifier using R Make filtration of the iris Data Set by selecting some rows for testing. testidx <- which(1:length(iris[, 1])%%5 == 0) testidx [1] 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 [19] 95 100 105 110 115 120 125 130 135 140 145 150
Example of Naive Bayes Classifier using R Make selection of the rows which will be used to make training of the Naive Bayes Classifier. If you note that row 10 and 20 is not in the list of training matrix because these lines are selected as part of other rows which will be used for testing. iristrain <- iris[-testidx,] iristrain
Example of Naive Bayes Classifier using R Make selection of the rows which will be used for testing. If you note that rows 10 and 20 in the list of these rows because these rows are used for testing. iristest <- iris[testidx,] iristest
Example of Naive Bayes Classifier using R Use the library of Naive Bayes classifier which called klar. We don t need to make installation of klar because this backage is already installed in R. library(klar) Make training of the Naive Bayes Classifier using the training data as follows: nbmodel <- NaiveBayes(Species~., data=iristrain)
Example of Naive Bayes Classifier using R Make prediction of three kinds of flowers using testing data. Here, the classifier will predict with three kinds of the flowers based on the probabilities of these flowers. The highest probability indicates to the predicted flower which may Setosa,Versicolor or Virginica. prediction <- predict(nbmodel, iristest[,-5]) prediction
Example of Naive Bayes Classifier using R The last Step, we can see, the Naive Bayes classifier can predict with the Setosa and Versicolor flowers perfectly where the classification accuracy is 100%, but it can t predict the Virginica flower perfectly where the classification accuracy is 80%. table(prediction$class, iristest[,5])
Support Vector Machine (SVM) classifier SVM is basically a two-class classifier. The SVM Uses machine learning to solve classification problems. Training: Find a decision boundary (a hyperplane) that divides the data into two classes. There are two types of the Support Vector Machine Classifier: A- Linear Support Vector Machine Classifier B- Non-linear Support Vector Machine Classifier.
Example of Support Vector Machine (SVM) using R Here, we will use the previous example to make a preparation of data through selecting some rows in iris Data-set for training and some rows in iris Data-set for testing. testidx <- which(1:length(iris[,1])%%5 == 0) iristrain <- iris[-testidx,] # 120 samples iristest <- iris[testidx,] # 30 samples Use the library of SVM classifier which called e1071. We don t need to make installation of e1071 because this backage is already installed in R. library(e1071) Make training of SVM classifier as follows: model <- svm(species~., data=iristrain)
Example of Support Vector Machine (SVM) using R Using the SVM in prediction by testing the model with a new data. In this step, we will see the ability of SVM in discriminating between different types of Data of three kinds of flowers: Setosa, Versicolor and Virginica. prediction <- predict (model, iristest[,-5]) prediction
Example of Support Vector Machine (SVM) using R The last Step, we will see whether the SVM classifier can predict with all types of flowers based on the testing data which we gave to it or not. As we can see, the SVM classifier can predict with the Setosa and Versicolor flowers perfectly where the classification accuracy is 100%, but it can t predict the Virginica flower perfectly where the classification accuracy is 90%. table(iristest$species, prediction)
Applications of Machine Learning Algorithms EMOTION RECOGNITION Emotion recognition is the process in taking a facial expression in an image which represents the identifying human emotion and understand this emotions. The emotions detected are anger, contempt, disgust, fear, happiness, neutral, sadness, and surprise. https://www.youtube.com/watch?v=8yrufcospq I
Emotion Recognition
Emotion Recognition Algorithm Training Set including three facial expressions of Michael s face (happiness, neutral and sadness) Features Detection of Michael face Features Extraction of Michael s face Preparation of Data Clustering (put all data into clusters) Testing Set including three facial expressions of Michael s face (happiness, neutral and sadness) Features Detection of Michael face Features Extraction of Michael s face Preparation of Data Clustering (put all data into clusters) Classifier Classification Accuracy
Classification Accuracy Applications of Machine Learning Algorithms SPEECH RECOGNITION Speech recognition algorithms have the ability to understand spoken language through converting the acoustic signals which are captured using a microphone or a telephone, to a set of words. The recognized words, which are captured by a machine or program, are used an end in themselves for many applications such as data entry, commands & control and etc. https://www.youtube.com/watch?v=yxxrahvtafi
Classification Accuracy Speech Recognition Algorithm Training Set including some words Features Extraction of these words Preparation of Data Testing Set including some words Features Extraction of these words Preparation of Data Classifier
Applications of Machine Learning Algorithms Workshop Go to: https://www.meetup.com/auckland-machine- Learning-Meetup/events/237125412/ Discount code Use DATADUDE to get 10% off
Thank You