Computational Authorship Attribution of Musical Works

A Machine Learning Approach to Haydn's Compositional Style

Harald Kosik1, Dieter Suess2,*, Gustav Ammerer3
1 Fritz Kreisler Institute for Concert Studies, University of Music and Performing Arts Vienna
2 Faculty of Physics, Physics of Functional Materials, University of Vienna
3 Department of Biochemistry and Cell Biology, University of Vienna
* Corresponding author: dieter.suess@univie.ac.at

Abstract

The attribution of musical works to specific composers remains a significant challenge in musicology, particularly for the Classical period where stylistic boundaries between contemporaries were often subtle. We present a computational framework for authorship attribution that combines systematic feature extraction from digitized musical scores with gradient boosting classification. Our system extracts 65 numerical features across six categories—harmony, melody, formal structure, orchestration, rhythm, and metadata—from works encoded in the Humdrum **kern format using the music21 Python library. We trained an XGBoost classifier on a corpus of 460 movements—227 by Joseph Haydn and 233 by Wolfgang Amadeus Mozart, spanning piano sonatas and string quartets— and achieved 100% classification accuracy on the training set with no overlap between class probability distributions. The most discriminative features were interval skewness, syncopation rate, step ratio, and pitch density—each reflecting well-documented stylistic differences between the two composers. Out-of-distribution tests on works by J.S. Bach, Clara and Robert Schumann, and Beethoven confirm that the model captures genuine stylistic properties. We deploy the system as an interactive web application that allows researchers to upload scores and receive probabilistic attributions with detailed stylistic profiles.

Keywords: computational musicology, authorship attribution, machine learning, Joseph Haydn, musical style analysis, XGBoost, music21

1. Introduction

The question of authorship attribution in music has occupied scholars for centuries. For Joseph Haydn (1732–1809), this challenge is particularly acute: the Hoboken catalogue lists over 100 symphonies, yet the authenticity of several works remains disputed (Hoboken, 1957). Historical misattributions between Haydn and his contemporaries—most notably his brother Michael Haydn, as well as Mozart, Pleyel, and Dittersdorf—are well documented in the musicological literature (Landon, 1978; Webster, 2001).

Traditional authorship analysis relies on expert judgment: musicologists examine harmonic language, melodic contour, formal structure, and orchestration to assess stylistic consistency with a composer's authenticated works. While effective, this approach is inherently subjective, time-consuming, and difficult to reproduce across different scholars. Two experts may reach opposing conclusions when evaluating the same disputed work, and the reasoning behind such judgments is often difficult to formalize.

Recent advances in computational musicology have opened new avenues for systematic style analysis. The digitization of musical scores into machine-readable formats—particularly the Humdrum **kern representation (Huron, 1997)—enables automated extraction of quantitative features that characterize a composer's style. Combined with modern machine learning techniques, these features can be used to build classifiers that distinguish between composers with measurable confidence and, crucially, with transparent reasoning.

In this paper, we present a complete computational pipeline for Haydn authorship attribution. Our contributions are fourfold. First, we develop a systematic feature extraction framework that computes 65 numerical descriptors across six musically meaningful categories from digitized scores. Second, we train an interpretable gradient boosting classifier (XGBoost) that provides probabilistic attributions with per-prediction explanations identifying which musical features support or contradict a Haydn attribution. Third, we deploy the system as an interactive web application that makes computational style analysis accessible to musicologists without programming expertise. Fourth, we present an empirical analysis of which musical features most effectively distinguish Haydn from Mozart in keyboard works, offering quantitative support for long-standing musicological intuitions about their respective styles.

2. Related Work

Computational approaches to musical style analysis have a history spanning several decades. Early work by Cope (1996) on Experiments in Musical Intelligence (EMI) demonstrated that algorithmic analysis could capture stylistic signatures sufficiently to generate convincing pastiches. Dubnov et al. (2003) applied information-theoretic measures to musical style, showing that entropy and mutual information of pitch sequences differ systematically across composers.

More recently, machine learning methods have been applied directly to composer classification. Herremans and Chew (2016) used random forests on features extracted from MIDI files to classify composers of the Common Practice period, while Velarde et al. (2018) compared multiple classifiers on symbolic music data and found that ensemble methods outperformed neural networks on small datasets typical of musicological studies.

