MAGIC spots epic gamma-ray burst — CERN Courier

High Energy Gamma Particles Classification comparison between Support Vector Machines and Naive Bayesian

Rubén Acevedo
Dev Environment

--

High-energy gamma particles are cosmic messengers, originating from distant astrophysical sources or interactions within our own galaxy. These particles carry vital information about some of the most extreme environments in the universe, including supernovae, pulsars, and active galactic nuclei. Detecting and classifying these gamma rays is crucial for understanding the universe's fundamental processes, but the task is far from trivial due to the complexity and diversity of the data collected from high-energy particle detectors.

This article is actually a summary of the study carried out on the notebook found clicking here.

I invite you to take a look at how programming languages can help us better understand the universe every day.

What is the Magic Gamma Telescope?

The MAGIC (Major Atmospheric Gamma Imaging Cherenkov) telescope is an observatory for gamma-ray astronomy, located at the Roque de los Muchachos Observatory on the island of La Palma in Spain. It consists of two large Cherenkov telescopes that detect high-energy gamma rays, allowing scientists to study astrophysical phenomena such as gamma-ray bursts, active galactic nuclei, and gamma-ray sources. What makes MAGIC unique is its capacity to observe gamma rays in the energy range between 30 GeV (gigaelectronvolts) and 100 TeV (teraelectronvolts), providing valuable insights into the most energetic processes in the universe.

What about the data we extract from it?

Data extracted from the MAGIC gamma telescope is harnessed to develop a predictive model for distinguishing between gamma rays and hadrons in cosmic ray events. Leveraging the telescope's exceptional capability to detect high-energy gamma rays, we aim to advance our understanding of astrophysical phenomena. By applying machine learning techniques to the rich dataset, we strive to uncover distinct patterns and features that differentiate gamma rays, which originate from celestial sources, from hadrons, which are often background noise.

We will use two different classification algorithms: Support Vector Machines and Naive Bayes. We will discuss how each of them works, just after a quick description of the dataset.

About the dataset

We'll thank UCI Machine Learning Repository for providing all the free data used in this project. You can also access the dataset through the link below: https://archive.ics.uci.edu/dataset/159/magic+gamma+telescope.

first 5 rows of dataset.

Attribute information:

1. fLength: continuous # major axis of ellipse [mm]

2. fWidth: continuous # minor axis of ellipse [mm]

3. fSize: continuous # 10-log of sum of content of all pixels [in #phot]

4. fConc: continuous # ratio of sum of two highest pixels over fSize [ratio]

5. fConc1: continuous # ratio of highest pixel over fSize [ratio]

6. fAsym: continuous # distance from highest pixel to center, projected onto major axis [mm]

7. fM3Long: continuous # 3rd root of third moment along major axis [mm]

8. fM3Trans: continuous # 3rd root of third moment along minor axis [mm]

9. fAlpha: continuous # angle of major axis with vector to origin [deg]

10. fDist: continuous # distance from origin to center of ellipse [mm]

11. class: g,h # gamma (signal), hadron (background)

About the algorithms

Support Vector Machines

The core idea behind SVM is to find an optimal hyperplane that best separates data points belonging to different classes in a high-dimensional feature space.

SVM can be of two types:

  • Linear SVM: Linear SVM is used for linearly separable data, which means if a dataset can be classified into two classes by using a single straight line, then such data is termed as linearly separable data, and classifier is used called as Linear SVM classifier.
  • Non-linear SVM: Non-Linear SVM is used for non-linearly separated data, which means if a dataset cannot be classified by using a straight line, then such data is termed as non-linear data and classifier used is called as Non-linear SVM classifier.

The plan to use SVM in this project is to take advantage of the low number of outliers in the data and cluster it by group of classes (gamma/hadron) bringing high predictability to the model.

Naive Bayes

The Naive Bayes algorithm is a probabilistic machine learning method primarily used for classification tasks, such as spam detection, sentiment analysis, and document categorization. It is based on Bayes' theorem, which relates conditional probabilities.

Gaussian Naive Bayes is a variant of the Naive Bayes algorithm that is specifically designed for data where the features (attributes or variables) are continuous and follow a Gaussian (normal) distribution. It's an extension of the classic Naive Bayes algorithm, which assumes that features are categorical or discrete.

Naive Bayes combines the probabilities from all the features and the prior probabilities for each class using Bayes' theorem to determine the most likely class label for the given data;

Test Results

Here we can check the classification reports from both algorithms:

Support Vector Machines:

precision    recall  f1-score   support

0 0.81 0.81 0.81 1347
1 0.89 0.89 0.89 2457

accuracy 0.86 3804
macro avg 0.85 0.85 0.85 3804
weighted avg 0.86 0.86 0.86 3804

Naives Bayes:

precision    recall  f1-score   support

0 0.66 0.40 0.50 1347
1 0.73 0.89 0.80 2457

accuracy 0.71 3804
macro avg 0.69 0.64 0.65 3804
weighted avg 0.70 0.71 0.69 3804

Understanding the results

As we can see with the classification report results, the Support Vector Machines (SVM) algorithm has demonstrated superior accuracy in this specific situation compared to the Naive Bayes method. This notable performance difference can be attributed to the nature of the dataset, which exhibits a relatively low number of outliers. SVMs excel in scenarios where data tends to be well-separated and outliers are minimal, as they can effectively identify the optimal hyperplane for classification. This characteristic makes SVMs particularly well-suited for applications like predicting particles, where precision and robustness in handling data outliers are crucial. While Naive Bayes remains a valuable tool in machine learning, the choice of algorithm should always consider the unique characteristics of the data and the specific problem at hand, as illustrated by the remarkable accuracy achieved by SVMs in this context.

Conclusion

As the field of particle physics and astrophysics continues to advance, machine learning techniques like SVM and NB provide indispensable tools for unlocking the secrets of the universe. Their synergy, complementing each other's strengths and weaknesses, ensures that we are better equipped to face the challenges posed by high-energy gamma particle classification, ultimately bringing us closer to understanding the cosmic phenomena that shape our universe.

Author

Rubén Acevedo is a data scientist with a passion for the idea of using technology to address critical challenges in the fields of Science, Economics, Social Causes and Healthcare.

You can contact me through my email ruben.fernando@pucpr.edu.br if you find it necessary :)

Thank you!

Rubén Acevedo

--

--

Rubén Acevedo
Dev Environment

Data scientist, caring brother and passionate writer.