Introduction
Introduction
Distance is one of the most fundamental quantities in astronomy, and also one of the most difficult to measure. Star cluster catalogs frequently record a cluster’s apparent magnitude while leaving its distance blank, because determining distance requires dedicated follow-up observations that clusters mostly never receive. Since the observables that are available correlate with distance (on average, more distant clusters appear fainter), these gaps can in principle be estimated by a machine learning model trained on the clusters whose distances are known.
The goal of this project is two-fold. First, we aim to determine how accurately missing star cluster distances can be imputed from the catalog’s available observables. To evaluate estimates of values that are, by definition, unknown, we use masking: a random 20 percent of the known distances are hidden during training, and the model’s estimates are compared against the hidden truth. Second, (and perhaps more importantly), we seek to assess whether the model’s stated uncertainty can be trusted. Rather than a single point estimate, the model is asked for a full predictive distribution for each cluster, and the resulting 68 percent intervals are audited for calibration. If they are reliable, the true distances should fall inside them roughly 68 percent of the time.
Data Extraction
Data Extraction
The data for this study were sourced from Wolfram’s curated StarClusterData entity store, which in the version used here contains 852 star clusters. Because property names in Wolfram’s entity stores are not always predictable, the code resolves them at runtime from a list of likely candidates. I searched for the following values:
- ApparentMagnitude (total apparent visual magnitude)
- AngularSize (apparent angular diameter of the cluster)
- Metallicity (iron abundance, [Fe/H])
- Distance (distance from Earth)
- AngularSize (apparent angular diameter of the cluster)
- Metallicity (iron abundance, [Fe/H])
- Distance (distance from Earth)
The target is the distance. Of the four values, only apparent magnitude and distance resolved to properties in the catalog, so apparent magnitude serves as the sole feature in this study.
In[]:=
available=CanonicalName/@EntityValue["StarCluster","Properties"];candidateMap=<|"ApparentMagnitude"->{"ApparentMagnitude","VisualMagnitude","TotalApparentMagnitude"},"AngularSize"->{"AngularDiameter","AngularSize","MajorAxisAngularSize","ApparentDiameter"},"Metallicity"->{"Metallicity","MetallicityFeH","FeH"},"Distance"->{"DistanceFromEarth","Distance"}|>;resolve[cands_List]:=SelectFirst[cands,MemberQ[available,#]&,Missing["None"]];resolved=DeleteMissing[Map[resolve,candidateMap]];Print["Resolved properties: ",resolved];Print["Other possibly useful properties: ",Select[available,StringContainsQ[#,"Angular"|"Diameter"|"Size"|"Metal"|"Type"|"Reddening"|"Extinction"|"Color",IgnoreCase->True]&]];If[!KeyExistsQ[resolved,"Distance"],Print["No distance property found in StarClusterData; cannot continue."];Abort[]];ents=StarClusterData[];If[!(ListQ[ents]&&Length[ents]>0&&MatchQ[First[ents],_Entity]),ents=EntityList[EntityClass["StarCluster",All]]];Print["Entities found: ",Length[ents]];targetName=resolved["Distance"];featConcepts=Keys[KeyDrop[resolved,"Distance"]];featCanonicals=Values[KeyDrop[resolved,"Distance"]];allConcepts=Append[featConcepts,"Distance"];allNames=Append[featCanonicals,targetName];allProps=Map[EntityProperty["StarCluster",#]&,allNames];rawMatrix=EntityValue[ents,allProps];Print["Catalog entries: ",Length[rawMatrix]]
Resolved properties: ApparentMagnitudeApparentMagnitude,DistanceDistanceFromEarth
Other possibly useful properties: {AngularDiameterFromEarth,AngularRadiusFromEarth,Diameter,EntityTypeList,GlobularClusterType,ObjectType}
Entities found: 852
Catalog entries: 852
Above, we query the list of available StarCluster properties, match each concept in candidateMap to the first candidate name that exists in the catalog, and retrieve the resolved properties for every cluster. The diagnostic print also reveals additional properties that could serve as features, including AngularDiameterFromEarth, Diameter and ObjectType.
In[]:=
unitMap=<|"Distance"->"LightYears","AngularSize"->"ArcMinutes"|>;colUnits=Map[Lookup[unitMap,#,None]&,allConcepts];toNum[v_,unit_:None]:=Which[NumericQ[v],N[v],QuantityQ[v],Module[{q},q=If[unit===None,v,Quiet[Check[UnitConvert[v,unit],$Failed]]];If[QuantityQ[q],toNum[QuantityMagnitude[q]],Missing["BadUnit"]]],Head[v]===Around,toNum[v["Value"]],Head[v]===Interval,toNum[Mean[First[v]]],ListQ[v]&&Length[v]>=1,toNum[First[v],unit],True,Missing["NotAvailable"]];numMatrix=Transpose[MapThread[Function[{col,u},Map[toNum[#,u]&,col]],{Transpose[rawMatrix],colUnits}]];angCol=FirstPosition[allConcepts,"AngularSize",{None}][[1]];If[angCol=!=None,numMatrix[[All,angCol]]=Map[If[NumericQ[#]&&#>0,Log10[#],Missing["NotAvailable"]]&,numMatrix[[All,angCol]]]];displayNames=Replace[allConcepts,"AngularSize"->"Log10AngularSize",{1}];distCol=Length[allNames];coverage=AssociationThread[displayNames,Table[Count[numMatrix[[All,j]],_?NumericQ],{j,Length[allNames]}]];Print["Coverage per property: ",coverage];minCoverage=100;keepIdx=Select[Range[Length[featCanonicals]],Function[j,coverage[[j]]>=minCoverage]];If[keepIdx==={},Print["No feature has at least ",minCoverage," numeric entries; lower minCoverage and re-run."];Abort[]];featureNames=displayNames[[keepIdx]];Print["Features kept: ",featureNames];If[MemberQ[available,"AngularDiameterFromEarth"],Module[{angOK,hasD,pairs},angOK=Map[NumericQ[toNum[#,"ArcMinutes"]]&,EntityValue[ents,"AngularDiameterFromEarth"]];hasD=Map[NumericQ,numMatrix[[All,distCol]]];pairs=Transpose[{angOK,hasD}];Print["AngularDiameterFromEarth available for ",Count[pairs,{True,True}]," of ",Count[hasD,True]," clusters with a distance, and ",Count[pairs,{True,False}]," of ",Count[hasD,False]," clusters without one."]]]
Coverage per property: ApparentMagnitude711,Distance252
Features kept: {ApparentMagnitude}
AngularDiameterFromEarth available for 137 of 252 clusters with a distance, and 0 of 600 clusters without one.
Next, each raw value is converted to a plain number. Quantities are first converted to a fixed unit per column (light years for distance, arcminutes for angular size) before their units are stripped, ensuring that entries stored in different units cannot be mixed, and uncertainty objects such as Around and Interval are reduced to their central values. Only features with at least 100 numeric entries are kept. Keep in mind that the physical diameter is omitted because catalogs typically derive it from angular size and distance, and AngularDiameterFromEarth is omitted because its name suggests it may be computed from distance as well; either would leak the answer into the input. The final lines of the cell test the latter suspicion by comparing how often the angular diameter is available for clusters with and without a known distance.
In[]:=
featOK[j_]:=VectorQ[numMatrix[[j,keepIdx]],NumericQ];distOK[j_]:=NumericQ[numMatrix[[j,distCol]]]&&numMatrix[[j,distCol]]>0;labeledIdx=Select[Range[Length[numMatrix]],Function[j,featOK[j]&&distOK[j]]];repairIdx=Select[Range[Length[numMatrix]],Function[j,featOK[j]&&!distOK[j]]];Print["Labeled clusters (train/grade): ",Length[labeledIdx]];Print["Repairable clusters (missing distance): ",Length[repairIdx]];If[Length[labeledIdx]<30,Print["Too few labeled clusters (",Length[labeledIdx],") for an 80/20 split; lower minCoverage or drop a feature."];Abort[]];Print["Median known distance: ",Median[numMatrix[[labeledIdx,distCol]]]," light years"];mkAssoc[j_]:=AssociationThread[featureNames->numMatrix[[j,keepIdx]]];labeledData=Map[Function[j,mkAssoc[j]->Log10[numMatrix[[j,distCol]]]],labeledIdx];
Labeled clusters (train/grade): 220
Repairable clusters (missing distance): 491
Median known distance: 10632.7 light years
Above, the catalog is divided into labeled clusters, which have both a magnitude and a distance and are used for training and evaluation, and repairable clusters, which have a magnitude but no distance. Of the 852 entries, 220 are labeled and 491 are repairable, so the clusters to be repaired outnumber the training examples by more than two to one.
Exploratory Data Analysis
Exploratory Data Analysis
Before training any model, we plot apparent magnitude against log distance for the labeled clusters to verify that the premise holds. If magnitude carries distance information, fainter clusters (larger magnitudes) should tend to lie at greater distances, while the vertical spread of the points at a given magnitude sets a limit on how precisely magnitude alone can predict distance. The cell also prints the range of each variable as a sanity check: no star cluster lies closer than roughly 100 light years (a log distance of 2), so a value far below this would indicate a placeholder or data-entry error.
Training and Evaluation
Training and Evaluation
In this section, we hide the distances of a random 20 percent of the labeled clusters, train a model on the remaining 80 percent using Predict[], and compare its estimates against the hidden values. Because the model never sees these distances, the comparison provides an honest preview of its performance on the clusters whose distances are genuinely missing.
On the 44 masked clusters, the median fractional error was about 56 percent, and only 27 percent of estimates fell within 25 percent of the true distance. The comparison plot also shows the estimates compressed into a narrower range than the true distances, a typical sign of a model with limited information regressing toward typical values. We believe the cause is primarily physical rather than algorithmic. A cluster’s apparent magnitude depends on both its distance and its intrinsic luminosity, and star clusters span an enormous range of luminosities, from sparse open clusters to globular clusters hundreds of times brighter. A single magnitude is therefore consistent with a wide range of distances.
The Calibration Audit
The Calibration Audit
Now, rather than a single estimate, we request the full predictive distribution for each masked cluster and extract its central 68 percent interval. The calibration audit reduces to a single number: the fraction of hidden distances that fall inside their intervals. Because the masked set is small, the binomial standard error of the score is printed alongside it.
The intervals captured 68 percent, compared with a target of 68 percent and a standard error of about 7 percentage points. The difference lies within one standard error, so there is no clear evidence of miscalibration.
Filling the Gaps
Filling the Gaps
With the evaluation complete, the model is retrained on all 220 labeled clusters and used to estimate distances, with 68 percent intervals, for the clusters that lack them. The reported distance is the median of each predictive distribution, ensuring that it always lies within its own interval. The first 15 repaired clusters are shown below:
The intervals are relatively wide, with upper bounds ranging from roughly 4 to 12 times the lower bounds (for example, 6,600 to 78,500 light years for IC 1311 and 1,120 to 4,940 light years for IC 2395), consistent with the masked results. We also noticed that several clusters, including IC 1311, IC 1612, and IC 1624, as well as IC 1611 and IC 166, received identical estimates. Similarly, IC 1805 and IC 1848 share the same predicted distance. This is likely because Predict selected a nearest-neighbors method.
Conclusion
Conclusion
In this project, we applied machine learning to impute missing distances in a star cluster catalog using Wolfram’s StarClusterData, and evaluated the results through two complementary tests. Masking transformed the question of whether imputed values are accurate into a standard held-out evaluation, while the calibration audit tested whether the model’s stated uncertainty could be trusted. Surprisingly, the two tests yielded different answers. With apparent magnitude as the only feature available for enough clusters, the estimates were imprecise, with a median error of about 56 percent. This limitation is largely physical, since apparent magnitude conflates distance with intrinsic luminosity, and star clusters vary enormously in brightness.
Crucially, however, the model’s uncertainty estimates held up: its 68 percent intervals captured 61 percent of the hidden distances, within one standard error of the nominal value. The model’s principal achievement is therefore not accuracy but an honest account of how little a single magnitude reveals. The 491 imputed distances are suitable for coarse applications, such as distinguishing nearby clusters from distant ones, but should not be treated as substitutes for measured distances. Two limitations remain. The test set contained only 44 clusters, so all reported figures carry substantial uncertainty, and masking assumes that clusters with missing distances resemble those with known distances, which is unlikely given that faint, distant and less-studied clusters are more often missing measurements. Future work could incorporate additional features that help separate distance from intrinsic luminosity, such as cluster type, an independently measured angular size, or interstellar reddening, provided none is derived from distance itself.
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
Catalog repair: imputing missing star-cluster distances with error bars
by Lim Lee
Wolfram Community, STAFF PICKS, October 31, 2026
https://community.wolfram.com/t/28457
by Lim Lee
Wolfram Community, STAFF PICKS, October 31, 2026
https://community.wolfram.com/t/28457