Translate

Showing posts with label Orange. Show all posts
Showing posts with label Orange. Show all posts

Wednesday, August 23, 2023

Violin Plot - Compare Data

Contrasting and comparing are part of data analysis to make vital decisions. A violin chart integrated with Box Plot is one of the charts that can be used to compare data. Let us see how we can utilize the Orange data mining tool to compare data using the Violin chart. 

Let us assume that the following is the dataset that we need to compare. 


In this dataset, there are five variables to compare. If you simply use a Violin chart without any preprocessing, you cannot compare charts in one chart. Therefore, there are a few preprocessing tasks to be done.

In the above preprocessing tasks, separate processing tasks are used for each variable. Select Columns, Edit Domain, and Feature Constructor are used. You can download the Orange workflow at ODM/Violine-Blog.ows at main · dineshasanka/ODM (github.com) 

Finally, all data flows are connected and then used to Violin Plot, as shown below.


Now you can see from the above chart, it is easily can be compared. In the above example, X1 has higher values.

Saturday, July 29, 2023

Clustering as Pre-Processing Technique for Classification

Clustering is often used to identify natural groups in a dataset. Since the clustering technique does not depend on any independent variable, the clustering technique is said to be unsupervised learning. The classification technique is supervised as it models data for a target or dependent variable. This post describes clustering as a pre-processing task for classification. This post has used the Orange Data Mining tool to demonstrate the above scenario. 

Following is the complete orange data mining workflow, and this is available in the Git Hub as well. 


The attrition sample dataset is used to demonstrate the above scenario. This dataset contains 18 variables with 1470 instances. Then the Jaccard distance is used, and it is essential to remember that you may have to choose a different distance technique in order to improve the results. 


Then hierarchical clustering is used for three clusters as too many clustering will have smaller clusters and may cause overfitting. Following is the cluster distribution for the three clusters. 


After the clustering is completed, the dataset is selected for each cluster and unnecessary columns (Clsuter and Selected) are removed.  Then for each cluster, different classification techniques were executed. This scenario uses SVM, Logistic Regression, Neural Network, Random Forest, AdaBoost, Naive Bayes, Tree, and kNN classification techniques. 

When classification techniques were executed for the entire dataset, without clustering, the best classification technique was Logistic Regression with a Classification accuracy of 87%.  

Following are the classification accuracies and other evaluation parameters for each cluster once it is evaluated with all the above said eight different classification techniques.


The above table shows that C1 and C2 clusters have higher accuracy than the full dataset. However, the third cluster performance is not as good as the overall dataset classification.
This technique is better when there are large volumes of data if not clustering will reduce the data which can lead to model overfitting. 

Thursday, August 25, 2022

How to Confuse Machine Learning

This is a post that was shared in LinkedIn and thought of exploring this with my pet tool Orange Data Mining tool.



First, separate these images into single images randomly. Since there is a small number of images, thought of employing clustering over classification. 

Following is the very simple Orange flow and it can be found at GitHub as well. 


As you could see, it is a very simple Orange workflow. Inception v3 was used as the embedded and Cosine distance was used as the distance calculation. Then Hierarchical Clustering was used. it is as very clear clusters which can be seen in the following figure.


Then the cluster distribution as below. 


So, you can't confuse Machine Learning as you think.

Thursday, November 18, 2021

Cluster Validation - Purity Calculation

As we know, clustering is an unsupervised technique. When it comes to classification, there are a lot of evaluation techniques such as Precision, Recall, F1, MCC etc. However, what are the techniques that can be used to evaluate clustering techniques. Purity calculation is one of the simplest calculations to evaluate your clusters.

In the Purity cluster quality measure, we will analyse the cluster distribution with respect to a selected variable. Let us look at how to calculate Purity in a Text Clustering using Orange and the following is the Orage flow. 


Further, you can get the Orange flow from Github. 
First, let us look at how the Purity is calculated. 
Let us assume that following are the clusters and data distribution.


In each cluster, the maximum number of objects that are falling to each cluster is calculated. For example, in Cluster 1, X has three instances while Cluster 2 has three instances of O and Cluster 3 has four L instances. Those numbers are added up and divided by the total number of instances which is 16. 