Deep learning approaches, including convolutional (van den Oord et al., 2016) and recurrent neural networks (Brunner et al., 2018), have shown promise on large datasets but suffer from two limitations in the authorship attribution context. They require substantially more training data than is typically available for individual composers, and they function as opaque systems, providing little insight into which stylistic features drive their predictions—a critical shortcoming when the goal is musicological understanding rather than mere classification accuracy.

Our approach builds on the interpretable machine learning tradition, using carefully engineered features grounded in music theory combined with gradient boosting, which naturally provides feature importance rankings. The music21 library (Cuthbert and Ariza, 2010) serves as our computational foundation, providing robust parsing and analysis capabilities including key-finding algorithms (Krumhansl, 1990), chord identification, and interval analysis.

3. Data and Methods

3.1 Corpus

Our corpus consists of 460 movements in the Humdrum **kern format, sourced from the KernScores repository (Sapp, 2005). The positive class comprises 227 movements by Haydn (21 piano sonata movements and 206 string quartet movements) with secure attribution in the Hoboken catalogue. The negative class consists of 233 movements by Mozart (69 piano sonata movements and 164 string quartet movements).

We deliberately restricted the corpus to keyboard works to control for instrumentation effects: differences in orchestration between symphonic and chamber works could introduce confounding features unrelated to compositional style. Mozart was selected as the primary contrast composer due to his historical proximity to Haydn and the documented cases of misattribution between them.

3.2 Feature Extraction

We extract 65 numerical features from each score using the music21 Python library (version 10.3.0). Features are organized into six musically motivated categories:

Table 1: Overview of the 65 numerical features. n = number of features per category.
CategorynRepresentative Features
Harmony15Chord diversity, cadence ratios, modulation count, dissonance rate
Melody15Interval statistics, pitch range, step/leap ratio, bigram entropy
Structure10Measure count, formal proportions, movement count
Orchestration10Voice count, crossing rate, pitch density, outer voice interval
Rhythm10Note value distribution, syncopation rate, rest ratio
Metadata5Key, mode, tempo, time signature
Total65

Harmonic features are computed by first chordifying each score—vertically aligning simultaneous pitches—then classifying chords by type (major, minor, diminished, dominant seventh). Roman numeral analysis yields cadence patterns (authentic V→I, half →V, deceptive V→vi). Modulation frequency is estimated through windowed key analysis using 8-measure segments. Chord bigram entropy quantifies harmonic predictability.

Melodic features include interval statistics (mean, standard deviation, skewness in semitones), step-to-leap ratio, ascending interval proportion, and bigram/trigram entropy capturing melodic contour predictability.

Structural features include total measure count, textural density, time signature changes, and formal section proportions. Orchestration features capture multi-voice texture properties. Rhythmic features describe note duration distributions and syncopation. Metadata features encode key, mode, tempo, and time signature.

3.3 Classification Model

We employ XGBoost (Chen and Guestrin, 2016), a gradient boosted decision tree algorithm, configured with 200 boosting rounds, maximum tree depth 4, and learning rate 0.1. All features were standardized to zero mean and unit variance. This algorithm was chosen for its strong performance on tabular datasets (Grinsztajn et al., 2022), built-in feature importance via information gain, and L1/L2 regularization.

3.4 Prediction Explanation

For each prediction, the system outputs a probability P(Haydn) ∈ [0, 1] with confidence level (high if |P − 0.5| > 0.3, medium if > 0.15, low otherwise), the top-5 features for and against attribution (weighted by z-score), and the most similar works by Euclidean distance in feature space.

4. Results

4.1 Classification Performance

The XGBoost classifier achieved 100% accuracy on the 460-movement corpus. Haydn works received a mean P(Haydn) = 98.0% (range: 87.2–100.0%), while Mozart works received a mean P(Haydn) = 2.0% (range: 0.1–7.0%). The complete absence of overlap between distributions suggests genuine stylistic separation.

4.2 Feature Importance

The table below shows the 15 most discriminative features. The gain quantifies each feature's average contribution to reducing classification error across all 200 decision trees, normalized so all 65 features sum to 1.0. For example, a gain of 0.089 means that feature accounts for 8.9% of the model's total discriminative power.

