{"id":3499,"date":"2025-08-31T11:12:59","date_gmt":"2025-08-31T09:12:59","guid":{"rendered":"https:\/\/neuraldesigner.com\/learning\/gamma\/"},"modified":"2026-08-06T13:29:28","modified_gmt":"2026-08-06T11:29:28","slug":"gamma","status":"publish","type":"learning","link":"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/","title":{"rendered":"Detect gamma rays using machine learning"},"content":{"rendered":"<style>\n.nds{width:100vw;margin-left:calc(50% - 50vw);padding:22px 24px 14px;background:#eee;color:#1b2635;font-family:\"Outfit\",\"Roboto\",Arial,sans-serif}\n.nds *{box-sizing:border-box}.nds-wrap{width:min(100%,1200px);margin:0 auto}.nds a{text-decoration:none;color:#2d799f}\n.nds-executive{margin:0 0 34px;padding:32px;border-radius:20px;background:linear-gradient(135deg,#12354b,#245e80);color:#fff}.nds-executive h2{margin:0 0 12px;color:#fff;font-size:30px}.nds-executive p{font-size:18px;line-height:1.55}\n.nds-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin-top:22px}.nds-kpi{padding:18px;border:1px solid rgba(255,255,255,.18);border-radius:14px;background:rgba(255,255,255,.1)}.nds-kpi strong{display:block;font-size:25px}.nds-kpi span{font-size:13px}\n.nds-actions,.nds-audience,.nds-downloads{display:flex;flex-wrap:wrap;justify-content:center;gap:12px;margin:22px 0}.nds-actions a,.nds-downloads a{padding:12px 20px;border-radius:24px;background:#245e80;color:#fff;font-weight:700}.nds-executive .nds-actions a{background:#fff;color:#12354b}\n.nds-toc{display:flex;flex-wrap:wrap;justify-content:center;gap:10px;margin:0 0 42px;padding:0;list-style:none}.nds-toc a,.nds-audience span{display:block;padding:9px 14px;border-radius:20px;background:#e9f2f8;color:#12354b;font-weight:600}\n.nds-card{margin:0 0 54px;scroll-margin-top:90px}.nds-card h2{margin:0 0 20px;padding-bottom:12px;border-bottom:1px solid #dbe5ec;color:#001233;font-size:24px}.nds-card p,.nds-card li{font-size:16.5px;line-height:1.6}.nds-card img{display:block;width:auto;max-width:min(640px,100%);height:auto;margin:24px auto;border-radius:12px}.nds-card img.nds-architecture{width:min(1000px,100%);max-width:100%}\n.nds-value-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;margin:22px 0}.nds-value{padding:20px;border:1px solid #dce8ef;border-radius:14px;background:#f8fbfd}.nds-note{margin:20px 0;padding:18px 20px;border-left:4px solid #56a1c8;border-radius:0 12px 12px 0;background:#f6fafc}.nds-note--warning{border-left-color:#d79a29;background:#fff9ed}\n.nds-table-scroll{max-width:100%;overflow-x:auto}.nds-card table{width:auto;max-width:100%;margin:24px auto;border-collapse:collapse;background:#fff}.nds-card th,.nds-card td{padding:11px 16px;border-bottom:1px solid #e2e9ee}.nds-card thead th{background:#12354b!important;color:#fff!important}.nds-card tbody th{background:#eaf2f6!important;color:#12354b!important;text-align:left}.nds-card tbody tr:nth-child(even) th{background:#f4f8fa!important}.nds-card tbody td{color:#33424f!important}\n.nds-figure-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}.nds-figure-grid figure,.nds-architecture-figure{margin:0;padding:16px;border:1px solid #dce8ef;border-radius:15px;background:#f8fbfd}.nds-figure-grid img{width:100%;max-width:100%;margin:0 auto 12px}.nds-card figcaption{color:#405361;font-size:14px;line-height:1.45}\n@media(max-width:820px){.nds-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.nds-value-grid{grid-template-columns:1fr}}\n@media(max-width:620px){.nds{padding:12px 14px}.nds-kpis,.nds-figure-grid{grid-template-columns:1fr}.nds-executive{padding:24px 20px}.nds-card table{font-size:13px}.nds-card th,.nds-card td{padding:9px 8px}}\n<\/style>\n<style>\n.nds code{padding:2px 5px;border-radius:4px;background:#e8eef2;color:#12354b}\n.nds-card h3{margin:27px 0 12px;color:#12354b;font-size:20px}\n.nds-card pre{margin:22px auto;padding:20px 22px;max-width:760px;overflow-x:auto;border:1px solid #dce5eb;border-radius:14px;background:#f7fafc!important;color:#173246!important;font:13px\/1.55 Consolas,Menlo,monospace}\n.nds-card pre code{padding:0;background:transparent;color:inherit}\n.nds-centered-figure{width:min(720px,100%);margin:24px auto;padding:16px;border:1px solid #dce8ef;border-radius:15px;background:#f8fbfd}\n.nds-centered-figure img{width:100%;max-width:100%;margin:0 auto 12px}\n.nds-figure-full{grid-column:1\/-1;width:min(580px,100%);justify-self:center}\n.nds-flow{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:10px;margin:24px 0}\n.nds-flow div{position:relative;display:flex;min-height:96px;align-items:center;justify-content:center;padding:15px 10px;border-radius:13px;background:#12354b;color:#fff;text-align:center;font-weight:700}\n.nds-flow div:not(:last-child):after{content:\"\u2192\";position:absolute;right:-15px;top:50%;z-index:2;transform:translateY(-50%);color:#56a1c8;font-size:21px}\n.nds-metrics td:nth-child(2),.nds-confusion td{text-align:right;font-variant-numeric:tabular-nums}\n.nds-deployment-grid{display:grid;grid-template-columns:minmax(0,2fr) minmax(250px,1fr);gap:22px;align-items:center}\n.nds-result{padding:26px;border:1px solid #cfe1eb;border-radius:16px;background:#f7fbfd;text-align:center}\n.nds-result span,.nds-result strong{display:block}.nds-result strong{margin:8px 0;color:#12354b;font-size:34px}\n@media(max-width:1000px){.nds-flow{grid-template-columns:repeat(3,1fr)}.nds-flow div:after{display:none}}\n@media(max-width:760px){.nds-flow,.nds-deployment-grid{grid-template-columns:1fr}.nds-flow div:after{display:none}}\n<\/style>\n<div class=\"nds\" data-science-profile=\"physical-chemical\">\n<div class=\"nds-wrap\">\n<section class=\"nds-executive\">\n<h2>Separate simulated gamma-ray showers from hadronic background<\/h2>\n<p>This reproducible benchmark maps ten image descriptors from a simulated imaging atmospheric Cherenkov telescope to a hadron-class score. On 3,804 held-out events, the final model reaches an ROC AUC of 0.935. At the default score threshold of 0.50 it retains 90.2% of gamma events while rejecting 82.8% of hadronic background.<\/p>\n<div class=\"nds-kpis\">\n<div class=\"nds-kpi\"><strong>0.935<\/strong><span>testing ROC AUC<\/span><\/div>\n<div class=\"nds-kpi\"><strong>90.2%<\/strong><span>gamma efficiency at score 0.50<\/span><\/div>\n<div class=\"nds-kpi\"><strong>82.8%<\/strong><span>hadron rejection at score 0.50<\/span><\/div>\n<div class=\"nds-kpi\"><strong>3,804<\/strong><span>held-out testing events<\/span><\/div>\n<\/div>\n<div class=\"nds-actions\"><a href=\"#6-validation\">Review operating points<\/a><a href=\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2026\/08\/gamma.csv\">Download the data<\/a><\/div>\n<\/section>\n<ul class=\"nds-toc\">\n<li><a href=\"#1-scientific-objective\">Scientific objective<\/a><\/li>\n<li><a href=\"#2-data-provenance\">Data and provenance<\/a><\/li>\n<li><a href=\"#3-model\">Model<\/a><\/li>\n<li><a href=\"#4-training\">Training<\/a><\/li>\n<li><a href=\"#5-selection\">Selection<\/a><\/li>\n<li><a href=\"#6-validation\">Validation<\/a><\/li>\n<li><a href=\"#7-inference\">Inference<\/a><\/li>\n<li><a href=\"#8-validity\">Validity<\/a><\/li>\n<\/ul>\n<section id=\"1-scientific-objective\" class=\"nds-card\">\n<h2>1. Scientific objective<\/h2>\n<p>The task is to rank telescope-camera events by how compatible their image morphology is with hadronic background. Events with a low hadron-class score are gamma-like candidates. This is an event-selection benchmark for simulated data; it is not a source detection, a flux measurement or evidence of a gamma-ray signal.<\/p>\n<div class=\"nds-value-grid\">\n<div class=\"nds-value\"><strong>Candidate selection<\/strong><\/p>\n<p>Reduce the background passed to downstream source and spectral analyses while retaining a controlled fraction of gamma events.<\/p>\n<\/div>\n<div class=\"nds-value\"><strong>Operating-point design<\/strong><\/p>\n<p>Choose a score threshold from the required gamma efficiency and accepted hadron leakage instead of optimizing accuracy alone.<\/p>\n<\/div>\n<div class=\"nds-value\"><strong>Reproducible benchmark<\/strong><\/p>\n<p>Inspect the exact split, model, regenerated analyses and executable Python export used for the reported results.<\/p>\n<\/div>\n<\/div>\n<div class=\"nds-audience\"><span>Gamma-ray astronomers<\/span><span>IACT analysts<\/span><span>High-energy astrophysics<\/span><span>Detector and ML teams<\/span><\/div>\n<div class=\"nds-note\"><strong>Scope.<\/strong> The data contains Monte Carlo events described by ten Hillas-style image parameters. The network supports simulated event ranking only; transfer to recorded telescope data requires independent, run-aware validation.<\/div>\n<\/section>\n<section id=\"2-data-provenance\" class=\"nds-card\">\n<h2>2. Data and provenance<\/h2>\n<p>The <a href=\"https:\/\/archive.ics.uci.edu\/dataset\/159\/magic+gamma+telescope\">MAGIC Gamma Telescope data set<\/a> contains 19,020 simulated events with no missing values: 12,332 gamma events (<code>g<\/code>) and 6,688 hadronic-background events (<code>h<\/code>). The examples were generated with CORSIKA and processed into approximately triggered camera images.<\/p>\n<p>The analysis uses the following ten input fields exactly as they appear in the downloadable CSV and the exported model.<\/p>\n<div class=\"nds-table-scroll\">\n<table>\n<thead>\n<tr>\n<th>CSV field<\/th>\n<th>Physical meaning<\/th>\n<th>Unit or scale<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th><code>ellipse_major_axis<\/code><\/th>\n<td>Major-axis extent of the shower image<\/td>\n<td>mm<\/td>\n<\/tr>\n<tr>\n<th><code>ellipse_minor_axis<\/code><\/th>\n<td>Minor-axis extent of the shower image<\/td>\n<td>mm<\/td>\n<\/tr>\n<tr>\n<th><code>log_total_pixel_signal<\/code><\/th>\n<td>Base-10 logarithm of total pixel content<\/td>\n<td>log signal<\/td>\n<\/tr>\n<tr>\n<th><code>two_brightest_pixels_signal_ratio<\/code><\/th>\n<td>Signal fraction in the two brightest pixels<\/td>\n<td>ratio<\/td>\n<\/tr>\n<tr>\n<th><code>brightest_pixel_signal_ratio<\/code><\/th>\n<td>Signal fraction in the brightest pixel<\/td>\n<td>ratio<\/td>\n<\/tr>\n<tr>\n<th><code>brightest_pixel_center_offset_major_axis<\/code><\/th>\n<td>Projected brightest-pixel offset along the major axis<\/td>\n<td>mm<\/td>\n<\/tr>\n<tr>\n<th><code>major_axis_third_moment_cuberoot<\/code><\/th>\n<td>Cube root of the third moment along the major axis<\/td>\n<td>mm<\/td>\n<\/tr>\n<tr>\n<th><code>minor_axis_third_moment_cuberoot<\/code><\/th>\n<td>Cube root of the third moment along the minor axis<\/td>\n<td>mm<\/td>\n<\/tr>\n<tr>\n<th><code>major_axis_angle_to_origin<\/code><\/th>\n<td>Major-axis angle to the image origin<\/td>\n<td>degrees<\/td>\n<\/tr>\n<tr>\n<th><code>ellipse_center_distance_to_origin<\/code><\/th>\n<td>Image-centroid distance to the origin<\/td>\n<td>mm<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"nds-table-scroll\">\n<table>\n<thead>\n<tr>\n<th>Subset<\/th>\n<th>Rows<\/th>\n<th>Purpose<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th>Training<\/th>\n<td>11,412<\/td>\n<td>Estimate model parameters<\/td>\n<\/tr>\n<tr>\n<th>Selection<\/th>\n<td>3,804<\/td>\n<td>Select the hidden-layer size<\/td>\n<\/tr>\n<tr>\n<th>Testing<\/th>\n<td>3,804<\/td>\n<td>Report final performance once<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"nds-figure-grid\">\n<figure><img decoding=\"async\" src=\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2026\/08\/gamma-event-distribution-2026.png\" alt=\"Class distribution with 64.8 percent gamma and 35.2 percent hadron events\"><figcaption>The public simulation contains more gamma than hadron events. The UCI documentation warns that this does not reflect the much larger hadronic background expected in real observations.<\/figcaption><\/figure>\n<figure><img decoding=\"async\" src=\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2026\/08\/gamma-event-correlations-2026.png\" alt=\"Pearson correlations between the ten image descriptors and encoded event type\"><figcaption>These are univariate associations with the encoded class (<code>g=0<\/code>, <code>h=1<\/code>), not causal importance measures. The nonlinear model can use interactions that Pearson correlation does not show.<\/figcaption><\/figure>\n<\/div>\n<div class=\"nds-note nds-note--provenance\"><strong>Provenance and licence.<\/strong> The source is the UCI MAGIC Gamma Telescope data set (DOI 10.24432\/C52C8B), released under CC BY 4.0. The records are simulated rather than observed events, and the public table does not include event energy, run identifier or simulation weights.<\/div>\n<\/section>\n<section id=\"3-model\" class=\"nds-card\">\n<h2>3. Model<\/h2>\n<p>All ten inputs use mean-and-standard-deviation scaling. The initial network has three tanh neurons in one hidden layer and one sigmoid output, for 37 trainable parameters. This is the baseline architecture trained before the hidden-layer size is evaluated.<\/p>\n<p>The output class ordering is <code>g;h<\/code>, so the sigmoid value is the score for <code>h<\/code>, the hadronic-background class.<\/p>\n<div class=\"nds-note\"><strong>Output contract.<\/strong> A high score means hadron-like; a low score means gamma-like. The value has not been calibrated as a probability and must not be presented as a gamma probability.<\/div>\n<figure class=\"nds-architecture-figure\" data-model-stage=\"initial\"><img decoding=\"async\" class=\"nds-architecture\" src=\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2026\/08\/gamma-initial-network-architecture-2026.png\" alt=\"Initial gamma-event classifier with ten inputs, three hidden neurons and one event-type output\"><figcaption>Initial 10\u20133\u20131 architecture used for the baseline training run before neuron selection.<\/figcaption><\/figure>\n<\/section>\n<section id=\"4-training\" class=\"nds-card\">\n<h2>4. Training strategy<\/h2>\n<p>The loss is weighted squared error. The gamma class receives weight 0.7712 and the less frequent hadron class weight 1.4219, so training does not simply follow the simulated class prevalence. A quasi-Newton optimizer estimates the parameters without explicit regularization.<\/p>\n<p>The initial three-neuron network converged in 237 epochs: training error decreased from 0.9177 to 0.4444 and selection error from 0.8921 to 0.4404.<\/p>\n<figure class=\"nds-centered-figure\"><img decoding=\"async\" src=\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2026\/08\/gamma-training-history-2026.png\" alt=\"Weighted-squared-error history for training and selection subsets\"><figcaption>Error history for the initial 10\u20133\u20131 network used before neuron selection.<\/figcaption><\/figure>\n<\/section>\n<section id=\"5-selection\" class=\"nds-card\">\n<h2>5. Model selection and baseline<\/h2>\n<p>Growing-neurons selection evaluated hidden layers from one to ten neurons. The lowest stored selection error, 0.3677, occurred at ten neurons; its training error was 0.3610. The final architecture is therefore 10\u201310\u20131.<\/p>\n<figure class=\"nds-centered-figure\"><img decoding=\"async\" src=\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2026\/08\/gamma-neuron-selection-2026.png\" alt=\"Neuron-selection curve from one to ten hidden neurons\"><figcaption>The minimum occurs at the configured upper limit. Ten is the best tested size, but this sweep does not prove that it is the global optimum.<\/figcaption><\/figure>\n<h3>Selected architecture<\/h3>\n<p>After neuron selection, the hidden layer expands from three to ten tanh neurons. This 10\u201310\u20131 network contains 121 trainable parameters and is the model used for testing, deployment and the downloadable Python export.<\/p>\n<figure class=\"nds-architecture-figure\" data-model-stage=\"selected\"><img decoding=\"async\" class=\"nds-architecture\" src=\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2026\/08\/gamma-selected-network-architecture-2026.png\" alt=\"Selected gamma-event classifier with ten inputs, ten hidden neurons and one event-type output\"><figcaption>Final 10\u201310\u20131 architecture obtained after neuron selection.<\/figcaption><\/figure>\n<div class=\"nds-table-scroll\">\n<table>\n<thead>\n<tr>\n<th>Reference<\/th>\n<th>ROC AUC<\/th>\n<th>Interpretation<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th>Random ranking<\/th>\n<td>0.500<\/td>\n<td>No class-separation ability<\/td>\n<\/tr>\n<tr>\n<th>Final neural network<\/th>\n<td>0.935<\/td>\n<td>Strong event ranking on the held-out simulation<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/section>\n<section id=\"6-validation\" class=\"nds-card\">\n<h2>6. Scientific validation<\/h2>\n<p>Testing uses 2,466 gamma events and 1,338 hadron events that were not used for parameter estimation or neuron selection. Because a hadron accepted as gamma contaminates the candidate sample, threshold selection is reported as gamma efficiency versus hadron rejection rather than relying on accuracy alone.<\/p>\n<div class=\"nds-table-scroll\">\n<table class=\"nds-metrics\">\n<thead>\n<tr>\n<th>Testing metric<\/th>\n<th>Value<\/th>\n<th>Meaning<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th>ROC AUC<\/th>\n<td>0.935<\/td>\n<td>Probability that a random hadron receives a higher hadron score than a random gamma event<\/td>\n<\/tr>\n<tr>\n<th>Gamma efficiency at score 0.50<\/th>\n<td>90.2%<\/td>\n<td>Gamma events retained as gamma-like<\/td>\n<\/tr>\n<tr>\n<th>Hadron rejection at score 0.50<\/th>\n<td>82.8%<\/td>\n<td>Hadron events rejected from the gamma-like sample<\/td>\n<\/tr>\n<tr>\n<th>Hadron leakage at score 0.50<\/th>\n<td>17.2%<\/td>\n<td>Hadron events incorrectly admitted as gamma-like<\/td>\n<\/tr>\n<tr>\n<th>Accuracy at score 0.50<\/th>\n<td>87.6%<\/td>\n<td>Supplementary metric under the simulated class mixture<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h3>Confusion matrix at hadron score 0.50<\/h3>\n<div class=\"nds-table-scroll\">\n<table class=\"nds-confusion\">\n<thead>\n<tr>\n<th>Actual \/ predicted<\/th>\n<th>Gamma-like<\/th>\n<th>Hadron-like<\/th>\n<th>Total<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th>Gamma<\/th>\n<td>2,224<\/td>\n<td>242<\/td>\n<td>2,466<\/td>\n<\/tr>\n<tr>\n<th>Hadron<\/th>\n<td>230<\/td>\n<td>1,108<\/td>\n<td>1,338<\/td>\n<\/tr>\n<tr>\n<th>Total<\/th>\n<td>2,454<\/td>\n<td>1,350<\/td>\n<td>3,804<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h3>Choose the threshold from the scientific objective<\/h3>\n<div class=\"nds-table-scroll\">\n<table>\n<thead>\n<tr>\n<th>Hadron-score threshold<\/th>\n<th>Gamma efficiency<\/th>\n<th>Hadron rejection<\/th>\n<th>Hadron leakage<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th>0.50<\/th>\n<td>90.2%<\/td>\n<td>82.8%<\/td>\n<td>17.2%<\/td>\n<\/tr>\n<tr>\n<th>0.30<\/th>\n<td>78.3%<\/td>\n<td>90.4%<\/td>\n<td>9.6%<\/td>\n<\/tr>\n<tr>\n<th>0.19<\/th>\n<td>65.6%<\/td>\n<td>95.0%<\/td>\n<td>5.0%<\/td>\n<\/tr>\n<tr>\n<th>0.05<\/th>\n<td>29.8%<\/td>\n<td>99.0%<\/td>\n<td>1.0%<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"nds-figure-grid\">\n<figure class=\"nds-figure-full\"><img decoding=\"async\" src=\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2026\/08\/gamma-roc-2026.png\" alt=\"ROC curve with area under the curve 0.935\"><figcaption>The ROC curve exposes the trade-off between rejecting hadronic background and retaining gamma events. The highlighted balanced point is useful for inspection, but a scientific analysis should select the threshold from its background budget and sensitivity objective.<\/figcaption><\/figure>\n<\/div>\n<div class=\"nds-note\"><strong>Scientific interpretation.<\/strong> The model separates the two simulated classes well, but the relevant operating point depends on the expected background and downstream significance. The 87.6% accuracy is not portable to real observations because the public simulation deliberately underrepresents hadrons.<\/div>\n<\/section>\n<section id=\"7-inference\" class=\"nds-card\">\n<h2>7. Inference and reproducibility<\/h2>\n<p>A credible workflow starts from reconstructed camera images, calculates the same ten descriptors, validates schema and ranges, evaluates the hadron-class score, and applies a threshold chosen for the analysis. Selected gamma-like candidates then enter spatial, temporal or spectral inference with exposure and systematic uncertainties.<\/p>\n<div class=\"nds-flow\">\n<div>Triggered camera image<\/div>\n<div>Image cleaning and descriptors<\/div>\n<div>Schema and range checks<\/div>\n<div>Hadron-class score<\/div>\n<div>Gamma-like candidate sample<\/div>\n<div>Statistical source analysis<\/div>\n<\/div>\n<h3>Representative simulated event<\/h3>\n<p>The following point is inside every training range and demonstrates the exported calculation. It is not a recorded telescope event.<\/p>\n<div class=\"nds-deployment-grid\">\n<div class=\"nds-table-scroll\">\n<table>\n<thead>\n<tr>\n<th>Input<\/th>\n<th>Value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th>Ellipse major axis<\/th>\n<td>65 mm<\/td>\n<\/tr>\n<tr>\n<th>Ellipse minor axis<\/th>\n<td>49 mm<\/td>\n<\/tr>\n<tr>\n<th>Log total pixel signal<\/th>\n<td>3.20<\/td>\n<\/tr>\n<tr>\n<th>Two-brightest-pixel ratio<\/th>\n<td>0.26<\/td>\n<\/tr>\n<tr>\n<th>Brightest-pixel ratio<\/th>\n<td>0.14<\/td>\n<\/tr>\n<tr>\n<th>Brightest-pixel major-axis offset<\/th>\n<td>\u221236 mm<\/td>\n<\/tr>\n<tr>\n<th>Major-axis third-moment cube root<\/th>\n<td>46 mm<\/td>\n<\/tr>\n<tr>\n<th>Minor-axis third-moment cube root<\/th>\n<td>28 mm<\/td>\n<\/tr>\n<tr>\n<th>Major-axis angle to origin<\/th>\n<td>78\u00b0<\/td>\n<\/tr>\n<tr>\n<th>Ellipse-centre distance to origin<\/th>\n<td>320 mm<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"nds-result\"><span>Hadron-class score<\/span><strong>0.99652<\/strong><\/p>\n<p>At threshold 0.50, the event is classified as <strong>hadron-like<\/strong> and excluded from the gamma-like candidate sample.<\/p>\n<\/div>\n<\/div>\n<h3>Reproduce the inference<\/h3>\n<p>The Python package contains the exact exported model, ordered input schema, representative case and expected output. It was executed over all 3,804 testing events and reproduced the Neural Designer confusion matrix and ROC AUC. The project package preserves the split, trained parameters and regenerated analyses.<\/p>\n<pre><code>from model import NeuralNetwork\n\ninputs = [65, 49, 3.2, 0.26, 0.14, -36, 46, 28, 78, 320]\nhadron_score = NeuralNetwork().calculate_outputs(inputs)[0]<\/code><\/pre>\n<div class=\"nds-downloads\"><a href=\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2026\/08\/gamma-python-model-2026.zip\">Download Python model (ZIP)<\/a><br \/>\n<a href=\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2026\/08\/gamma-neural-designer-project-2026.zip\">Download Neural Designer project (ZIP)<\/a><br \/>\n<a href=\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2026\/08\/gamma.csv\">Download gamma.csv<\/a><\/div>\n<\/section>\n<section id=\"8-validity\" class=\"nds-card\">\n<h2>8. Validity, uncertainty and limitations<\/h2>\n<ul>\n<li><strong>Simulation-to-data transfer is untested.<\/strong> The benchmark uses CORSIKA-generated events and does not validate detector response, atmospheric conditions or image cleaning on recorded observations.<\/li>\n<li><strong>The public prevalence is artificial.<\/strong> Gamma events are 64.8% of this table, whereas real observations contain substantially more hadronic background. Accuracy and sample purity therefore do not transfer directly.<\/li>\n<li><strong>Energy dependence is hidden.<\/strong> The public CSV has no event-energy column, so performance cannot be reported in the energy bins used in the source study.<\/li>\n<li><strong>Validation is row-random.<\/strong> Thirty testing feature vectors (0.79%) duplicate a training vector. A stricter benchmark would group or remove duplicates before partitioning and would validate by simulation or observation run.<\/li>\n<li><strong>The score is not calibrated.<\/strong> It is a ranking score for class <code>h<\/code>, not a posterior gamma probability. Any probabilistic use requires independent calibration under representative class priors.<\/li>\n<li><strong>The selection boundary was reached.<\/strong> Ten neurons produced the lowest selection error among the tested sizes but was also the configured maximum.<\/li>\n<li><strong>Scientific discovery requires more.<\/strong> Exposure, event weights, control regions, systematic uncertainties and a likelihood-based significance analysis are outside this example.<\/li>\n<\/ul>\n<\/section>\n<section id=\"references\" class=\"nds-card\">\n<h2>References<\/h2>\n<ul>\n<li><a href=\"https:\/\/archive.ics.uci.edu\/dataset\/159\/magic+gamma+telescope\">UCI Machine Learning Repository: MAGIC Gamma Telescope<\/a>, DOI <a href=\"https:\/\/doi.org\/10.24432\/C52C8B\">10.24432\/C52C8B<\/a>, CC BY 4.0.<\/li>\n<li>R. K. Bock et al., <a href=\"https:\/\/www.sciencedirect.com\/science\/article\/pii\/S0168900203025051\">Methods for multidimensional event classification: a case study using images from a Cherenkov gamma-ray telescope<\/a>, Nuclear Instruments and Methods in Physics Research A 516 (2004), 511\u2013528.<\/li>\n<li>D. Heck et al., <a href=\"https:\/\/www.iap.kit.edu\/corsika\/\">CORSIKA: a Monte Carlo code to simulate extensive air showers<\/a>.<\/li>\n<\/ul>\n<\/section>\n<\/div>\n<\/div>\n","protected":false},"author":13,"featured_media":2137,"template":"","categories":[29],"tags":[],"class_list":["post-3499","learning","type-learning","status-publish","has-post-thumbnail","hentry","category-examples"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Detect gamma rays using machine learning<\/title>\n<meta name=\"description\" content=\"Build a machine learning model to develop a classification method to detect gamma rays while it discriminate the background.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Gamma ray machine learning example\" \/>\n<meta property=\"og:description\" content=\"In this example, we develop a classification method to detect gamma signal\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/\" \/>\n<meta property=\"og:site_name\" content=\"Neural Designer\" \/>\n<meta property=\"article:modified_time\" content=\"2026-08-06T11:29:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2023\/06\/gamma-telescope.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Gamma ray machine learning example\" \/>\n<meta name=\"twitter:description\" content=\"In this example, we develop a classification method to detect gamma signal\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2023\/06\/gamma-telescope.webp\" \/>\n<meta name=\"twitter:site\" content=\"@NeuralDesigner\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/\",\"url\":\"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/\",\"name\":\"Detect gamma rays using machine learning\",\"isPartOf\":{\"@id\":\"https:\/\/www.neuraldesigner.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2023\/06\/gamma-telescope.webp\",\"datePublished\":\"2025-08-31T09:12:59+00:00\",\"dateModified\":\"2026-08-06T11:29:28+00:00\",\"description\":\"Build a machine learning model to develop a classification method to detect gamma rays while it discriminate the background.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/#primaryimage\",\"url\":\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2023\/06\/gamma-telescope.webp\",\"contentUrl\":\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2023\/06\/gamma-telescope.webp\",\"width\":1200,\"height\":628,\"caption\":\"Gamma-ray telescope\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.neuraldesigner.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Learning\",\"item\":\"https:\/\/www.neuraldesigner.com\/learning\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Detect gamma rays using machine learning\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.neuraldesigner.com\/#website\",\"url\":\"https:\/\/www.neuraldesigner.com\/\",\"name\":\"Neural Designer\",\"description\":\"Explainable AI Platform\",\"publisher\":{\"@id\":\"https:\/\/www.neuraldesigner.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.neuraldesigner.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.neuraldesigner.com\/#organization\",\"name\":\"Neural Designer\",\"url\":\"https:\/\/www.neuraldesigner.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.neuraldesigner.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2023\/05\/logo-neural-1.png\",\"contentUrl\":\"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2023\/05\/logo-neural-1.png\",\"width\":1024,\"height\":223,\"caption\":\"Neural Designer\"},\"image\":{\"@id\":\"https:\/\/www.neuraldesigner.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/NeuralDesigner\",\"https:\/\/es.linkedin.com\/showcase\/neuraldesigner\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Detect gamma rays using machine learning","description":"Build a machine learning model to develop a classification method to detect gamma rays while it discriminate the background.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/","og_locale":"en_US","og_type":"article","og_title":"Gamma ray machine learning example","og_description":"In this example, we develop a classification method to detect gamma signal","og_url":"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/","og_site_name":"Neural Designer","article_modified_time":"2026-08-06T11:29:28+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2023\/06\/gamma-telescope.webp","type":"image\/webp"}],"twitter_card":"summary_large_image","twitter_title":"Gamma ray machine learning example","twitter_description":"In this example, we develop a classification method to detect gamma signal","twitter_image":"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2023\/06\/gamma-telescope.webp","twitter_site":"@NeuralDesigner","twitter_misc":{"Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/","url":"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/","name":"Detect gamma rays using machine learning","isPartOf":{"@id":"https:\/\/www.neuraldesigner.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/#primaryimage"},"image":{"@id":"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/#primaryimage"},"thumbnailUrl":"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2023\/06\/gamma-telescope.webp","datePublished":"2025-08-31T09:12:59+00:00","dateModified":"2026-08-06T11:29:28+00:00","description":"Build a machine learning model to develop a classification method to detect gamma rays while it discriminate the background.","breadcrumb":{"@id":"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/#primaryimage","url":"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2023\/06\/gamma-telescope.webp","contentUrl":"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2023\/06\/gamma-telescope.webp","width":1200,"height":628,"caption":"Gamma-ray telescope"},{"@type":"BreadcrumbList","@id":"https:\/\/www.neuraldesigner.com\/learning\/examples\/gamma\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.neuraldesigner.com\/"},{"@type":"ListItem","position":2,"name":"Learning","item":"https:\/\/www.neuraldesigner.com\/learning\/"},{"@type":"ListItem","position":3,"name":"Detect gamma rays using machine learning"}]},{"@type":"WebSite","@id":"https:\/\/www.neuraldesigner.com\/#website","url":"https:\/\/www.neuraldesigner.com\/","name":"Neural Designer","description":"Explainable AI Platform","publisher":{"@id":"https:\/\/www.neuraldesigner.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.neuraldesigner.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.neuraldesigner.com\/#organization","name":"Neural Designer","url":"https:\/\/www.neuraldesigner.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.neuraldesigner.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2023\/05\/logo-neural-1.png","contentUrl":"https:\/\/www.neuraldesigner.com\/wp-content\/uploads\/2023\/05\/logo-neural-1.png","width":1024,"height":223,"caption":"Neural Designer"},"image":{"@id":"https:\/\/www.neuraldesigner.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/NeuralDesigner","https:\/\/es.linkedin.com\/showcase\/neuraldesigner\/"]}]}},"_links":{"self":[{"href":"https:\/\/www.neuraldesigner.com\/api\/wp\/v2\/learning\/3499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.neuraldesigner.com\/api\/wp\/v2\/learning"}],"about":[{"href":"https:\/\/www.neuraldesigner.com\/api\/wp\/v2\/types\/learning"}],"author":[{"embeddable":true,"href":"https:\/\/www.neuraldesigner.com\/api\/wp\/v2\/users\/13"}],"version-history":[{"count":5,"href":"https:\/\/www.neuraldesigner.com\/api\/wp\/v2\/learning\/3499\/revisions"}],"predecessor-version":[{"id":23121,"href":"https:\/\/www.neuraldesigner.com\/api\/wp\/v2\/learning\/3499\/revisions\/23121"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.neuraldesigner.com\/api\/wp\/v2\/media\/2137"}],"wp:attachment":[{"href":"https:\/\/www.neuraldesigner.com\/api\/wp\/v2\/media?parent=3499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.neuraldesigner.com\/api\/wp\/v2\/categories?post=3499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.neuraldesigner.com\/api\/wp\/v2\/tags?post=3499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}