# Using Enhanced Representations to Predict Medical Procedures from Clinician Notes
## 4 Implementation Design and Evaluation
### ICD Encoding  
Since each medical record usually has multiple ICD codes assigned to it, both for diagnoses and procedures, we use a multi-hot representation to describe the collection of codes related to any given case, with a single vector where each position relates to a specific code. We perform set expansion for the diagnoses codes by considering the hierarchical structure of ICD codes, which first groups whole families of codes with similar characteristics and then, within each subsequent category in the hierarchy, describes specific codes with increasing detail. In the ICD-9 standard, the leading digits of a diagnosis code represent its main category, and the following encode its clinical details, as shown in Figure 4. To obtain the general category of any given code, only the leftmost part of its detailed code is taken. As a result, we consider three representations for each diagnosis code in the evaluation: its main category, the fully qualified code if available, and the expanded representation that consists of a combination of both, each represented as multi-hot vectors. Another consideration is the frequency with which any code is assigned to a medical record. Some codes are more frequent and therefore likely to appear in more medical records compared to others that are assigned sparingly. Following this idea, some studies approached the task of automatic ICD coding by selecting a reduced subset of the most frequent codes seen across all medical records in their database of choice, suggesting that these codes cover most cases [3]. Using a reduced ICD code space ultimately improves prediction performance by omitting uncommon codes. For a better comparison with the SOTA, we considered two subsets of ICD codes covering the 10 and 50 most frequent codes for both diagnoses and procedures, which correspond to the most popular configurations in the literature [3; 10; 11]. Nevertheless, it should also be noted that reducing the label space comes at a cost, as it can negatively impact the overall reliability, especially in the healthcare domain, where infrequent codes, either from diagnoses or procedures, tend to be clinically relevant, as noted by [PERSON] et al. [45]. To visualize this phenomenon in actual data, we provide Figure 5, which shows the distribution of ICD codes (both diagnoses and procedures) per number of documents in which they appear in MIMIC-III. In the figure, the horizontal axis represents the distribution of codes for different subsets, sorted from least to most reoccurring, while the vertical axis shows the actual number of documents in which they appear. Bold-faced values represent the highest number of documents in which the most frequently reoccurring code appears. The distribution corroborates that most ICD codes are rarely assigned to many different records, while a small group of codes are the most prevalent across records. This behavior is also equally present for both diagnosis codes and procedure codes. Figure 4: ICD diagnosis code hierarchy. When using subsets with the most frequent ICD codes, the representation is symmetric in terms of cardinality, which means that the number of procedure codes to predict is always the same as the number of diagnosis codes in the input. To select the codes of each subset, we first find the top diagnosis codes (_top-n\({}_{D}\)_) for a given collection of records. We keep only the documents that contain at least one diagnosis code, and then repeat the same process to obtain the top procedure codes (_top-n\({}_{P}\)_) using the remaining records. This process ensures that medical records always contain valid entries with at least one diagnosis and one associated procedure. As a result of this step, we end up with a variety of representations, which leads to different inputs to consider in the prediction task, depending on the type of description used for the diagnosis code (main category, full code, or both), and the _top-n\({}_{D}\)_ and _top-n\({}_{P}\)_ subsets considered in each case.