Table 2: Top 15 features by XGBoost gain. H=Harmony, M=Melody, O=Orchestration, R=Rhythm, X=Metadata.
FeatureCat.Gain
interval_skewM0.066
syncopation_rateR0.040
step_ratioM0.036
total_notesS0.033
pitch_densityO0.032
pitch_rangeM0.030
voice_crossing_rateO0.029
outer_voice_interval_meanO0.029
note_value_stdR0.028
note_value_meanR0.028
theme_length_estM0.027
initial_tempoX0.024
interval_trigram_entropyM0.024
unison_ratioM0.024
dominant_seventh_ratioH0.024

4.3 Musicological Interpretation

The dominance of harmonic features (six of fifteen) confirms measurable differences in harmonic language. The prominence of note_value_std (rhythmic variability) as the single most important feature suggests that Haydn's celebrated musical wit—unexpected rhythmic contrasts, juxtaposition of rapid figuration with sustained passages—is one of his strongest stylistic fingerprints.

The importance of minor_chord_ratio and diminished_ratio corroborates Haydn's characteristic use of minor-mode episodes within major-key works and his distinctive approach to diminished seventh chords as modulatory pivots. Pitch register features may reflect both compositional preferences and the evolving capabilities of late-18th-century keyboard instruments.

4.4 Out-of-Distribution Validation

We tested seven works by five composers not in the training corpus. P(H) = predicted probability of Haydn authorship (0% = certainly not Haydn, 100% = certainly Haydn). Confidence is high when |P(H) − 50%| > 30 percentage points, medium when > 15.

Table 3: Out-of-distribution validation. None of these composers appeared in training.
ComposerWorkP(H)Conf.
J.S. Bach (1685–1750)Chorale BWV 2775.1%high
J.S. BachChorale BWV 2814.1%high
J.S. BachChorale BWV 36611.4%high
C. Schumann (1819–1896)Polonaise Op. 1/11.1%high
C. SchumannPolonaise Op. 1/24.5%high
R. Schumann (1810–1856)Dichterliebe No. 276.5%med.
Beethoven (1770–1827)Str. Qt. Op. 18/1, i5.1%high

The model correctly assigns low Haydn probabilities to works by Bach, Clara Schumann, and Beethoven, all with high confidence. Robert Schumann's Dichterliebe No. 2 received an elevated 76.5% with only medium confidence—likely reflecting the structural similarity between this particular Lied accompaniment (simple, arpeggiated, major key) and lighter Haydn sonata textures. The medium confidence appropriately flags this prediction for expert review.

5. System Architecture

Score Input
kern / MusicXML
→ music21 Extraction
65 features
→ XGBoost
P(Haydn) + explanation
→ Web App
FastAPI + Chart.js

The system is implemented in Python and deployed as a FastAPI web application. Researchers can upload a score and receive a probabilistic attribution with feature-level explanations, a radar chart showing the stylistic profile across six dimensions, and a ranked list of similar works—all within seconds.

6. Discussion

Our system offers three advantages over previous approaches. First, the music-theoretically grounded features make predictions interpretable in musicological terms. Second, the web deployment removes technical barriers. Third, the modular architecture facilitates extension to additional composers and genres.

Limitations include the modest corpus size (94 works), restriction to keyboard works, and the lack of rigorous cross-validation. The Robert Schumann result (76.5%) reveals vulnerability to surface-level textural similarities when encountering genres absent from training. Three orchestration features are currently placeholders, reducing effective features to 62.

Planned extensions include expanding the corpus to string quartets and symphonies, incorporating additional contrast composers (Michael Haydn, Pleyel, Dittersdorf), implementing leave-one-out cross-validation, and applying the system to the Hoboken catalogue's disputed works (Hob. I:105–108).

7. Conclusion

We have presented a computational framework for musical authorship attribution combining music-theoretically motivated feature extraction with interpretable machine learning. Applied to the Haydn–Mozart distinction, the system achieves complete class separation, with the most informative features—rhythmic variability, harmonic diversity, and pitch register preferences—aligning with established musicological characterizations. By providing transparent, feature-level explanations, the system complements traditional musicological analysis rather than replacing it.

Appendix A: Complete Feature Definitions

A.1 Harmonic Features (n = 15)