Let us look at this example with our popular film review dataset.

After the text Preprocessing, the Loving Clustering technique is used. Following is the cluster distribution with respect to the review classification.

So the Purity is (190 + 193 + 158 + 123+ 136 + 112+124+102 +11) / 2000. Ideally, this should be close to 1 meanwhile in the case of multi-class we can calculate the Purity with a Minimum value which should be close to 0. 
Entropy is another calculation that is performed to measure the Cluster Quality which we will leave for another day.

Sunday, October 24, 2021

Federalist Papers : Case for Naïve Bayes Text Classification

Alexander Hamilton, James Madison, and John Jay

The Federalist Papers is a collection of 85 articles and essays written by Alexander Hamilton, James Madison, and John Jay. 1787 after the UK was thrown out from US, many were in the view that 13 counties should rule independently. 

John Jay, James Madison, Alexander Hamilton wrote letters independently to pursue that the US should have a strong central government with the individual state government. Between 1787 - 1788 these papers were published under the pseudonym PUBLIS. While the authorship of 73 of The Federalist essays is fairly certain, the identities of those who wrote the twelve remaining essays are disputed by some scholars. In 1963 this dispute was fixed by Mosteller and Wallace using Bayesian Methods.

Let us see do a simple analysis of these papers by performing a analyse of the titles of these papers using the Orange Data Mining Tool. You can retrieve the sample files and the Orange workflow from dineshasanka/FederalistPapersOrangeDataMining (github.com). 

Following is the Orange Data Mining workflow and let us go through important controls. 

After importing the CSV, text was preprocessed and word cloud was generated to identify the word distribution. 


Bags of Words are used to identify the keywords. Then six classifiers are used which are Neural Network, Naive Bayes, Decision Trees, Random Forest, SVM and AdaBoost. Following is the evaluation results and it shows that the Random Forest technique has the edge over the other techniques 

We can build the decision tree as shown below. 

Wednesday, October 20, 2021

Simple Rule Based Text Classification using Orange Data Mining

Typically, we use a lot of algorithms to perform simple classification such as Decision Trees, SVM, Naive Bayes, Logistic Regression etc. How about using simple rules. For example, can't we look at some specific words to define whether it is a positive or negative sentiment? how about words like pathetic, worst, poor for negative sentiments whereas great, fabulous, superb for positive. 

Let us see how we can use the Orange Data Mining tool to achieve the above objective. Following is the Orange Data Mining flow.


You can download the workflow from the Github  dineshasanka/Orange-Data-Mining---Text-Analyitics (github.com) 

Let us explain the package one by one. 
1. From the import documents, a film review data set was extracted.
2. Preprocess Text was used to convert the texts to lowercase and remove some URLs. 
3. Statistics is the key component in this package. This is where you identify the keywords.


4. Then using two aggregate columns were used to create two POS and NEG columns. This will sum the two positive and negative sentiments to the two columns.


5. As of now this is the dataset. 



6. Two feature constructors were introduced. If you are good at Python you can use a Python Script component. 

7. Depending on the positive and negative keywords, we can introduce a new column predicted as follows. 


8. Let us look at the confusion matrix from Pivot table control.

You can see that it has 70% accuracy while more than 85% accuracy for negative sentiments. 

This technique shows that you do not need to rely on complex algorithms but a simple technique will give you more accuracy. 

Monday, October 4, 2021

Orange Data Mining - Text Processing

During the last few blog posts, we have discussed how Image processing can be used for different purposes using the popular Orange Data Mining tool. Now let us move our discussions to Text analytics another one of the complex data sources. 
Text tab in the Orange Data Mining tool is not available by default and that has to be added to the tool by updating the add-in. From time to time, there can be updates that have to be added periodically. 

Now let us see what are the basic functions of the Orange Data Mining for Text Analytics.



Today let us use a few and important features for Text Mining. As you can see, there are existing corpora (Text datasets) for you to use as shown below. 


Further, if you have proper access, you can extract data from NY Times, Pubmed, Twitter etc. 

