Introduction

At a broad level, the supernovae considered in this notebook can be grouped into two families. Type Ia supernovae are thermonuclear explosions involving white dwarfs. After empirical corrections for light-curve shape and color, many Type Ia events can be used as standardizable distance indicators, although their explosion mechanisms and intrinsic luminosities are not perfectly uniform. Core-collapse supernovae, including Types II, Ib, and Ic, result from the deaths of massive stars and span a diverse range of progenitors and luminosities.
Spectroscopy provides the conventional basis for assigning definitive supernova types. Modern photometric classifiers commonly use multiband light curves, colors, contextual information about the host galaxy, and sometimes redshift estimates. This notebook considers a deliberately narrower problem: whether broad thermonuclear and core-collapse labels can be predicted using only a catalog apparent magnitude and a catalog distance estimate.
A distance-corrected magnitude is a deterministic transformation of apparent magnitude and distance, so it introduces no new observational information. It instead presents the same information in a physically motivated coordinate. The experiment tests whether explicitly supplying this derived feature helps the same classifier generalize to unseen examples. Because the catalog property used is ApparentMagnitude rather than a verified peak magnitude, and because DistanceFromEarth is not necessarily a luminosity distance, the derived feature is an approximate absolute-magnitude proxy rather than a homogeneous measurement of peak absolute magnitude.

Data Extraction

