Learning

Star types classification using machine learning

Classify six educational stellar categories from tabular properties

This reproducible tutorial expands six physical and categorical fields into 22 model features and assigns one of six labels with a fixed softmax classifier. The final export classifies 47 of 48 held-out rows correctly, with 97.9% accuracy and a macro-F1 of 0.974. These are internal results on a small curated data set.

97.9%held-out accuracy
0.974macro-F1
48held-out test rows
240total tabular records

1. Scientific objective

The objective is to demonstrate multiclass classification from temperature, luminosity, radius, absolute magnitude, colour and spectral class. The output can support teaching, software checks and reproducible comparisons on this specific table. It is not a substitute for spectral analysis, catalogue classification or stellar-evolution inference.

Multiclass workflow

Demonstrate categorical encoding, scaling, softmax classification and class-level evaluation in a compact example.

HR-diagram intuition

Relate temperature, luminosity, radius and magnitude to visibly separated regions of an educational stellar table.

Reproducible inference

Inspect the exact split, regenerated figures, executable Python export and Neural Designer project used for the reported result.

Astronomy educationScientific data scienceResearch softwareIntroductory stellar astrophysics
Scope. This is a small educational benchmark. The labels combine substellar objects, stellar remnants, main-sequence subgroups and high-luminosity classes; they should not be treated as one authoritative astronomical taxonomy.

2. Data and provenance

The updated stars.csv contains 240 complete and non-duplicated rows. Each of the six target labels occurs exactly 40 times, an intentionally balanced prevalence that is unlikely to represent an astronomical survey.

CSV fieldMeaning in this data setUnit or encoding
temperatureStellar effective/surface temperatureK
luminosityLuminosity relative to the SunL/L
relative_radiusRadius relative to the SunR/R
absolute_magnitudeAbsolute visual magnitude used by the source tableMV
colorEleven qualitative colour categoriesnominal category
spectral_classOne of O, B, A, F, G, K or Mnominal category
typeTarget: Brown Dwarf, Hypergiants, Main Sequence, Red Dwarf, Supergiants or White Dwarfsix-class category

Source fields and model features

Source field groupSource columnsModel featuresPreprocessing
Physical values44Mean-and-standard-deviation scaling
Colour111One-hot encoding and minimum–maximum scaling
Spectral class17One-hot encoding and minimum–maximum scaling
Total622Ordered schema required by the export
SubsetRowsPurpose
Training144Estimate the fixed model parameters
Selection48Monitor generalization during training
Testing48Report final internal performance
Six target labels with forty records each
The complete table is perfectly balanced, but the random 60/20/20 split does not preserve exactly equal testing counts.
Pearson associations between source fields and a numerically encoded six-class target
The target is nominal. These coefficients depend on its arbitrary numerical encoding and are not physical importance or causal measures.
Provenance. The source is the Kaggle Star dataset to predict star types. The repository does not document object identifiers, observing facilities, measurement uncertainties, acquisition dates, selection functions or a peer-reviewed construction protocol. The table should therefore be treated as a curated educational compilation, not a survey catalogue or externally validated astrophysical sample.

3. Model

The four numeric inputs are standardized. The eleven colour categories and seven spectral classes are one-hot encoded, producing 22 features. A single dense layer connects those features directly to six softmax outputs ordered as Brown Dwarf, Hypergiants, Main Sequence, Red Dwarf, Supergiants and White Dwarf.

The model contains no hidden layer and has 138 trainable parameters. It is a multiclass logistic classifier represented in Neural Designer’s neural-network framework.

This is both the base and final architecture. No neuron-selection or architecture-selection experiment is used.

Output contract. The largest softmax score defines the predicted label. The scores have not been calibrated as probabilities and should not be interpreted as astrophysical confidence.
Fixed star-type model with six source fields, twenty-two encoded features and six softmax outputs
Fixed base and final architecture. The diagram shows the six source fields; colour and spectral class expand internally so the dense softmax layer receives 22 features.

4. Training strategy

The model minimizes multiclass cross-entropy with the quasi-Newton method and no explicit regularization. Training stopped at the configured loss goal after 20 completed epochs (21 stored iterations). Training cross-entropy decreased from 1.8483 to 0.0006.

Selection cross-entropy fell from 1.2338 to its minimum of 0.342 at epoch 7, then increased to 0.6664 while training error continued to fall. The downloadable export is the stored final model at epoch 20; the earlier checkpoint was not restored.

Training and selection cross-entropy histories over twenty epochs
The divergence after epoch 7 is a clear overfitting signal despite the strong held-out classification result.

5. Model selection and baseline