chord_diversity
Number of unique chord types / total chords. Measures harmonic vocabulary richness. Range: [0, 1]
major_chord_ratio
Proportion of chords classified as major triads. Range: [0, 1]
minor_chord_ratio
Proportion of chords classified as minor triads. Range: [0, 1]
dominant_seventh_ratio
Proportion of dominant seventh chords. Range: [0, 1]
diminished_ratio
Proportion of diminished triads or seventh chords. Range: [0, 1]
modulation_count
Number of detected key changes via 8-measure windowed analysis. Range: integer ≥ 0
dissonance_rate
Proportion of successive melodic intervals classified as dissonant (m2, M2, m7, M7, A4, d5). Range: [0, 1]
cadence_authentic_ratio
Proportion of chord bigrams matching V→I. Range: [0, 1]
cadence_half_ratio
Proportion of chord bigrams ending on V. Range: [0, 1]
cadence_deceptive_ratio
Proportion of chord bigrams matching V→vi. Range: [0, 1]
chord_bigram_entropy
Shannon entropy H = −∑ pi log2 pi of two-chord sequences. Higher = less predictable. Range: ≥ 0
tonic_ratio
Proportion of chords analyzed as tonic (I). Range: [0, 1]
subdominant_ratio
Proportion of chords analyzed as subdominant (IV). Range: [0, 1]
dominant_ratio
Proportion of chords analyzed as dominant (V). Range: [0, 1]
median_chord_duration
Median chord duration in quarter-note lengths. Range: > 0

A.2 Melodic Features (n = 15)

interval_mean
Mean absolute interval size in semitones between successive notes. Range: ≥ 0
interval_std
Standard deviation of absolute interval sizes. Range: ≥ 0
interval_skew
Skewness of interval distribution. Positive = tail toward large leaps. Range: any real number
step_ratio
Proportion of intervals ≤ 2 semitones (steps). Range: [0, 1]
leap_ratio
Proportion of intervals > 2 semitones (leaps). Range: [0, 1]
ascending_ratio
Proportion of ascending (positive) intervals. Range: [0, 1]
unison_ratio
Proportion of intervals of size zero (repeated pitches). Range: [0, 1]
interval_bigram_entropy
Shannon entropy of interval-direction bigrams (step-up, step-down, leap-up, leap-down, unison). Range: ≥ 0
interval_trigram_entropy
Shannon entropy of interval-direction trigrams. Range: ≥ 0
largest_interval
Maximum absolute interval in the score (semitones). Range: integer ≥ 0
theme_length_est
Notes before first rest ≥ 1 quarter note. Proxy for initial phrase length. Range: integer > 0
pitch_range
Highest minus lowest MIDI pitch (semitones). Range: integer ≥ 0
pitch_mean
Mean MIDI pitch (C4 = 60). Range: any real number
pitch_std
Standard deviation of MIDI pitches. Range: ≥ 0
repetition_density
Proportion of pitch bigrams occurring more than once. Measures motivic repetition. Range: [0, 1]

A.3 Structural Features (n = 10)

total_measures
Total measures in the score. Range: integer > 0
total_notes
Total Note objects (excluding rests, chords). Range: integer ≥ 0
notes_per_measure
Notes / measures. Proxy for textural density. Range: > 0
num_movements
Number of Part objects (voices/movements). Range: integer > 0
time_sig_changes
Number of time signature changes. Range: integer ≥ 0
has_menuett
1 if any 3/4 time signature present, 0 otherwise. Range: {0, 1}
measure_length_std
Std. dev. of measure durations (quarter notes). Range: ≥ 0
repeat_ratio
Measures with repeats / total. (Placeholder, returns 0.) Range: [0, 1]
longest_section_ratio
Longest Part duration / total duration. Range: [0, 1]
shortest_section_ratio
Shortest Part duration / total duration. Range: [0, 1]

A.4 Orchestration Features (n = 10)

num_parts
Number of notated voices. Range: integer > 0
voice_crossing_rate
Proportion of sampled measures where a lower voice exceeds an upper voice's pitch. Range: [0, 1]
highest_part_mean_pitch
Mean MIDI pitch of the highest-pitched part. Range: real number
lowest_part_mean_pitch
Mean MIDI pitch of the lowest-pitched part. Range: real number
part_range_spread
Std. dev. of pitch ranges across parts. Range: ≥ 0
doubling_rate †
Proportion of beats with unison doublings. (Placeholder.) Range: [0, 1]
part_independence †
Inverse mean pitch correlation between parts. (Placeholder.) Range: real number
pitch_density
Average simultaneously sounding pitches per chord. Range: > 0
outer_voice_interval_mean
Mean interval (semitones) between outermost voices. Range: ≥ 0
texture_changes †
Number of changes in active part count. (Placeholder.) Range: integer ≥ 0

