<?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 Swatimaste on Medium]]></title>
        <description><![CDATA[Stories by Swatimaste on Medium]]></description>
        <link>https://medium.com/@swatimaste8?source=rss-fb09af16f89f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*AQGj-pSQ73GDqkFM.jpg</url>
            <title>Stories by Swatimaste on Medium</title>
            <link>https://medium.com/@swatimaste8?source=rss-fb09af16f89f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 12:22:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@swatimaste8/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[AI in Healthcare, Part 6: Prompting Techniques and Fine‑Tuning LLMs for Healthcare QA]]></title>
            <link>https://medium.com/@swatimaste8/ai-in-healthcare-part-6-prompting-techniques-and-fine-tuning-llms-for-healthcare-qa-60f5bd3bdadf?source=rss-fb09af16f89f------2</link>
            <guid isPermaLink="false">https://medium.com/p/60f5bd3bdadf</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[prompting-technique]]></category>
            <category><![CDATA[healthcare]]></category>
            <category><![CDATA[fine-tuning]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Swatimaste]]></dc:creator>
            <pubDate>Sun, 27 Jul 2025 15:13:45 GMT</pubDate>
            <atom:updated>2025-07-27T15:13:45.685Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Wr_fA0rycN6bRwQU07x0g.png" /></figure><p>Welcome to the final post in my <a href="https://medium.com/@swatimaste8/transforming-healthcare-with-artificial-intelligence-2ead0f166aad">AI in Healthcare series</a>! In earlier blogs we explored structured healthcare data, built ML models, and even trained deep learning networks. Now we move into one of the most exciting areas in AI today — <strong>Large Language Models (LLMs)</strong>—and how they can be applied in healthcare, specifically for <strong>medical question answering (MedQA)</strong>.</p><p>I’ll walk you through not only what I implemented, but also why each step matters and what other approaches you could consider.</p><p><strong>GitHub: </strong><a href="https://github.com/SwatiMaste/AI-in-HealthCare/tree/main/LLM"><strong>Code for Prompting methods and Fine Tuning</strong></a></p><h3>Why LLMs Struggle With Medical QA</h3><p>Most modern LLMs (like GPT, LLaMA, TinyLlama) are trained on massive general‑domain corpora. They do surprisingly well on many everyday tasks out‑of‑the‑box. However, when it comes to <strong>domain‑specific</strong> tasks such as medical question answering, their performance often drops. Why?</p><ul><li><strong>Medical data is sensitive and less available</strong> for pretraining, which I have also discussed in detail in my <a href="https://medium.com/@swatimaste8/transforming-healthcare-with-artificial-intelligence-2ead0f166aad">first blog</a> of the series.</li><li><strong>Specialized terminology and reasoning</strong> are not common in general datasets.</li><li><strong>High stakes:</strong> a wrong answer in medicine can be dangerous, so accuracy and explainability matter more than ever.</li></ul><p>That’s why I’ve experimented with two approaches:</p><ol><li><strong>Prompt engineering</strong>—improving performance without retraining.</li><li><strong>Fine-tuning with LoRA</strong>—adapting the model to the medical domain efficiently.</li></ol><h3>Dataset: MedMCQA</h3><p><a href="https://huggingface.co/datasets/openlifescienceai/medmcqa">MedMCQA</a> is a large collection of multiple‑choice questions from medical entrance exams in India. Each question has four options (A/B/C/D) with one correct answer. It’s a great benchmark to test both prompting and fine‑tuning methods.</p><h3>Part 1: Prompting Methods with TinyLlama</h3><p>Prompting lets you get better results from an LLM <strong>without any training</strong> by simply designing the input cleverly.</p><h4>Zero‑Shot Prompting</h4><p>Ask the question directly with options, e.g.:</p><pre>Question: What is the treatment for condition X?<br>Options: A. ... B. ... C. ... D. ...<br>Answer:</pre><p>No extra context. Quick, but often shallow.</p><h4>Few‑Shot Prompting</h4><p>Add a few solved examples before your new question to guide the model’s reasoning. This often boosts accuracy.</p><h4>Chain‑of‑Thought Prompting</h4><p>Explicitly ask the model to reason step‑by‑step before answering:</p><pre>Let&#39;s think step by step. First, analyze the symptoms... Then choose the best answer:</pre><p>CoT prompting helps with complex reasoning tasks.</p><h4>Self‑Consistency</h4><p>Generate multiple answers using Chain‑of‑Thought and pick the most frequent. Improves robustness.</p><p><strong>Implementation highlight:</strong></p><pre>prompt = f&quot;Question: {question}\nOptions: A. {optA} B. {optB} C. {optC} D. {optD}\nAnswer:&quot;<br>inputs = tokenizer(prompt, return_tensors=&#39;pt&#39;).to(device)<br>response = model.generate(**inputs, max_new_tokens=50)</pre><blockquote><strong><em>Why prompting first?</em></strong><em> It’s quick, doesn’t require resources, and often gives a strong baseline. But it has limits — especially in domains like healthcare where training data is scarce and specialized knowledge is needed.</em></blockquote><p><a href="https://arxiv.org/abs/2212.06713">Read more about prompting methods</a></p><h3>Part 2: Fine‑Tuning TinyLlama with LoRA</h3><p>Prompting helps, but for sustained improvements we need to actually adapt the model to our domain. Performing a full fine‑tuning of a large language model is extremely resource‑intensive and requires powerful hardware. <strong>LoRA (Low‑Rank Adaptation)</strong> offers a smarter alternative: instead of updating all parameters, it inserts and trains small low‑rank adapter layers within the model while keeping the original weights frozen. This significantly reduces computation and memory requirements while still allowing the model to learn domain‑specific nuances.</p><p><strong>PEFT (Parameter‑Efficient Fine‑Tuning)</strong> is the broader framework we are using here. LoRA is just one technique under PEFT — other approaches include Prefix Tuning, P‑Tuning v2, QLoRA and more, each offering its own way to fine‑tune large models efficiently.</p><p><strong>Why LoRA?</strong></p><ul><li>It dramatically lowers GPU memory and compute needs compared to full fine-tuning.</li><li>Because the base model weights remain frozen, the same base model can be reused with different LoRA adapters for different tasks.</li><li>In practice, LoRA often reaches performance levels close to traditional full fine-tuning, making it a very efficient choice for specialized domains like healthcare.</li></ul><p><strong>What the code does in detail:</strong></p><ol><li><strong>Prepare a subset of MedMCQA</strong> with Q&amp;A pairs so that we can train quickly and experiment without using the entire dataset.</li><li><strong>Configure LoRA adapters:</strong> Here we specify how and where to add trainable adapters to our model.</li></ol><ul><li>r=8: sets the rank of the adapter matrices; lower ranks mean fewer parameters.</li><li>lora_alpha=32: a scaling factor controlling how much the adapter updates affect the model’s output.</li><li>target_modules=[&quot;q_proj&quot;,&quot;k_proj&quot;,&quot;v_proj&quot;,&quot;o_proj&quot;]: These are the internal projection layers in the transformer’s attention mechanism where LoRA adapters are inserted.</li><li>lora_dropout=0.1: adds dropout inside the adapters to reduce overfitting.</li><li>bias=&quot;none&quot;: we are not fine-tuning bias terms, only adapter weights.</li><li>task_type=&quot;CAUSAL_LM&quot;: tells PEFT we are doing causal language modeling.</li></ul><pre>lora_config = LoraConfig(<br>    r=8,<br>    lora_alpha=32,<br>    target_modules=[&quot;q_proj&quot;,&quot;k_proj&quot;,&quot;v_proj&quot;,&quot;o_proj&quot;],<br>    lora_dropout=0.1,<br>    bias=&quot;none&quot;,<br>    task_type=&quot;CAUSAL_LM&quot;<br>)<br>model = get_peft_model(base_model, lora_config)</pre><p>This wraps the base model with LoRA adapters so only these small matrices are updated during training.</p><p><strong>3. Train using PEFT’s SFTTrainer:</strong></p><ul><li>model: the wrapped TinyLlama with LoRA adapters.</li><li>train_dataset: the processed MedMCQA subset.</li><li>tokenizer: ensures inputs and outputs align with TinyLlama’s vocabulary.</li><li>training_args: includes hyperparameters like learning rate, epochs, and batch size.</li></ul><pre>trainer = SFTTrainer(<br>    model=model,<br>    train_dataset=train_data,<br>    tokenizer=tokenizer,<br>    args=training_args<br>)<br>trainer.train()</pre><p>After runningtrain() , only the LoRA adapter weights are updated, giving you a domain‑specialized model with minimal compute cost.</p><p>💡 <strong>A note on </strong><strong>task_type=&quot;CAUSAL_LM&quot;:</strong> In this configuration, we are telling PEFT that our base model is a decoder‑only model trained for left‑to‑right text generation, also known as causal language modeling. This is the right choice when your model predicts the next token given previous tokens (as with GPT, LLaMA, TinyLlama).</p><p>Other options exist depending on your base model and task:</p><ul><li>SEQ_CLS: for sequence classification tasks such as sentiment analysis or intent detection.</li><li>TOKEN_CLS: for token‑level classification like named entity recognition.</li><li>SEQ_2_SEQ_LM: for encoder–decoder models (like T5) used in summarization or translation.</li><li>QUESTION_ANSWERING: for span‑based QA models that point to answer spans in context.</li></ul><p>Choosing the correct⁣ task_type ensures that PEFT configures the adapters and training loops properly for your use case.</p><p><a href="https://huggingface.co/docs/peft/index">PEFT and LoRA Documentation</a></p><h3>Results &amp; Observations</h3><ul><li><strong>Prompting alone:</strong> Chain‑of‑Thought and Self‑Consistency outperformed Zero‑Shot, showing the power of better instructions.</li><li><strong>After LoRA fine-tuning,</strong> accuracy on MedMCQA improved significantly. The model produced more consistent, domain‑appropriate answers.</li></ul><blockquote><strong><em>Evaluation matters:</em></strong><em> In medical QA, don’t rely only on accuracy. Look at precision, recall, and error cases to understand where the model might fail.</em></blockquote><h3>What You Can Try Next</h3><ul><li>Explore <a href="https://www.geeksforgeeks.org/artificial-intelligence/react-reasoning-acting-prompting/"><strong>ReAct prompting</strong></a> (reasoning + acting) for multi‑step problems.</li><li>Try other PEFT techniques like <a href="https://ankitasinha0811.medium.com/ways-to-improve-an-llm-performance-while-keeping-the-llm-weights-frozen-7f67d740c5e2"><strong>Prefix Tuning</strong> or <strong>P‑Tuning v2</strong></a>.</li><li>Experiment with different medical QA datasets.</li><li>Combine text with images (multimodal LLMs) for richer clinical insights.</li></ul><p>This wraps up my AI in Healthcare series! We’ve gone from EDA and classical ML to deep learning and finally to advanced LLM techniques tailored for healthcare. I hope these posts give you a strong starting point to build and experiment with AI solutions that make a real difference in medicine!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60f5bd3bdadf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI in Healthcare, Part 5: Autism Detection using Deep Learning]]></title>
            <link>https://medium.com/@swatimaste8/ai-in-healthcare-part-5-autism-detection-using-deep-learning-f7fd3a3298c9?source=rss-fb09af16f89f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7fd3a3298c9</guid>
            <category><![CDATA[vgg19]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[healthcare]]></category>
            <dc:creator><![CDATA[Swatimaste]]></dc:creator>
            <pubDate>Sun, 27 Jul 2025 14:04:00 GMT</pubDate>
            <atom:updated>2025-07-27T14:04:00.499Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7l6-3TaqDjwblnQLp1Ac9A.png" /></figure><p>Welcome to Part 5 of my <a href="https://medium.com/@swatimaste8/transforming-healthcare-with-artificial-intelligence-2ead0f166aad">AI in Healthcare series</a>! In the earlier posts, we explored how to work with clinical datasets, preprocess features, and build machine learning models. In this blog, we take a leap into <strong>deep learning</strong> and see how convolutional neural networks (CNNs) can be used to detect autism from images.</p><p>Link to Kaggle Dataset: <a href="https://www.kaggle.com/datasets/arifulislamjoy/autism-image-dataset">Image Dataset</a></p><p>Link to GitHub: <a href="https://github.com/SwatiMaste/AIH-Autism-Detection/tree/main">Dataset and Code</a></p><p>I’ll walk you through the concepts, why we make certain choices, and what alternatives you can explore on your own.</p><h3>Dataset &amp; Preprocessing</h3><p>For this project, I used a dataset organized into two folders: Autistic and NonAutistic, each containing images. We first read the file names and created a DataFrame with two columns:</p><ul><li><strong>filename</strong> (image name)</li><li><strong>category</strong> (0 for NonAutistic, 1 for Autistic)</li></ul><pre>filenames = os.listdir(&quot;/content/AIH-Autism-Detection/AutismDataset/train&quot;)<br>categories = []<br>for filename in filenames:<br>    category = filename.split(&#39;.&#39;)[0]<br>    if category == &#39;Autistic&#39;:<br>        categories.append(str(1))<br>    else:<br>        categories.append(str(0))</pre><pre>train_df = pd.DataFrame({&#39;filename&#39;: filenames, &#39;category&#39;: categories})</pre><p>To prevent overfitting, we use <strong>data augmentation</strong>:</p><pre>train_datagen = ImageDataGenerator(<br>    rotation_range=15,<br>    rescale=1./255,<br>    shear_range=0.1,<br>    zoom_range=0.2,<br>    horizontal_flip=True,<br>    width_shift_range=0.1,<br>    height_shift_range=0.1<br>)</pre><blockquote><strong><em>Why augment data?</em></strong><em> Medical image datasets are often small. Augmentation synthetically increases data variety, improving model generalization.</em></blockquote><p><a href="https://keras.io/api/preprocessing/image/">Learn more about ImageDataGenerator</a></p><h3>Why VGG19 and Transfer Learning?</h3><p>Training a CNN from scratch needs huge amounts of data and compute. Instead, we use <strong>transfer learning</strong>:</p><ul><li>Load a CNN which is already pretrained on ImageNet (millions of images)</li><li>Reuse its feature extraction layers</li><li>Add new layers for our task (here classifying a image as autistic or not)</li></ul><p>Here we use <strong>VGG19</strong>—a deep network with 19 layers known for strong feature extraction.</p><blockquote><strong><em>Alternatives to explore:</em></strong><em> ResNet50, EfficientNet, DenseNet — each offers different trade-offs in accuracy and speed.</em></blockquote><p>Read more: <a href="https://keras.io/guides/transfer_learning/">Introduction to Transfer Learning</a></p><h3>Model Architecture &amp; Implementation</h3><p>We start by loading VGG19 without its top layers:</p><pre>base_model = VGG19(weights=&#39;imagenet&#39;, include_top=False, input_shape=(224,224,3))<br>for layer in base_model.layers:<br>    layer.trainable = False  # freeze layers</pre><pre>model = Sequential([<br>    base_model,<br>    Flatten(),<br>    Dense(256, activation=&#39;relu&#39;),<br>    Dropout(0.5),<br>    Dense(2, activation=&#39;softmax&#39;)<br>])</pre><pre>model.compile(optimizer=Adam(learning_rate=0.0001), loss=&#39;categorical_crossentropy&#39;, metrics=[&#39;accuracy&#39;])</pre><blockquote><strong><em>Why freeze layers?</em></strong><em> We retain general image features from ImageNet and only train the top layers to adapt to autism detection.</em></blockquote><h3>Training with Callbacks</h3><p>To train efficiently and avoid overfitting, we use:</p><ul><li><strong>EarlyStopping:</strong> stop training when validation loss stops improving.</li><li><strong>ModelCheckpoint:</strong> save the best model weights.</li></ul><pre>earlystop = EarlyStopping(patience=10)<br>checkpoint = ModelCheckpoint(&#39;best_model.h5&#39;, save_best_only=True)</pre><pre>history = model.fit(<br>    train_generator,<br>    epochs=50,<br>    validation_data=validation_generator,<br>    callbacks=[earlystop, checkpoint]<br>)</pre><h3>Results &amp; Evaluation</h3><p>We can plot training and validation accuracy/loss to see convergence:</p><pre>plt.plot(history.history[&#39;accuracy&#39;])<br>plt.plot(history.history[&#39;val_accuracy&#39;])<br>plt.title(&#39;Model accuracy&#39;)<br>plt.xlabel(&#39;Epoch&#39;)<br>plt.ylabel(&#39;Accuracy&#39;)<br>plt.legend([&#39;Train&#39;,&#39;Validation&#39;], loc=&#39;upper left&#39;)<br>plt.show()</pre><blockquote><em>In my runs, the model quickly reached high accuracy on validation data, showing that transfer learning is effective even with limited samples.</em></blockquote><p>For healthcare tasks, always look beyond accuracy:</p><ul><li><strong>Precision:</strong> How many predicted autistic images were correct?</li><li><strong>Recall:</strong> How many actual autistic images did we detect?</li><li><strong>F1-score:</strong> Balance between precision and recall.</li></ul><p>Read more: <a href="https://towardsdatascience.com/accuracy-precision-recall-or-f1-331fb37c5cb9">Understanding precision/recall</a></p><h3>Key Takeaways</h3><ul><li>Transfer learning with VGG19 allows powerful image classification without massive data.</li><li>Data augmentation is essential to fight overfitting.</li><li>Callbacks like EarlyStopping and ModelCheckpoint ensure better generalization.</li><li>In healthcare, always interpret results with metrics beyond accuracy.</li></ul><h3>What You Can Try Next</h3><ul><li>Fine-tune deeper layers of VGG19 or try EfficientNet.</li><li>Use <a href="https://www.analyticsvidhya.com/blog/2023/12/grad-cam-in-deep-learning/"><strong>Grad-CAM</strong></a> to visualize what parts of the image influence predictions.</li><li>Experiment with optimizers or different augmentation strategies.</li><li>Test on external datasets to check generalization.</li></ul><p>In the next post, we’ll explore advanced prompting strategies and fine-tuning large language models, and how these approaches can be applied across different healthcare use cases. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7fd3a3298c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI in Healthcare, Part 4: Classifying Genetic Disorders using Machine Learning]]></title>
            <link>https://medium.com/@swatimaste8/ai-in-healthcare-part-4-predicting-genetic-disorders-with-machine-learning-a025285915fb?source=rss-fb09af16f89f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a025285915fb</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[heathcare]]></category>
            <category><![CDATA[pca-analysis]]></category>
            <category><![CDATA[eda]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Swatimaste]]></dc:creator>
            <pubDate>Sun, 27 Jul 2025 10:09:56 GMT</pubDate>
            <atom:updated>2025-07-27T10:31:30.561Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oQVNnrcS63LcxlGBNBwlsA.png" /></figure><p>Welcome back to the fourth blog in my <a href="https://medium.com/@swatimaste8/transforming-healthcare-with-artificial-intelligence-2ead0f166aad">AI in Healthcare blog series</a>!</p><p>So far in this series, we’ve been diving deep into the MIMIC‑III dataset to learn different AI techniques in healthcare. For this post, I wanted to show you that these skills are not limited to one dataset—so I picked a different dataset to demonstrate more machine learning methods in action. Here we’ll explore a genomics dataset and see how machine learning can be applied to classify <strong>genetic disorders.</strong></p><p>Link to GitHub<strong>: </strong><a href="https://github.com/SwatiMaste/AI-in-HealthCare/blob/main/AIH_selfLearningTutorial.ipynb"><strong>Code</strong></a></p><p><strong>What are genetic disorders?</strong> They are health conditions caused by changes in DNA, often inherited from parents. Early prediction can help in preventive care and treatment planning.</p><p>Rather than just sharing what I implemented, I aim to walk you through <strong>why</strong> each step matters and <strong>what alternatives you could try!</strong></p><h3>Dataset Overview</h3><p>For this project, I used the <a href="https://www.kaggle.com/datasets/atharvaingle/genome-and-genetic-disorders"><strong>Genomes and Genetic Disorders</strong></a> dataset from Kaggle, originally part of a HackerEarth ML challenge.</p><p><strong>Key characteristics:</strong></p><ul><li>Patient details: family history, prenatal indicators, and birth conditions</li><li>Target variable: Type of genetic disorder</li><li>Challenges: Missing values, many categorical variables, class imbalance</li></ul><h3>Step-by-Step Project Pipeline</h3><p>Here’s the high-level workflow:</p><ol><li><strong>Installation &amp; Setup</strong>—Libraries like pandas, scikit-learn, seaborn, xgboost</li><li><strong>Data Loading &amp; Cleaning</strong>—Convert missing values, drop noisy columns</li><li><strong>Exploratory Data Analysis (EDA)</strong>—Visualize patterns in the data</li><li><strong>Feature Engineering</strong>—Label encoding, discretization</li><li><strong>Dimensionality Reduction (PCA)</strong>—Reduce feature space</li><li><strong>Balancing the Dataset (SMOTE)</strong>—Fix class imbalance</li><li><strong>Train ML Models</strong>—Decision Tree, Random Forest, XGBoost, Naive Bayes, KNN</li><li><strong>Evaluation</strong>—Accuracy, classification report, confusion matrix</li></ol><p>Each step builds upon the previous one—after preparing and exploring the data, we engineer features and then proceed to modeling.</p><h3>Exploratory Data Analysis (EDA) 📊</h3><p><strong>EDA</strong> is a critical step in any ML workflow. It helps uncover hidden patterns, distributions, correlations, and potential outliers. Below are some key insights from the charts we generated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*qCnMx8WyCD6OcELOpLJMjQ.png" /><figcaption>Genetic Disorder classes</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dP-HYMopZ36rgkaB2KJogA.png" /><figcaption>Genetic Disorder Subclasses</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*A_OJNQ5fCq2Gu2A79bDkcQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*MLEwcwFX3QMfAgGZ1qUnNQ.png" /></figure><ul><li>The pie chart shows the overall distribution of genetic disorder classes. It’s clear the dataset is imbalanced, with <strong>Mitochondrial genetic inheritance disorders</strong> making up more than half of the data.</li><li>The bar chart of disorder subclasses reveals which conditions dominate, such as <strong>Leigh syndrome</strong> and <strong>Cystic fibrosis</strong>, which could influence model performance if not balanced properly.</li><li>Grouped bar charts (e.g., inheritance from father or mother) show that <strong>maternal inheritance</strong> appears more frequently associated with certain disorders, which could be an important predictive signal.</li><li>Gender-based charts show that gender does not strongly separate classes, but the dataset interestingly includes an <strong>Ambiguous</strong> category, which could introduce noise or be analyzed further.</li></ul><p>Including these interpretations in your workflow helps you understand what patterns the model might learn and what preprocessing steps (like handling imbalance) are most crucial.</p><p><a href="https://www.geeksforgeeks.org/data-analysis/what-is-exploratory-data-analysis/">Learn more about EDA</a></p><h3>Data Preprocessing &amp; Feature Engineering</h3><p>In real-world healthcare datasets, raw data is rarely directly usable for modeling. Feature engineering transforms this raw data into a form that a machine learning model can understand and learn from. Here’s what we did—and why:</p><h4>🔠 Label Encoding</h4><p>Many features in the dataset (like ‘Disorder Type,’ ‘Family History,’ and ‘Gene Origin’) are <strong>categorical</strong>—they represent discrete values like ‘maternal’ or ‘paternal.’ Models can’t work with text directly, so we convert these categories into numerical values using <strong>label encoding.</strong> For example, “maternal” might become 0 and “paternal” might become 1.</p><p><a href="https://towardsdatascience.com/understanding-feature-engineering-part-2-categorical-data-f54324193e63">What is Label Encoding?</a></p><blockquote><em>When to use it: Label encoding is ideal when the categorical values do not have ordinal relationships (e.g., disorder names). If the categories do have an order (like ‘low’, ‘medium’, ‘high’), you might consider </em><strong><em>Ordinal Encoding</em></strong><em> instead.</em></blockquote><h4>Discretization</h4><p>Some continuous variables are hard to model directly, especially when they have skewed distributions. We <strong>discretize</strong> them—i.e., group the values into bins or categories to reduce noise and improve interpretability.</p><blockquote><em>When to use it: Discretization is helpful when you want to reduce sensitivity to small changes in value (e.g., age groups) or improve model robustness.</em></blockquote><h4>PCA (Principal Component Analysis)</h4><p>With many features—especially derived ones—it’s easy to end up with high-dimensional data that leads to overfitting or long training times. PCA helps us reduce dimensionality by projecting the data into a space that retains most variance while eliminating redundancy.</p><p>Read more: <a href="https://www.geeksforgeeks.org/data-analysis/principal-component-analysis-pca/">PCA</a></p><blockquote><em>When to use it: Use PCA when you have many interrelated numeric variables/many features (large features means model will suffer from </em><a href="https://www.geeksforgeeks.org/machine-learning/curse-of-dimensionality-in-machine-learning/"><em>high dimensionality curse</em></a><em>, hence use feature reduction/selection techniques), and you want to simplify without losing much information.</em></blockquote><p>Once these steps are done, we can move on to handle data imbalance and train models.</p><h3>⚖️ SMOTE—Fixing Class Imbalance</h3><p>Class imbalance occurs when one category of the target variable is heavily underrepresented. To address this, we used <strong>SMOTE (Synthetic Minority Over-sampling Technique)</strong>.</p><p>SMOTE creates synthetic samples of the minority class to balance the dataset. Balancing the dataset is necessary to prevent the model from being biased towards the target classes.</p><p><a href="https://imbalanced-learn.org/stable/references/generated/imblearn.over_sampling.SMOTE.html">Understanding SMOTE</a></p><h3>ML Models I Used — and Why</h3><p>Selecting a model is never a one‑size‑fits‑all decision. It depends on your dataset, how much interpretability you need, and the trade‑offs you’re willing to make between speed, accuracy, and complexity. Below are the models I experimented with, along with why they made sense for this project — and when you might want to use (or skip) them in your own work:</p><ul><li><strong>Decision Tree:</strong> A great starting point because it’s simple and interpretable. You can easily see which features influence predictions. However, it tends to overfit when the data is noisy or high‑dimensional.</li><li><strong>Random Forest:</strong> An ensemble of trees that reduces overfitting by averaging results. It handles categorical features well and is a solid general‑purpose choice.</li><li><strong>XGBoost:</strong> A boosting algorithm that usually delivers high accuracy, especially when you have time to tune hyperparameters. It’s powerful but can be harder to interpret.</li><li><strong>Naive Bayes:</strong> A fast and simple baseline for categorical or text‑like data. It assumes feature independence, so performance may drop if your features are highly correlated.</li><li><strong>K‑Nearest Neighbors (KNN):</strong> Works by comparing new data points to existing ones. It’s effective for small, well‑separated datasets but doesn’t scale well to very large or high‑dimensional data.</li></ul><h3>📈 Model Evaluation</h3><p>Evaluating healthcare models isn’t just about accuracy; you need to look deeper:</p><ul><li><strong>Accuracy Score:</strong> Overall proportion of correct predictions.</li><li><strong>Confusion Matrix:</strong> Shows how predictions break down per class, highlighting which classes get misclassified.</li><li><strong>Precision, Recall, and F1‑Score:</strong> Essential for imbalanced datasets. Precision tells us what proportion of predicted positives were actually correct. Recall tells us how many actual positives we caught. F1‑Score balances the two and gives a better single metric for uneven classes.</li></ul><p><a href="https://www.geeksforgeeks.org/machine-learning/metrics-for-machine-learning-model/">Learn more about evaluation metrics</a></p><h3>Key Takeaways</h3><ul><li><strong>Preprocessing is everything:</strong> Clean your data and handle missing values and categories before modeling.</li><li><strong>Handle class imbalance:</strong> Techniques like SMOTE can dramatically improve model fairness and performance.</li><li><strong>Dimensionality reduction helps:</strong> PCA simplified the feature space while retaining important information.</li><li><strong>Tuning matters:</strong> Hyperparameter tuning (like RandomizedSearchCV) significantly improved models such as Naive Bayes and KNN.</li></ul><h3>What You Can Try Next</h3><ul><li>Use GridSearchCV for exhaustive hyperparameter tuning.</li><li>Try AutoML platforms like <a href="https://www.h2o.ai/">H2O.ai</a> or <a href="https://epistasislab.github.io/tpot/">TPOT</a>.</li><li>Visualize PCA components and model predictions.</li><li>Try neural networks for larger datasets.</li></ul><p>This project isn’t just a modeling exercise — it’s a blueprint for how you can structure real-world ML workflows for most of the classification problems. I hope this walkthrough helped you not only follow the implementation but also understand the thinking behind each choice.</p><p>In the next post, we’ll explore deep learning model for Healthcare datatsets. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a025285915fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI in Healthcare, Part 3: Exploring Clinical Notes with NLP on MIMIC-III]]></title>
            <link>https://medium.com/@swatimaste8/ai-in-healthcare-part-3-exploring-clinical-notes-with-nlp-on-mimic-iii-1ea4746a7d73?source=rss-fb09af16f89f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ea4746a7d73</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[healthcare]]></category>
            <dc:creator><![CDATA[Swatimaste]]></dc:creator>
            <pubDate>Sun, 25 May 2025 14:00:32 GMT</pubDate>
            <atom:updated>2025-05-26T05:10:38.890Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rxd4A4D7z_zX2cXw6o5NCA.png" /></figure><p>Welcome to Part 3 of my <a href="https://medium.com/@swatimaste8/transforming-healthcare-with-artificial-intelligence-2ead0f166aad">AI in Healthcare blog series</a>! In the previous posts, we explored the foundations of AI in healthcare and how to work with the MIMIC-III dataset using EDA and SQL. Now, we’re entering one of the most exciting areas of AI in healthcare — <strong>Natural Language Processing (NLP)</strong>.</p><p>In this blog, we’ll dive into how we can use NLP to extract meaningful information from <strong>clinical notes</strong> in the MIMIC-III dataset. We’ll cover concepts like Named Entity Recognition (NER), word embeddings, and even transformer-based models — all applied to real patient note data. Check the notebook from my <a href="https://github.com/SwatiMaste/AI-in-HealthCare/tree/main">GitHub </a>for code : <a href="https://github.com/SwatiMaste/AI-in-HealthCare/blob/main/MIMICNLP_NOTEEVENTS.ipynb">Appying NLP techniques on MIMIC III</a></p><h3>What is NLP and Why Does it Matter in Healthcare?</h3><p>Natural Language Processing (NLP) is a field of Artificial Intelligence (AI) that focuses on enabling machines to understand, interpret, and generate human language. It combines techniques from linguistics, computer science, and machine learning.</p><p>In healthcare, NLP is essential because a large portion of medical information is stored as unstructured text. Traditional data formats (like structured lab results) only tell part of the story — notes written by doctors, nurses, and other clinicians hold rich context that structured data often lacks.</p><p>Some examples of where NLP is used in healthcare include:</p><ul><li><strong>Entity extraction</strong> (e.g., diseases, medications, symptoms): Automatically finding and labeling important terms in clinical text. <a href="https://towardsdatascience.com/named-entity-recognition-unmasked-the-essential-guide-404ad0568964/">Learn more about Named Entity Recognition</a></li><li><strong>Clinical coding automation</strong>: Helping map diagnoses and procedures to standardized codes like ICD. <a href="https://www.aapc.com/resources/what-is-medical-coding?srsltid=AfmBOopZNopKEX48E6d8qxA6cSdyzhFQhlXIZwgei9UA-fuuomTk9vbm">Intro to Clinical Coding</a></li><li><strong>Summarization of long medical reports</strong>: Generating concise summaries of lengthy clinical documents. <a href="https://nlp.johnsnowlabs.com/medical_text_summarization">Read about text summarization in healthcare</a></li><li><strong>Semantic search</strong> within patient records: Enhancing information retrieval from EHRs by understanding meaning rather than just keywords. <a href="https://dl.acm.org/doi/10.1145/3626772.3661349">Semantic Search for EHRs</a></li></ul><p>If you’re new to NLP and want to explore it more broadly before diving into the healthcare context, check out this beginner-friendly introduction: <a href="https://www.deeplearning.ai/resources/natural-language-processing/">NLP Guide for Beginners</a></p><h3>Clinical Notes in MIMIC-III</h3><p>We use NOTEEVENTS.csv.gz from MIMIC-III, which contains:</p><ul><li>TEXT: the actual clinical note text</li><li>CATEGORY: type of note (e.g., Discharge summary, Radiology)</li><li>HADM_ID: hospital admission ID</li></ul><p>We first load the dataset:</p><pre>notes_df = pd.read_csv(&quot;NOTEEVENTS.csv.gz&quot;, usecols=[&#39;TEXT&#39;, &#39;CATEGORY&#39;, &#39;HADM_ID&#39;])</pre><h3>Named Entity Recognition (NER) with SciSpacy</h3><p>Named Entity Recognition (NER) is an NLP technique used to automatically locate and classify key information (entities) in text into predefined categories like diseases, medications, or chemicals. In healthcare, NER helps unlock valuable structured information from free-text notes that doctors and nurses write.</p><p>To apply this in the biomedical domain, we use <strong>SciSpacy</strong>, an extension of the popular spaCy NLP library developed specifically for scientific and clinical texts. The en_ner_bc5cdr_md model we use is trained on biomedical literature and can recognize entities like diseases and chemical compounds.</p><pre>import spacy<br>import scispacy<br>from scispacy.linking import EntityLinker</pre><pre>nlp = spacy.load(&quot;en_ner_bc5cdr_md&quot;)<br>def extract_entities_scispacy(text):<br>  doc = nlp(text)<br>  return [(ent.text, ent.label_) for ent in doc.ents]</pre><pre>text = &quot;Patient diagnosed with pneumonia and prescribed azithromycin.&quot;<br>print(extract_entities_scispacy(text))</pre><pre>relevant_notes[&#39;Entities_SciSpacy&#39;] = relevant_notes[&#39;TEXT&#39;].dropna().apply(lambda x: extract_entities_scispacy(str(x)))</pre><p>This approach helps us identify phrases like <em>“renal failure”</em> or <em>“aspirin”</em> and label them accordingly. These extracted terms can later be used in patient phenotyping, filtering datasets, or linking to medical ontologies like UMLS.</p><p>Want to understand more about NER? <a href="https://towardsdatascience.com/named-entity-recognition-82fb2da545ca">This visual NER explainer is a great start</a>.</p><h3>Word Embeddings with Word2Vec</h3><p>Word embeddings are a way to represent words as numerical vectors, capturing their meanings and relationships based on the context in which they appear. For example, embeddings learned from clinical notes might place “hypertension” and “blood pressure” close together in vector space because they appear in similar contexts.</p><p>We use <strong>Word2Vec</strong>, a simple but effective algorithm that learns these embeddings from text data. In our case, we tokenize the notes into sentences and train the model:</p><pre>from gensim.models import Word2Vec</pre><pre>sentences = [text.split() for text in notes_df.TEXT.sample(1000).tolist()]<br>w2v_model = Word2Vec(sentences, vector_size=100, window=5, min_count=2, workers=4)</pre><p>This gives us a trained model where each word is associated with a vector. You can compute word similarity, find analogies, or visualize the embeddings with dimensionality reduction techniques like t-SNE.</p><p>Curious about how Word2Vec works? <a href="https://jalammar.github.io/illustrated-word2vec/">Check out this beginner’s guide</a></p><h3>Transformer Models (BioBERT)</h3><p>Transformers are state-of-the-art neural network models designed to process and understand sequential data, especially natural language. The most well-known transformer architecture is <strong>BERT (Bidirectional Encoder Representations from Transformers)</strong>, which learns language representations by predicting missing words in a sentence using both the left and right context.</p><p><a href="https://huggingface.co/dmis-lab/biobert-v1.1"><strong>BioBERT</strong> </a>and <a href="https://huggingface.co/emilyalsentzer/Bio_ClinicalBERT"><strong>Bio_ClinicalBERT </strong></a>are adaptations of BERT that have been further pre-trained on large corpora of biomedical and clinical texts. This makes them better suited for healthcare applications such as medical NER, question answering, and document classification.</p><p>In our notebook, we use the model Bio_ClinicalBERT from Hugging Face’s model hub to generate embeddings for clinical text:</p><pre>from transformers import AutoTokenizer, AutoModel</pre><pre>tokenizer = AutoTokenizer.from_pretrained(&quot;emilyalsentzer/Bio_ClinicalBERT&quot;)<br>model = AutoModel.from_pretrained(&quot;emilyalsentzer/Bio_ClinicalBERT&quot;)</pre><pre>inputs = tokenizer(text_sample, return_tensors=&quot;pt&quot;, truncation=True, padding=True)<br>outputs = model(**inputs)</pre><p>These embeddings can then be used for downstream tasks like classifying clinical notes, identifying patient risk profiles, or clustering similar documents.</p><p>For a gentle intro to BERT and transformers, see: <a href="https://jalammar.github.io/illustrated-transformer/">The Illustrated Transformer</a> and <a href="https://huggingface.co/dmis-lab/biobert-base-cased-v1.1">BioBERT on HuggingFace</a></p><h3>Why We Used These NLP Techniques</h3><p>Each of the NLP techniques we used serves a distinct purpose in helping us understand and process clinical text:</p><ul><li><strong>NER with SciSpacy</strong> helps in extracting structured medical concepts from raw notes. This is useful for building clean features for downstream tasks, mapping notes to medical ontologies, and automating manual data entry.</li><li><strong>Word2Vec</strong> captures the semantic similarity between words. It’s useful when you want to understand word relationships in clinical contexts — helping identify synonyms, group medical terms, or cluster patient cohorts.</li><li><strong>Transformer-based models like BioBERT</strong> provide deep contextual understanding of long clinical notes. These models are especially powerful for classification, summarization, and information extraction where meaning depends on context.</li></ul><h3>Key Takeaways</h3><ul><li><strong>Start simple:</strong> Use NER and keyword-based matching if you’re just exploring the data or need basic entity extraction.</li><li><strong>Use Word2Vec</strong> when your goal is to understand word associations or generate compact embeddings for clustering.</li><li><strong>Use Transformers like BioBERT</strong> when working with complex tasks requiring context-aware representations, such as clinical note classification or predictive modeling.</li></ul><p>Choosing the right NLP technique depends on your problem and data constraints. Always consider:</p><ul><li>The size of your dataset</li><li>The computational resources available</li><li>The level of accuracy and context you need</li></ul><h3>What Can You Try Next?</h3><ul><li>Extract medications and disease terms from discharge summaries</li><li>Use NER to build a medication-frequency dashboard</li><li>Compare note embeddings across departments (e.g., cardiology vs oncology)</li><li>Train a classifier to predict patient outcomes from note text</li></ul><h3>Resources</h3><ul><li><a href="https://allenai.github.io/scispacy/">SciSpacy</a></li><li><a href="https://huggingface.co/emilyalsentzer/Bio_ClinicalBERT">Bio_ClinicalBERT</a></li><li><a href="https://physionet.org/content/mimiciii/1.4/">MIMIC-III Dataset</a></li></ul><p>In the next post, we’ll explore predictive modeling in healthcare on MIMIC data. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ea4746a7d73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Hands-On with Healthcare Data: Exploring MIMIC-III with EDA and SQL]]></title>
            <link>https://medium.com/@swatimaste8/getting-hands-on-with-healthcare-data-exploring-mimic-iii-with-eda-and-sql-3fca995f63f3?source=rss-fb09af16f89f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3fca995f63f3</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[eda]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[healthcare]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Swatimaste]]></dc:creator>
            <pubDate>Mon, 19 May 2025 13:38:14 GMT</pubDate>
            <atom:updated>2025-05-19T14:23:06.512Z</atom:updated>
            <content:encoded><![CDATA[<h3>AI in Healthcare, Part 2: Getting Hands-On with MIMIC-III using EDA &amp; SQL</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M73xojqB6aHmqWHhz_An7g.png" /></figure><p>Welcome back to the second post in my <a href="https://medium.com/@swatimaste8/transforming-healthcare-with-artificial-intelligence-2ead0f166aad#">AI in Healthcare blog series</a>! Now that we’ve laid a strong foundation by understanding what AI in healthcare is and the importance of ethical data access through CITI and MIMIC-III, it’s time to roll up our sleeves and dive into the data.</p><p>In this post, we’ll explore the <a href="https://physionet.org/content/mimiciii/1.4/"><strong>MIMIC-III dataset</strong></a> — one of the most widely used medical datasets for critical care research. You’ll learn how to perform <strong>Exploratory Data Analysis (EDA)</strong> on real-world healthcare data and write your first SQL queries to extract insights. All of this can be done using either the <strong>full </strong><a href="https://physionet.org/content/mimiciii/1.4/"><strong>MIMIC-III dataset</strong></a> (if you’re credentialed) or the <a href="https://physionet.org/content/mimiciii-demo/1.4/"><strong>demo dataset</strong> hosted on PhysioNet</a>.</p><p>I’ve uploaded two notebooks — <a href="https://github.com/SwatiMaste/AI-in-HealthCare/blob/main/MIMIC_III_Visualization.ipynb">EDA + Visualization</a> and <a href="https://github.com/SwatiMaste/AI-in-HealthCare/blob/main/MIMIC_III_SQL.ipynb">SQL with MIMIC</a> — to help you follow along. GitHub repository that contains all the code for the AI in Healthcare blog series can be found <a href="https://github.com/SwatiMaste/AI-in-HealthCare">here</a>.</p><h3>What is MIMIC-III?</h3><p><strong>MIMIC-III (Medical Information Mart for Intensive Care)</strong> is a freely accessible critical care database developed by the MIT Lab for Computational Physiology. It includes comprehensive, de-identified health data associated with over 40,000 patients who stayed in the intensive care units (ICUs) of the Beth Israel Deaconess Medical Center between 2001 and 2012.</p><p>It contains:</p><ul><li><strong>Patient demographics</strong></li><li><strong>Vitals and chart events</strong></li><li><strong>Medications, lab results, procedures</strong></li><li><strong>Diagnosis and admission information</strong></li></ul><p>The dataset is structured into multiple <strong>CSV files</strong> (or SQL tables), such as:</p><ul><li>ADMISSIONS.csv: patient admission records</li><li>PATIENTS.csv: demographic information</li><li>LABEVENTS.csv: lab test results</li><li>CHARTEVENTS.csv: vital signs and measurements</li><li>ICUSTAYS.csv, DIAGNOSES_ICD.csv, PRESCRIPTIONS.csv, and more</li></ul><h3>Why Exploratory Data Analysis (EDA) Matters</h3><p>Exploratory Data Analysis (EDA) is the first crucial step when working with any dataset — especially in the healthcare domain, where data is often large, noisy, and messy. EDA helps us make sense of the dataset before jumping into modeling or decision-making.</p><p>EDA involves summarizing the dataset’s main characteristics, often using visual methods, to:</p><ul><li>Understand the <strong>shape and structure</strong> of the data</li><li>Detect <strong>missing values, anomalies, or outliers</strong></li><li>Identify <strong>relationships and distributions</strong> across variables</li><li>Highlight <strong>trends and patterns</strong> that could influence downstream tasks</li></ul><p>In simpler terms, EDA is like getting to know your data before trusting it. And in the world of machine learning, this familiarity is key — because your model is only as good as the data it learns from.</p><p>After EDA, you typically move on to <strong>data preprocessing</strong>, where you clean, transform, and prepare the data for machine learning. This might include steps like:</p><ul><li>Handling missing or inconsistent values</li><li>Standardizing formats and scales</li><li>Encoding categorical variables</li><li>Normalizing numerical features</li></ul><p>In healthcare, good preprocessing isn’t just a technical step — it’s critical for patient safety, model accuracy, and ethical AI outcomes.</p><h3>Visualization and EDA with MIMIC-III</h3><p>One important thing to know is that the MIMIC-III dataset uses <strong>ICD-9 codes</strong> — a standardized system for coding diseases and diagnoses. Each code corresponds to a specific medical condition. For easier interpretation, these codes can be mapped to human-readable short titles.</p><p>Let’s walk through an example visualization from the dataset that reveals the <strong>Top 10 most common diagnoses</strong> using ICD-9 codes. Using the<a href="https://github.com/SwatiMaste/AI-in-HealthCare/blob/main/MIMIC_III_Visualization.ipynb"> visualization notebook</a>, here’s what you’ll explore:</p><ul><li>Distributions of various diseases diagnosed</li><li>Length of Stay in Hospital</li><li>Top 10 Most Common Brand vs. Generic Drug Usage</li><li>Top 10 Most Prescribed Drugs by ICU Stay Duration</li><li>Admissions and Mortality Trends Over the Years</li><li>Admissions and Mortality Breakdown by Ethnicity and Admission Type</li><li>Distribution of Length of Stay (LOS) by Hospital Expiration Flag</li></ul><p>Each of these visualizations helps you understand the dataset’s composition and identify areas for deeper exploration.</p><pre># Sample: Distribution of Diagnoses<br>import pandas as pd<br>import matplotlib.pyplot as plt</pre><pre>diagnoses_merged = pd.merge(diagnoses, icd_name, on=&#39;icd9_code&#39;)<br>diagnoses_merged[&quot;icd9_code_title&quot;] = diagnoses_merged[&#39;icd9_code&#39;] + &quot;: &quot; + diagnoses_merged[&#39;short_title&#39;]</pre><pre>top_diagnoses = diagnoses_merged[&#39;icd9_code_title&#39;].value_counts().head(10)<br>plt.figure(figsize=(10, 5))<br>top_diagnoses.plot(kind=&#39;bar&#39;)<br>plt.title(&#39;Top 10 Diagnoses&#39;)<br>plt.xlabel(&#39;ICD9 Code&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>plt.xticks(rotation=90)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*EHWi6dRZcvNVWKzbMqLQ4g.png" /></figure><p>The resulting bar chart shows the most frequent diagnoses among patients. For example, conditions like hypertension, atrial fibrillation, and acute kidney failure appear often in the data. This kind of visualization helps us</p><ul><li>Understand which medical conditions are most common among the patients</li><li>Guide downstream analyses such as outcome prediction or treatment optimization</li></ul><h3>Writing SQL Queries on MIMIC-III</h3><p>If you’re working with MIMIC-III in SQL format, one of the easiest ways to get started is with the <a href="https://querybuilder-lcp.mit.edu/">MIT QueryBuilder</a>, an interactive SQL platform designed for MIMIC and related datasets. For more custom queries and data exploration, you can also use <strong>Google BigQuery</strong> in Colab. The code for the same can be found in the <a href="https://github.com/SwatiMaste/AI-in-HealthCare/blob/main/MIMIC_III_SQL.ipynb">SQL notebook</a>. In this you’ll learn to:</p><ul><li>Join multiple tables for richer insights and then build an SQL query for 10 medical scenarios, some listed below.</li><li>Number of Cardiac Vs Trauma Patients Admitted Each Year</li><li>Readmission Rate of Cardiac Patients Within 30 Days</li><li>Mortality Rate of Cardiac Patients in ICU and many more …</li></ul><pre># 1. Number of Cardiac Vs Trauma Patients Admitted Each Year<br>query = &quot;&quot;&quot;<br>    SELECT<br>        EXTRACT(YEAR FROM ADMITTIME) AS admit_year,<br>        COUNT(CASE WHEN LOWER(DIAGNOSIS) LIKE &#39;%cardiac%&#39; THEN 1 END) AS num_cardiac_patients,<br>        COUNT(CASE WHEN LOWER(DIAGNOSIS) LIKE &#39;%trauma%&#39; THEN 1 END) AS num_trauma_patients<br>    FROM `physionet-data.mimiciii_clinical.admissions`<br>    GROUP BY admit_year<br>    ORDER BY admit_year;<br>&quot;&quot;&quot;<br><br><br># Run the query<br>query_job = client.query(query)<br>df = query_job.to_dataframe()<br>df</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*XMYjHPduFH8X2vkkmFkQeA.png" /></figure><p>Note that the admission years in the dataset appear as unrealistic values like 2100, 2101, etc. This is because the dataset has been <strong>de-identified for privacy compliance</strong>, and real dates have been shifted to protect patient identity.</p><h3>Suggested Experiments for You</h3><p>Once you’re familiar with the structure and tools, try out the following:</p><ul><li>Analyze trends in hospital admissions over time</li><li>Identify the most common lab tests for critical care patients</li><li>Explore gender differences in ICU mortality</li><li>Track medication usage across diagnoses</li><li>Predict ICU length of stay using patient vitals</li></ul><h3>What’s Next?</h3><p>In the next post, we’ll introduce <strong>Natural Language Processing (NLP)</strong> techniques to work with clinical notes and discharge summaries. We’ll extract insights from free-text fields and see how NLP can be applied to real-world healthcare.</p><p>Until then, experiment with the visualizations, run SQL queries, and immerse yourself in the MIMIC-III dataset. Healthcare data is complex — but with the right tools, it becomes a goldmine for impactful insights!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3fca995f63f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI in Healthcare Part 1: Transforming Healthcare with Artificial Intelligence]]></title>
            <link>https://medium.com/@swatimaste8/transforming-healthcare-with-artificial-intelligence-2ead0f166aad?source=rss-fb09af16f89f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ead0f166aad</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[generative-ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[ai-in-health-care]]></category>
            <dc:creator><![CDATA[Swatimaste]]></dc:creator>
            <pubDate>Thu, 08 May 2025 15:02:31 GMT</pubDate>
            <atom:updated>2025-07-27T16:33:35.683Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M73xojqB6aHmqWHhz_An7g.png" /></figure><p>Artificial Intelligence (AI) is reshaping the world of healthcare at an astonishing pace. From enhancing diagnostics to revolutionizing patient care, AI has introduced a new era of precision medicine and predictive analytics that is transforming the way healthcare is delivered.</p><p>Imagine a world where life-threatening conditions are detected early, surgeries are performed with robotic precision, and personalized treatment plans are crafted through data-driven insights. This is the promise of AI in healthcare — and it’s only the beginning.</p><p>This blog is part of my AI in Healthcare series. Here’s what’s ahead:</p><ol><li><a href="#"><strong>Part 1: Transforming Healthcare with Artificial Intelligence</strong></a> <em>(you’re reading this now)</em></li><li><a href="https://medium.com/@swatimaste8/getting-hands-on-with-healthcare-data-exploring-mimic-iii-with-eda-and-sql-3fca995f63f3"><strong>Part 2: Getting Hands-On with MIMIC-III using EDA &amp; SQL</strong></a></li><li><a href="https://medium.com/@swatimaste8/ai-in-healthcare-part-3-exploring-clinical-notes-with-nlp-on-mimic-iii-1ea4746a7d73"><strong>Part 3: Exploring Clinical Notes with NLP on MIMIC-III</strong></a></li><li><a href="https://medium.com/@swatimaste8/ai-in-healthcare-part-4-predicting-genetic-disorders-with-machine-learning-a025285915fb"><strong>Part 4: Classifying Genetic Disorders using Machine Learning</strong></a></li><li><a href="https://medium.com/@swatimaste8/ai-in-healthcare-part-5-autism-detection-using-deep-learning-f7fd3a3298c9"><strong>Part 5: Autism Detection using Deep Learning</strong></a></li><li><a href="https://medium.com/@swatimaste8/ai-in-healthcare-part-6-prompting-techniques-and-fine-tuning-llms-for-healthcare-qa-60f5bd3bdadf"><strong>Part 6: Prompting Techniques and Fine‑Tuning LLMs for Healthcare QA</strong></a></li></ol><h3>Why is AI in Healthcare Different?</h3><p>Healthcare data is incredibly diverse and complex. It consists of:</p><ul><li><strong>Structured Data:</strong> Medical records, lab results, patient demographics.</li><li><strong>Unstructured Data:</strong> Clinical notes, radiology images, and genomic sequences.</li></ul><p>However, healthcare data is also highly <strong>sensitive and regulated</strong>. Datasets like <strong>MIMIC-III</strong> must undergo strict de-identification processes before they can be accessed for research. This is crucial to protect patient privacy and comply with laws like <strong>HIPAA</strong> (Health Insurance Portability and Accountability Act).</p><p><strong>De-Identification &amp; Privacy Challenges:</strong></p><p>Even after de-identification, there are still significant restrictions on how data can be used. For example, <strong>MIMIC-III is not licensed for use in Large Language Model (LLM) training</strong>, which highlights the strict ethical guidelines surrounding medical data usage. This is not just limited to MIMIC; <a href="https://digital.nhs.uk/services/data-access-request-service-dars">NHS Digital in the UK</a> enforces similar controls to maintain patient confidentiality and data ethics.</p><p><strong>Case Study:</strong> In 2019, Google partnered with Ascension to collect patient data under “<a href="https://www.techtarget.com/searchhealthit/definition/Project-Nightingale"><strong>Project Nightingale</strong></a>,” which raised major concerns around patient consent and data privacy. The incident sparked debates on ethical data use in healthcare, illustrating why transparent and regulated handling of medical data is crucial.</p><p>Ethical research training becomes non-negotiable in this context, emphasizing the importance of compliance, privacy, and patient rights.</p><h3>Recent Innovations Shaping the Future</h3><p>AI is constantly pushing the boundaries of what is possible in medicine. Here are some of the most groundbreaking innovations:</p><ol><li><strong>PMC-LLaMA for Medical Research</strong> — <a href="https://arxiv.org/abs/2304.08962">Read about the latest advancements</a> where LLaMA-based models are being fine-tuned specifically for medical literature understanding and clinical decision support.</li><li><strong>Digital Pathology and AI-Powered Imaging</strong> — AI models are now achieving <a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC9674813/">dermatologist</a>-level accuracy in detecting skin cancer and radiologist-level precision in diagnosing lung diseases.</li><li><strong>AI-Assisted Robotic Surgery</strong> — Systems like the da Vinci Surgical System are empowering surgeons with enhanced precision and minimally invasive procedures. <a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC10907451/">Read more here</a></li><li><strong>Wearable Health Devices</strong> — Advanced AI algorithms in wearables like <a href="https://www.cnet.com/tech/mobile/apple-watch-discover-ai-already-on-the-wearable/">Apple Watch</a> and Fitbit now track cardiac health, detect irregular heartbeats, and predict potential health risks.</li><li><strong>Drug Discovery Acceleration</strong> — AI is cutting drug discovery timelines by predicting molecular interactions and potential side effects, as demonstrated by companies like <a href="https://insilico.com/">Insilico Medicine.</a></li></ol><p>For those interested in exploring medical datasets that power these innovations, here are some popular ones:</p><ul><li><a href="https://physionet.org/content/mimiciii/1.4/">MIMIC-III (Critical Care Database)</a></li><li><a href="https://eicu-crd.mit.edu/">eICU Collaborative Research Database</a></li><li><a href="https://www.ukbiobank.ac.uk/">UK Biobank</a></li><li><a href="https://digital.nhs.uk/">NHS Digital</a></li><li><a href="https://www.cancerimagingarchive.net/">Cancer Imaging Archive</a></li></ul><p>These datasets are instrumental in training models that can predict, diagnose, and support medical decision-making.</p><h3>Building the Ethical Foundation: CITI Training and MIMIC Access</h3><p>To ethically work with sensitive medical datasets, it is crucial to understand global standards in research ethics. To prepare for this, I undertook the <strong>Collaborative Institutional Training Initiative (CITI) Program</strong>. This certification is a gold standard for ethical research and ensures compliance with HIPAA regulations and privacy guidelines. Here is a snapshot of my CITI certification:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d48OQuVZUbswVnvyKjk2zg.png" /><figcaption>CITI training completion certificate</figcaption></figure><p>For more details, you can visit the <a href="https://about.citiprogram.org/en/homepage/">CITI Program</a>.</p><h3>Accessing MIMIC-III</h3><p>The <strong>MIMIC-III</strong> dataset, hosted on <a href="https://physionet.org/">PhysioNet</a>, is a goldmine for healthcare analytics. It contains de-identified health information from over forty thousand critical care patients. If you want to explore it hands-on, you can access:</p><ul><li><strong>Full Access:</strong> Requires CITI certification and PhysioNet credentials.</li><li><strong>Demo Dataset:</strong> <a href="https://physionet.org/content/mimiciii-demo/1.4/">Click here to explore MIMIC Demo</a> — No credentials required.</li></ul><h3>Closing Thoughts</h3><p>This blog series is my way of sharing everything I have learned and experimented with during my AI in Healthcare course at <a href="https://cdso.utexas.edu/msai">UT Austin</a>, guided by <a href="https://ischool.utexas.edu/profiles/ying-ding">Dr. Ying Ding</a>. Through this journey, I hope to simplify complex concepts, share practical hands-on notebooks, and inspire others to explore the endless possibilities AI brings to healthcare.</p><p>Stay tuned as we dive deeper into real-world applications with the MIMIC-III dataset in the next post. Our first deep dive will include interactive visualizations and SQL-based analysis to understand patient data better.</p><p><a href="https://medium.com/@swatimaste8/getting-hands-on-with-healthcare-data-exploring-mimic-iii-with-eda-and-sql-3fca995f63f3">AI in Healthcare, Part 2: Getting Hands-On with MIMIC-III using EDA &amp; SQL</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ead0f166aad" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>