PsychiatryNLPKit.analysis.word_level_cosine_similarity
- PsychiatryNLPKit.analysis.word_level_cosine_similarity(content_word_embedding_vectors, sections=None)[source]
Cosine similarity between adjacent word embeddings per section.
- Notes:
Theoretical basis - NLP semantic coherence measured by cosine similarity is highly correlated with TLC positive thought disorder items of tangentiality, circumstantiality and derailment. Higher semantic similarity can predict increased impoverishment of thought measured by TLI scores (Bilgrami et al., 2022; Elvevag et al., 2007; He et al., 2024).
- Args:
- content_word_embedding_vectors: Dict mapping section names to pre-trained
word embedding tensors for content words (from
TextData.content_word_embedding_vectors).
sections: Sections to process.
Noneprocesses all sections in the dict.- Returns:
Dict mapping section names to a dict with key
"word_level_cosine_similarity". Empty sections receivefloat("nan").- References:
Bilgrami, Z. R., Sarac, C., Srivastava, A., Herrera, S. N., Azis, M., Haas, S. S., Shaik, R. B., Parvaz, M. A., Mittal, V. A., Cecchi, G., & Corcoran, C. M. (2022). Construct validity for computational linguistic metrics in individuals at clinical risk for psychosis: Associations with clinical ratings. Schizophrenia Research, 245, 90-96. https://doi.org/10.1016/j.schres.2022.01.019 Elvevag, B., Palmer, B. W., Gold, J. M., & Jeste, D. V. (2007). Semantic coherence of speech in schizophrenia and bipolar disorder. Schizophrenia Research, 93(1-3), 304-316. https://doi.org/10.1016/j.schres.2007.03.001 He, R., Palominos, C., Zhang, H., Alonso-Sánchez, M. F., Palaniyappan, L., & Hinzen, W. (2024). Navigating the semantic space: Unraveling the structure of meaning in psychosis using different computational language models. Psychiatry Research, 333, 115752. https://doi.org/10.1016/j.psychres.2024.115752