# Music Opinion Dynamics d1381d7a-6e4c-48fb-83c2-dacd0bf97027 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. ## Current experiment - 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. ## Repository layout ```text 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 ``` ## Data and model setup The main data source is the [Cross-era Dataset](https://www.audiolabs-erlangen.de/resources/MIR/cross-era). Composition years can be obtained from [cross-era-classical-work-years](https://huggingface.co/datasets/hreyulog/cross-era-classical-work-years). Large assets are not versioned. Place or generate them under the paths expected by the scripts: ```text 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. ## Installation Python 3.10 or newer is recommended. ```bash python -m venv .venv pip install -r requirements.txt ``` The 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. ## Main Python pipeline ```bash 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.py ``` Scripts resolve paths relative to the repository root and create `output/` when needed. ## Current opinion-dynamics models Run from the repository root: ```powershell 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.wls ``` The scale-normalized SD-DeGroot model uses ```text 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. ## Reproducibility and leakage control - 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. ## Optional MIDI supplement See [midi_experiment/README.md](midi_experiment/README.md). Its external dataset and model weights are intentionally excluded. ## Citation ```bibtex @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}, }