Assign a given visit to the closest cluster from a given clustering. The function generates the embedding of the visit (by the function embed_visit) and computed the squared Euclidean distance from the clusters' centers.

assign_visit_to_cluster(visit_description, clusters, inter_term_vectors,
  exam_term_vectors)

Arguments

visit_description

A named two element vector (with names: inter and exam) of concatenated terms of interview and examination, separated by ", "

clusters

An output of the function cluster_visits

inter_term_vectors

A matrix of embeddings of the interview terms

exam_term_vectors

A matrix of embeddings of the examination terms

Value

A list of:

cl

The number of the closest cluster

distances

The vector of distances to each cluster

Examples

inter_term_vectors <- embed_terms(interviews, embedding_size = 10L, term_count_min = 1L)
#> Error in .subset2(public_bind_env, "initialize")(...): unused arguments (word_vectors_size = 10, vocabulary = list(c("fever", "rhinitis", "cough", "eye", "thyroid"), c(3, 3, 4, 4, 6), c(3, 3, 4, 4, 6)))
exam_term_vectors <- embed_terms(examinations, embedding_size = 10L, term_count_min = 1L)
#> Error in .subset2(public_bind_env, "initialize")(...): unused arguments (word_vectors_size = 10, vocabulary = list(c("fever", "man", "mother", "cough", "heart", "patient", "thyroid", "eye", "rhinitis", "woman", "father"), c(2, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7), c(2, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7)))
visits_vectors <- embed_list_visits(interviews, examinations, inter_term_vectors, exam_term_vectors)
#> Error in ncol(term_vectors): object 'inter_term_vectors' not found
clusters <- cluster_visits(visits_vectors, visits, spec = "internist", cluster_number = 2L)
#> Error in rownames(visits_vectors): object 'visits_vectors' not found
assign_visit_to_cluster(c(inter = "cough, fever, rhinitis", exam = ""), clusters, inter_term_vectors, exam_term_vectors)
#> Error in ncol(term_vectors): object 'inter_term_vectors' not found
assign_visit_to_cluster(c(inter = "thyroid", exam = ""), clusters, inter_term_vectors, exam_term_vectors)
#> Error in ncol(term_vectors): object 'inter_term_vectors' not found
assign_visit_to_cluster(c(inter = "cough, fever, rhinitis", exam = "patient, heart"), clusters, inter_term_vectors, exam_term_vectors)
#> Error in ncol(term_vectors): object 'inter_term_vectors' not found