Let us use the customized dataset to perform simple text preprocessing technique. By using, Import Documents widget.  IMDB review dataset was used as it has 2000 positive and negative reviews. You can download the relevant Orange Data Mining workflows from this link. https://github.com/dineshasanka/Orange-Data-Mining---Text-Analyitics.git and following the entire workflow.


After the 2000 documents are imported, we need to perform some preprocessing techniques in order to clean data. This is something very important task in text analytics as you tend to see a lot of issues with the text due to the free form nature of text data. 


The above configuration covers basic preprocessing techniques, Tokenization, filtering and transformation. In this example, we have not used other available preprocessing techniques such as N-Gram, normalization and POS tag. 
Tokenization will decide how would to separate words from the sentences and the filter will decide to remove unnecessary words. Since we have used English stopwords and customized text to remove the non-semantic words. The basic transformation was done by removing URLs and converting the text to lowercase. 
Now you can visualize the words in the word cloud as shown in the following screen.


Apart from word cloud analysis, you can perform simple statistics on your text documents using the Statistics widgets. 

Then you can view the data either from a data table or from the feature statistics.  

Thursday, September 16, 2021

Grouping the Flags - Image Processing using Orange


If you look at different flags of countries, you would think that some flags look similar. This post is to explain how Orange Data Mining Tool can be used in order to cluster images into groups. You can get the dataset and Orage Package in ImageProcessing-Orange (github.com).

This is a simple Data Mining Package, this will show that how easily you can perform image processing in Orange. 


Let us see how each cluster so that we can see how the grouping is done. 

The following does not have all the clusters as it has only the distinguished clusters. 

Cluster 2 


Cluster 3

Cluster 9


Cluster 10

Though this was done for fun, you can how the Orange tool can be used to determine clusters of images.

Thursday, August 12, 2021

Matching People when they are Getting Older

We have done multiple image processing tasks with Orange over the last few blog posts. We were looking at how to match when modelling personals are with and without their popular makeups. We have done this for both Hollywood and Bollywood beauties. Further, we looked at how to classify people with and without face masks on their faces after looking at few image classification techniques. In the last post, we have discussed how to identify actresses when they are without their fancy hair. 

Today we are looking at how to identifying when these modellers become elder. 

These are the images of actresses who have become elder. 


We can use the Orange Data Mining tool similar to what we did last time. 


The openface was used for Image Embedding while cosine distance was used for the distance measure in the Neighbors. 
Though we had higher success rates in the previous activities, this activity was able to match only 11 out of 42 images. Does that mean, though you can match these beauties with no makeup or less hair, it is difficult to match them when they are getting elder!

Thursday, July 29, 2021

Detect Modelers with less hair using Orange

Around a few months before, we did few experiments with the Orange tool with different image sets. During this series, we first did the image clustering for images such as birds, trees etc. The same technique was used to identify famous and historical paintings. The next task was more towards the current environment that we are living in, and it is about identifying people who are wearing Masks. Finally, we discussed how to identify modellers without their makeup and we did for both Hollywood and Bollywood. 
Like makeup another challenging task is to identify these modellers when they have less or no hair. These are the images for those modellers with hair and less or no hair. 


The orange package is much simpler as shown below. 

The Openface embedding was used for both Image Embeddingwhile the cosine distance was for the Neighbors. out of the 19 images, three were dropped by the Image embedding and out of the other 16 images, 11 were correctly matched. 



Thursday, April 15, 2021

Recognizing Hollywood Beauties when they are without Makeup

Less than one month ago, by using Orange Data Mining Tool, we looked at how to recognize Bollywood beauties when they are not under their fancy makeup. 
Let us do the same exercise with Hollywood Beauties. 
These are stars that we are going to match.


These are the image of them when they are without makeup.


We have used the same Package in Orange which is shown in the below figure. 


In the Image Embedding, we have used OpenFace embedder and the Cosine Distance in the Neighbours. Four images were ignored in the Embedding. 
Following are perfect matches of those actresses with and no makeups. 


Out of 26 images, 8 of them were matched with the first image and many of them were matched when they were matched to 3rd neighbour.