assign_visit_to_cluster: Assign Visit to the Cluster

Description Usage Arguments Value Examples

View source: R/clustering.R

Description

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.

Usage

1
2
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
inter_term_vectors <- embed_terms(interviews, embedding_size = 10L,
                                  term_count_min = 1L)
exam_term_vectors <- embed_terms(examinations, embedding_size = 10L,
                                 term_count_min = 1L)
visits_vectors <- embed_list_visits(interviews,
                                    examinations, inter_term_vectors, exam_term_vectors)
clusters <- cluster_visits(visits_vectors, visits,
                           spec = "internist",
                           cluster_number = 2L)
assign_visit_to_cluster(c(inter = "cough, fever, rhinitis", exam = ""),
                       clusters, inter_term_vectors, exam_term_vectors)
assign_visit_to_cluster(c(inter = "thyroid", exam = ""),
                       clusters, inter_term_vectors, exam_term_vectors)
assign_visit_to_cluster(c(inter = "cough, fever, rhinitis",
                         exam = "patient, heart"),
                       clusters, inter_term_vectors, exam_term_vectors)

adamgdobrakowski/memr documentation built on Sept. 4, 2021, 3:45 a.m.