<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sanjeev Khanna on Medium]]></title>
        <description><![CDATA[Stories by Sanjeev Khanna on Medium]]></description>
        <link>https://medium.com/@sanjeevbkhanna?source=rss-551c875670d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MRpX9hKQgOyLwAPB.jpg</url>
            <title>Stories by Sanjeev Khanna on Medium</title>
            <link>https://medium.com/@sanjeevbkhanna?source=rss-551c875670d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 04:36:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sanjeevbkhanna/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Predicting surgical complications from patient health data]]></title>
            <link>https://medium.com/@sanjeevbkhanna/sanjeevkhannainsights-dd0ae3aa6903?source=rss-551c875670d------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd0ae3aa6903</guid>
            <dc:creator><![CDATA[Sanjeev Khanna]]></dc:creator>
            <pubDate>Wed, 26 Jun 2019 22:08:34 GMT</pubDate>
            <atom:updated>2019-07-03T19:29:16.140Z</atom:updated>
            <content:encoded><![CDATA[<h3>C.O.R.N.E.A: Cataract Outcome Results from Novel and Exploratory Analyses</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*A2Hx4ZCv4eds8w18xI-P_w.png" /><figcaption><a href="https://craftoptics.com/cataracts-and-craftoptics/">https://craftoptics.com/cataracts-and-craftoptics/</a></figcaption></figure><p>Over 3 million cataract surgeries are performed every year in the US. Complications from surgeries can result in partial or full loss of vision, an important determinant of quality of life. Predicting surgical complications would provide value to clinicians by identifying high risk patient populations, who could be more closely monitored post-surgery.</p><p><strong>Introduction:</strong></p><p>For my Insight project, I worked in consultation with a local San Francisco company. One aspect of this company’s work focuses on retrospective statistical analyses of post-operative complications to cataract surgery; however, a predictive framework had not been investigated to date. Thus, the goal of this project was to lay the groundwork for a predictive model that the company could later expand upon. Specifically, we were interested in whether surgical complications can be predicted from patient medical information, and if they could, what features are important. We envisioned how this project could be implemented as a product, deciding that model and feature interpretability should be emphasized, as future applications of this project could help inform clinical decision making and provide a data-driven profile of patients who are at high risk for complication.</p><p>Patient information came from a clinical data repository aggregated across numerous doctor’s offices. The information was provided on an Amazon Web Services (AWS) cluster and consisted of four main files. The first file included a list of deidentified patient IDs, an index of the cataract surgery, which eye the surgery was performed on, and whether the patient experienced a surgical complication in the year after the surgery. The second and third files contained historical pre-operative diagnosis and procedure codes corresponding to each patient. Diagnosis codes were in ICD-10 format, while procedure codes were in CPT and HCPC format. ICD-10 and CPT/HCPC codes are standardized medical nomenclatures required for healthcare billing and reimbursement purposes. For example, a specific ICD-10 code might identify a given patient as having had a heart attack, while a specific CPT code might signal that during a doctor’s office visit the patient underwent a routine physical examination. The fourth and final file contained limited demographic information and all patient information was deidentified.</p><p><strong>Data cleaning and wrangling:</strong></p><p>After completing the necessary HIPAA training, I was granted access to the data files and was excited to begin merging the files and proceeding to feature selection in my Python Jupyter notebook! However, upon merging the label information with the procedure and diagnosis codes… I promptly maxed out the AWS instance I was working on. I quickly realized that having a very large patient dataset to begin with, and then merging diagnosis and procedure information for each patient, resulted in VERY large data structures that Python is not typically equipped to handle. Enter PySpark:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*jKlLqS5p0JA5wvabiFbEmA.jpeg" /></figure><p>PySpark is a collaboration between Apache Spark, an open-source cluster-computing framework, and Python, the general-purpose high-level programming language many of us hold dearly. Because of its distributed computing framework, PySpark is very useful for manipulating large datasets. Due to the limited time frame to complete this project, and having no previous experience with PySpark, I prioritized learning enough PySpark to clean and format the data, and eventually export the data in a format that could be loaded in Python for further analyses.</p><p>The cleaning and formatting consisted of two main steps. First, I filtered out codes that did not exactly match the structured format of the ICD-10 and CPT nomenclature. In their standard form, ICD-10 codes are alphanumeric (such as H27.01) while CPT codes are 6 digits (such as 69547). For example, the filtering found and removed codes that might have had a typo, such as “6954*”, an ICD-10 code where it should have been a CPT code, or codes which contained code modifiers that might be used for billing purposes, such as “69547A”. Second, I merged the labeled complication file with the corresponding demographic, procedure, and diagnosis information, and ensured I had a sufficient number of complication and no complication samples. By filtering the diagnosis and procedure codes, I was able to standardize every code, which greatly helped when encoding the hierarchical structure of the features (see below). Once I had the merged dataframe, I saved it as a .csv file for later analysis in Python, with a total of 20,000 patients with complications and 20,000 without complications.</p><p><strong>Feature encoding of diagnosis and procedure codes:</strong></p><p>Having successfully loaded a subsample of the patient dataset into Python I was now ready to begin generating the features to input into my model. I encountered another obstacle very quickly: how to encode the diagnosis information. This came about because of the hierarchical nature of the ICD-10 coding scheme. As you can see in the example below, each portion of the ICD-10 code corresponds to a different diagnosis level, in this case from a general description relating to the eye to a very specific type of cataract diagnosis. This meant a given diagnosis code could be encoded as a feature in many ways, from very granular (cortical age-related cataract) to very general (disease of the eye and adnexa). A similar hierarchical structure is present in the CPT procedure codes as well. Even when only looking at one of the intermediate levels, the number of unique diagnosis and procedure codes was over 7500!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*YftBrBCw1AYByWIBWiN5xA.png" /></figure><p><strong>Feature selection:</strong></p><p>Because of the exploratory nature of the project, combined with a very large potential feature space, I knew I needed a principled approach regarding feature selection. I began by identifying diagnosis and procedure codes that appeared most often across patients. However, just because a code appeared frequently did not mean it was informative between complication and no complication cases. To address this, I visually inspected the distribution of complications and no complications for a given feature, and then ran chi-square tests to determine whether the proportion of patients that experienced a complication was statistically significant for a given feature. Additionally, working with the consulting company, I presented preliminary findings to an ophthalmologist to determine if my data driven approach coincided with their clinical experience. Incorporating the statistical tests and clinical context resulted in a feature space of 25 features, which encompassed diagnosis information (both systemic and eye related diagnoses), demographic information, and generated features which described broad indications of patient health.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*bemMu-_9RWDHJUDDy2eLkA.png" /></figure><p><strong>Model implementation:</strong></p><p>I first divided the data into a training and testing set, with 80% of the trials going to training and 20% going to testing. I further subdivided the training set by 80/20 again to have a validation set for model iteration. I implemented a logistic regression model as well as tree based methods (random forest, boosted forest, and extreme boosted forest), with all models having a similar performance as measured by the area under the curve (AUC) of a receiver operating characteristic (ROC) curve. I selected the logistic regression model to move forward with identifying feature importance, as it was simplest model and had the benefit of maintaining directionality when examining the feature coefficients. As shown below, the logistic model performed above chance (indicated by the unity line), with an AUC value equal to .64.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*EJaelSfAID_0-mcCOYHe4Q.png" /></figure><p><strong>Feature importance:</strong></p><p>Having achieved the first goal of the project (to implement a model that could predict cataract surgery complications from patient data), I next turned to feature importance. I found that the model used information from all aspects of the features I had included, namely demographics, eye specific diagnoses, systemic diagnoses, and the broad measures of patient health I had generated myself. These features were further validated through discussions with an ophthalmologist. Interestingly, one of my generated features had the largest positive correlation with a complication classification!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*UWcSzkuDd65UMHp2jtpqjg.png" /></figure><p><strong>Conclusion:</strong></p><p>Over the course of 3 weeks, I generated a candidate model with features derived from patient data that could predict cataract surgery complications. Meaningful features came from a variety of different patient metrics, including demographics, systemic and eye related diagnoses, as well as features I generated that measured broad indications of patient health. Future directions include analyzing patients that had surgeries in both eyes, where only one eye resulted in a complication (as these patients are currently excluded from this analysis) to gain more insights into what the driving cause of complications could be. Additionally, complications vary in their severity, with the data available for this project aggregating across many different types of complications. Segmenting out the complications by their type could reveal that some features are more important than others for a specific type of complication. Finally, temporal information could be included, as perhaps <em>when</em> a diagnosis occurred is just as important as <em>what</em> diagnosis occurred.</p><p>From a value proposition standpoint, this project provides a foundation for the company I partnered with to analyze cataract surgery complications and highlights important features which can be built upon. Looking into the future, clinicians could use this model to identify high risk patient populations to either more closely monitor post-surgery or potentially revaluate whether the surgery should be performed at all. Additionally, medical device companies could use the insights gained from this project to identify underserved patient populations which could guide future prosthetic lens development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd0ae3aa6903" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>