# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import gensim
import pickle


infile = open('patientnumber_to_stringtextfile_dict', 'rb')
patient_to_stringtextfile = pickle.load(infile)


def create_tagged_data(pat_to_textfile):
    tagged_documents = []
    for pat_num in pat_to_textfile:
        tagged_documents.append(gensim.models.doc2vec.TaggedDocument(words=pat_to_textfile[pat_num], tags=['Patient' + str(pat_num)]))
    return tagged_documents


tagged_documents = create_tagged_data(patient_to_stringtextfile)

model = gensim.models.doc2vec.Doc2Vec(tagged_documents, vector_size=400, window=10, min_count=1, workers=6)

model.train(tagged_documents, total_examples=len(tagged_documents), epochs=10)

model.save('docembeddings_dim_400_window_10')

model.docvecs['Patient11']



StarcoderdataJupyterScriptsDedupFiltered