Code for estimating country-level musical opinion signals and comparing
multidimensional DeGroot, Friedkin--Johnsen (FJ), and state-dependent DeGroot
(SD-DeGroot) models.
This repository intentionally contains source code only. Datasets, model weights, embeddings, intermediate files, figures, and experiment outputs are excluded.
- Period: 1875--1940
- Agents: Russia, France, Germany, Austria, and Others
- Representation: ChordBERT work embeddings
- State space: PC1--PC23 (more than 90% cumulative explained variance)
- Signal extraction: causal Kalman filtering
- Training transitions: 1875--1925
- Recursive forecasts: 1930, 1935, and 1940
- Models:
- multidimensional DeGroot;
- multidimensional FJ;
- scale-normalized SD-DeGroot.
The PCA-weighted specifications use normalized explained-variance ratios in the estimation loss. Weighting does not alter the transition equation or introduce cross-component interactions.
src/ ChordBERT, PCA, Kalman, and Python dynamics code
opinion_dynamics/
degroot_fj/ Variance-weighted DeGroot and FJ
fj/ Independent multidimensional FJ implementation
sd_degroot/ Scale-normalized SD-DeGroot and figure generators
reproducibility/ Wolfram/Node experiment runners
mathematica/ Original reference notebooks
chord_embedding/chordbert/ Chord parsing and model inference utilities
midi_experiment/src/ Optional MIDI/BiLSTM supplement
The main data source is the Cross-era Dataset. Composition years can be obtained from cross-era-classical-work-years.
Large assets are not versioned. Place or generate them under the paths expected by the scripts:
data/ Raw and processed datasets
chord_embedding/dataset/ Generated chord-sequence splits
chord_embedding/chordbert/ Downloaded or trained model directories
output/ Generated embeddings, signals, metrics, and figures
All these paths are ignored by Git.
Python 3.10 or newer is recommended.
python -m venv .venv
pip install -r requirements.txtThe opinion-dynamics scripts additionally require Wolfram Language 13.3 or newer. Figure SVG generators use Node.js 18 or newer and only built-in modules.
python src/preprocess.py
python src/build_chordbert_datasets.py
python src/evaluate_chordbert.py
python src/analyze_chordbert_pca_1875_1940.py
python src/evaluate_degroot_chordbert_window_minmax.py
python src/evaluate_fj_chordbert_window_minmax.pyScripts resolve paths relative to the repository root and create output/
when needed.
Run from the repository root:
wolframscript -file opinion_dynamics/degroot_fj/VarianceWeighted_DeGroot_FJ_PC1_PC23.wls
wolframscript -file opinion_dynamics/sd_degroot/ScaleNormalized_SDDeGroot_Equal_and_PCAWeighted_PC1_PC23.wls
wolframscript -file opinion_dynamics/sd_degroot/Export_ActualState_W_Diagnostics.wlsThe scale-normalized SD-DeGroot model uses
U_ij(t) = log(B_j) - h_i d_ij(t)/tau_d + Gamma_j q_j(t)/tau_q,
where B is a positive simplex, d_ij is RMS stylistic distance, q_j is
RMS distance from the cross-country centroid, and tau_d and tau_q are
training-period medians. It uses no min--max scaling, clipping, or held-out
information.
- Kalman filtering is causal.
- Training uses states through 1925 only.
- Forecasts for 1930--1940 are recursive.
- PCA variance weights affect estimation losses only.
- Actual-state influence matrices for 1930 and 1935 are diagnostic and are never used to produce forecasts or evaluation metrics.
See midi_experiment/README.md. Its external dataset and model weights are intentionally excluded.
@misc{he2026modelingstylisticcoevolutionsymbolic,
title={Modeling Stylistic Co-evolution in Symbolic Music Heritage Collections},
author={Yulong He and Ivan Smirnov and Yanming Li},
year={2026},
eprint={2607.23957},
archivePrefix={arXiv},
primaryClass={cs.SD},
url={https://arxiv.org/abs/2607.23957},
}