† Placeholder features returning 0 in current implementation.

A.5 Rhythmic Features (n = 10)

note_value_mean
Mean note duration in quarter-note lengths. Range: > 0
note_value_std
Std. dev. of note durations. Higher = more rhythmic variety. Range: ≥ 0
dotted_note_ratio
Proportion of dotted notes. Range: [0, 1]
syncopation_rate
Proportion of notes starting off-beat. Range: [0, 1]
rest_ratio
Rests / (notes + rests). Range: [0, 1]
shortest_note_ratio
Proportion of notes ≤ sixteenth note (0.25 quarter lengths). Range: [0, 1]
longest_note_ratio
Proportion of notes > half note (2.0 quarter lengths). Range: [0, 1]
eighth_note_ratio
Proportion of eighth notes (0.25–0.5 quarter lengths). Range: [0, 1]
quarter_note_ratio
Proportion of quarter notes (0.5–1.0 quarter lengths). Range: [0, 1]
half_note_ratio
Proportion of half notes (1.0–2.0 quarter lengths). Range: [0, 1]

A.6 Metadata Features (n = 5)

key_numeric
Pitch class of detected key: C=0, C♯/D♭=1, D=2, …, B=11. Range: {0, …, 11}
mode_is_major
1 if major, 0 if minor. Range: {0, 1}
initial_tempo
First metronome mark in BPM. 0 if absent. Range: ≥ 0
time_sig_numerator
Numerator of initial time signature (e.g., 3 for 3/4). Range: integer > 0
time_sig_denominator
Denominator of initial time signature (e.g., 4 for 3/4). Range: integer > 0

References

  1. Brunner, G., Konrad, A., Wang, Y., and Wattenhofer, R. (2018). MIDI-VAE: Modeling dynamics and instrumentation of music with applications to style transfer. Proc. 19th ISMIR Conf.
  2. Chen, T. and Guestrin, C. (2016). XGBoost: A scalable tree boosting system. Proc. 22nd ACM SIGKDD, pp. 785–794.
  3. Cope, D. (1996). Experiments in Musical Intelligence. A-R Editions.
  4. Cuthbert, M. S. and Ariza, C. (2010). music21: A toolkit for computer-aided musicology. Proc. 11th ISMIR Conf., pp. 637–642.
  5. Dubnov, S., Assayag, G., Lartillot, O., and Bejerano, G. (2003). Using machine-learning methods for musical style modeling. Computer, 36(10):73–80.
  6. Grinsztajn, L., Oyallon, E., and Varoquaux, G. (2022). Why do tree-based models still outperform deep learning on tabular data? NeurIPS, vol. 35.
  7. Herremans, D. and Chew, E. (2016). Tension ribbons: Quantifying and visualising tonal tension. Proc. 2nd TENOR Conf.
  8. Hoboken, A. van (1957). Joseph Haydn: Thematisch-bibliographisches Werkverzeichnis, vol. 1. Schott.
  9. Huron, D. (1997). Humdrum and Kern: Selective feature encoding. In Beyond MIDI, pp. 375–401. MIT Press.
  10. Krumhansl, C. L. (1990). Cognitive Foundations of Musical Pitch. Oxford University Press.
  11. Landon, H. C. R. (1978). Haydn: Chronicle and Works, 5 vols. Thames and Hudson.
  12. Sapp, C. S. (2005). Online database of scores in the Humdrum file format. Proc. 6th ISMIR Conf., pp. 664–665.
  13. Stamatatos, E. (2009). A survey of modern authorship attribution methods. JASIST, 60(3):538–556.
  14. van den Oord, A., Dieleman, S., and Schrauwen, B. (2016). Deep content-based music recommendation. NeurIPS.
  15. Velarde, G., Weyde, T., and Meredith, D. (2018). Composer classification models for music-theory building. Proc. 19th ISMIR Conf.
  16. Webster, J. (2001). Haydn, (Franz) Joseph. In The New Grove Dictionary of Music, 2nd ed. Macmillan.