Data are retrieved from Wolfram's Supernova entity store. Because property names can vary across versions, each required quantity is specified as an ordered list of candidate names and resolved against the properties available in the current session. The magnitude candidates run from explicit peak-magnitude properties down to the generic ApparentMagnitude fallback; which case the run landed in is printed rather than assumed.
available=CanonicalName/@EntityValue["Supernova","Properties"];​​​​candidateMap=<|​​"Type"->{"Type","SupernovaType","SpectralClass"},​​"Magnitude"->{"MaximumApparentMagnitude","MaxApparentMagnitude",​​"PeakApparentMagnitude","ApparentMagnitude"},​​"Distance"->{"DistanceFromEarth","Distance"}​​|>;​​​​resolve[cands_List]:=SelectFirst[cands,MemberQ[available,#]&,​​Missing["NoAvailableProperty"]];​​​​resolved=Map[resolve,candidateMap];​​​​If[AnyTrue[Values[resolved],MissingQ],​​Print["One or more required properties could not be resolved: ",resolved];​​Abort[];​​];​​​​Print["Resolved properties: ",resolved];​​​​SeedRandom[21];​​ents=RandomSample[SupernovaData[],UpTo[6000]];​​​​allProps=Lookup[resolved,{"Type","Magnitude","Distance"}];​​​​rawMatrix=EntityValue[ents,allProps];​​​​Print["Catalog entries returned: ",Length[rawMatrix]];
Resolved properties: TypeSupernovaType,MagnitudeApparentMagnitude,DistanceDistanceFromEarth
Catalog entries returned: 5364
The catalog stores heterogeneous subtype labels, including Ia, Ia-91T, Iax, II, IIP, IIn, Ib, Ic, and Ib/c. Labels beginning with Ia are mapped to the thermonuclear class, labels beginning with Ib, Ic, or II to the core-collapse class, and everything else is dropped.
Prefix matching on Ia collapses normal Type Ia events together with peculiar subclasses such as Ia-91T and Iax, which differ substantially in luminosity; the thermonuclear class is therefore broader and more dispersed in absolute magnitude than the standard-candle framing suggests. Those events are one plausible source of the faint tail seen in the next section, though non-peak magnitudes and unreliable distances would produce the same feature and this run does not distinguish between them.
In[]:=
toNum[v_]:=Which[​​NumericQ[v],N[v],​​QuantityQ[v],toNum[QuantityMagnitude[v]],​​Head[v]===Around,toNum[v["Value"]],​​Head[v]===Interval,toNum[Mean[First[v]]],​​ListQ[v]&&Length[v]>=1,toNum[First[v]],​​True,Missing["NotAvailable"]];​​​​convertPc[v_]:=Which[​​QuantityQ[v],QuantityMagnitude[UnitConvert[v,"Parsecs"]],​​Head[v]===Around,convertPc[v["Value"]],​​NumericQ[v],N[v],​​True,Missing["NotAvailable"]];​​​​coarse[t_]:=Module[{s},​​If[!StringQ[t],Return[Missing["NA"]]];​​s=ToUpperCase[StringTrim[t]];​​Which[​​StringStartsQ[s,"IA"],"Ia",​​StringStartsQ[s,"IB"]||StringStartsQ[s,"IC"]||​​StringStartsQ[s,"II"],"Core-collapse",​​True,Missing["Other"]]];​​​​labelsAll=Map[coarse,rawMatrix[[All,1]]];​​magAll=Map[toNum,rawMatrix[[All,2]]];​​distAll=Map[convertPc,rawMatrix[[All,3]]];​​​​okIdx=Select[Range[Length[labelsAll]],​​Function[j,​​StringQ[labelsAll[[j]]]&&NumericQ[magAll[[j]]]&&​​NumericQ[distAll[[j]]]&&distAll[[j]]>0]];​​​​labels=labelsAll[[okIdx]];​​m=magAll[[okIdx]];​​dPc=distAll[[okIdx]];​​absM=m-5*Log10[dPc]+5;​​​​Print["Usable supernovae: ",Length[labels]];​​Print["Median distance (pc): ",Median[dPc]];​​Print["Class balance: ",Counts[labels]]
Usable supernovae: 254
Median distance (pc): 2.305×
7
10
Class balance: Core-collapse142,Ia112
Of 5364 catalog entries, 254 survive the joint requirement that the type string map onto one of the two broad families and that a magnitude and a positive distance both be present -- a 95% attrition rate. The surviving sample is therefore not a random draw from the catalog but the subset with a usable label and complete photometry and distance, which biases toward nearby, well-studied events. Conclusions below apply to that subset, not to supernovae generally.

Exploratory Data Analysis

The approximate distance-corrected magnitude shows a concentration of Type Ia objects near -19 mag, together with a faint tail and substantial overlap with the core-collapse population.
iaM=Pick[absM,labels,"Ia"];​​ccM=Pick[absM,labels,"Core-collapse"];​​Histogram{iaM,ccM},{0.5},

Out[]=
Type Ia
Core-collapse
Apparent magnitude alone shows heavier overlap. The joint pair of apparent magnitude and distance nevertheless contains predictive information on this dataset, as demonstrated by the baseline model below.
GraphicsRow​​Histogram{Pick[m,labels,"Ia"],Pick[m,labels,"Core-collapse"]},{0.5},
,​​ListLogLinearPlot{Transpose[{Pick[dPc,labels,"Ia"],​​Pick[m,labels,"Ia"]}],​​Transpose[{Pick[dPc,labels,"Core-collapse"],​​Pick[m,labels,"Core-collapse"]}]},
,​​ImageSize->Full
Out[]=

Baseline Classification from Raw Observables

The train/test split is fixed once and the same assignment is used for both representations: an object assigned to the training set in one remains in the training set in the other. Model selection is completed using only the training data so the final test set remains untouched. Several standard classifiers are benchmarked on the raw two-feature representation, each inside a time-constrained sandbox, and the strongest is kept as the baseline. The engineered representation retains both raw features and adds absolute magnitude, so it is a strict superset; the comparison isolates the value of making the combination explicit, not of replacing the raw coordinates.
The standard error across folds is reported alongside each mean. With roughly forty objects per fold the spread between the leading methods is comparable to the fold-to-fold noise, so the selected method is the best on this sample rather than the best in any stronger sense.

Adding the Physics: Absolute Magnitude

The selected classifier is retrained on the same training objects with absolute magnitude included. Because absolute magnitude is calculated deterministically from apparent magnitude and distance, the engineered representation contains no additional observational information. It instead makes one physically meaningful nonlinear combination explicit. Any performance difference must therefore be interpreted as an effect of representation, not additional data.

Comparing the Two Representations

The two confusion matrices tell the story more honestly than a single accuracy number, and three further quantities are needed to read them. Per-class F-scores for both models show whether the off-diagonal mass moved. The majority-class accuracy sets the floor, since a lazy classifier can score deceptively well by always guessing the majority class. And because both models are scored on the same test objects, the comparison is paired: the appropriate test is McNemar's exact test on the objects where the two disagree, not an interval around either accuracy on its own.

Conclusion

Adding the approximate absolute-magnitude feature increased held-out accuracy from 39 of 51 test objects (76.5%) to 41 of 51 (80.4%). Total errors fell from twelve to ten. Both models correctly classified 21 of 25 core-collapse events, with four core-collapse events misclassified as Type Ia in each case. For Type Ia events, correct classifications increased from 18 of 26 to 20 of 26, raising Type Ia recall from 69.2% to 76.9%.
​
Per-class F-scores increased from 0.778 to 0.808 for core-collapse and from 0.750 to 0.800 for Type Ia. The models disagreed on six test objects: the raw-observable model alone was correct on two, while the engineered-feature model alone was correct on four. McNemar’s exact two-sided test gives p=0.6875, and the 95% Wilson intervals overlap substantially. The observed improvement is therefore directionally consistent with the physical motivation, but it does not provide statistically significant evidence that the engineered representation is superior.
​
This run does not establish that either representation is superior. However, the two models disagree on 9 of the 51 test objects, so it shows that making the distance correction explicit does change what the classifier learns.

CITE THIS NOTEBOOK

Testing a physics-informed feature for broad supernova classification​
by Lim Lee​
Wolfram Community, STAFF PICKS, July 28, 2026
https://community.wolfram.com/groups/-/m/t/3768970