No neuron selection was performed, and no architecture selection was performed. The direct 22–6 softmax model was fixed before training and retained as the final model. This demonstrates that a larger network is unnecessary for separating this small curated table, but it does not establish that the architecture is optimal.

ReferenceExpected/test accuracyInterpretation
Uniform six-class guess16.7% expectedChance reference under the deliberately balanced full data set
Fixed softmax model97.9% testingStrong internal separation of the curated labels
Training recommendation. Architecture selection is not needed here, but checkpoint selection is. A production-quality rerun should stop near the lowest selection cross-entropy and preserve that checkpoint before testing.

6. Scientific validation

The random testing subset contains 48 rows. The final exported model correctly classifies 47; one Supergiants row is assigned to Main Sequence. Because every class has only 4–12 testing examples, each error changes the class-level metrics substantially.

Testing metricValueInterpretation
Accuracy97.92%47 correct labels from 48 testing rows
Macro precision96.67%Unweighted mean across the six labels
Macro recall98.61%Unweighted mean sensitivity across labels
Macro-F197.42%Class-balanced summary of precision and recall
Testing cross-entropy0.322Calculated from the exact final Python export

Confusion matrix

Actual / predictedBrown dwarfHypergiantsMain sequenceRed dwarfSupergiantsWhite dwarfTotal
Brown dwarf9000009
Hypergiants0900009
Main sequence0040004
Red dwarf0007007
Supergiants001011012
White dwarf0000077
Total995711748

Per-class performance

LabelTesting rowsPrecisionRecallF1
Brown dwarf9100.0%100.0%100.0%
Hypergiants9100.0%100.0%100.0%
Main sequence480.0%100.0%88.9%
Red dwarf7100.0%100.0%100.0%
Supergiants12100.0%91.7%95.7%
White dwarf7100.0%100.0%100.0%
Scientific interpretation. The result shows that the supplied labels are highly separable within this table. It does not demonstrate transfer to Gaia, spectroscopic surveys or new stellar populations, and the 48-row test set is too small to characterize rare failure modes or calibration.

7. Inference and reproducibility

A credible application would begin with traceable photometric or spectroscopic measurements, apply quality and uncertainty filters, derive physically documented quantities, validate the six-field schema, encode the two categorical fields, calculate six model scores and submit the result to astronomical review.

Instrument or catalogue
Quality and uncertainty checks
Physical and spectral fields
22-feature encoding
Six model scores
Astronomical review

Held-out white-dwarf example

The following record belongs to the testing subset and is reproduced with the exact Python export. It replaces the previous artificial input combination with one internally consistent row from the published table.

InputValue
Temperature9,675 K
Luminosity0.00045 L/L
Relative radius0.0109 R/R
Absolute magnitude13.98 MV
ColourBlue-White
Spectral classA
Recorded targetWhite Dwarf
Highest model scoreWhite Dwarf

White Dwarf 69.34%; Main Sequence 30.65%; every other score is below 0.01%. The predicted label matches the stored testing target, but the score margin also shows why the output should not be presented as certainty.

Try the exported stellar classifier

Provide the four numeric fields and select the qualitative colour and spectral class. The browser reproduces the 22-feature encoding used by Neural Designer.

Research demonstration. The calculation runs locally with the exact exported weights and preprocessing. Values outside the validated domain are rejected. Scores are not calibrated probabilities or an astronomical diagnosis.

Reproduce the inference

The Python package contains the exact exported model, the 22-feature encoding schema, the held-out case and its expected scores. The project package preserves the split, trained parameters and regenerated analyses.

from model import NeuralNetwork

# Four numeric values + 11 colour indicators + 7 spectral indicators
scores = NeuralNetwork().calculate_outputs(encoded_inputs)

8. Validity, uncertainty and limitations

  • External provenance is incomplete. The source page does not identify the stars, instruments, surveys, measurement methods or uncertainties behind the 240 rows.
  • The taxonomy mixes different concepts. Brown dwarfs are substellar objects; white dwarfs are remnants; red dwarfs are normally main-sequence stars; and supergiant/hypergiant terminology describes luminosity or evolutionary state.
  • The class balance is artificial. Exactly 40 rows per target is useful for teaching but does not represent astronomical prevalence.
  • Inputs are physically redundant. Temperature, luminosity, radius, magnitude, colour and spectral class are related. Strong performance partly reflects repeated information rather than independent evidence.
  • The random row split is only internal validation. It does not test transfer across instruments, surveys, sky regions, extinction regimes or observing conditions.
  • Training overfits after epoch 7. The published final export reaches lower training loss but higher selection loss than the best stored epoch.
  • The test set is small. With 4–12 rows per label, confidence intervals would be wide and one mistake materially changes a class metric.
  • Scores are not calibrated. They are ranking values for this model and data set, not posterior class probabilities.

References