liveBook · Manning

Chapter 4: LLM-driven data science

What you will learn in chapter 4 of Vibe Engineering

The introduction explains how LLMs can turn business questions into data-analysis notebooks while emphasizing that plausible-looking results still require human verification.

After this chapter you will be able to

Section by section

Introduction

The introduction explains how LLMs can turn business questions into data-analysis notebooks while emphasizing that plausible-looking results still require human verification.

Key terms: dataset, data cleaning, parsing, normalization, analytics notebook, business domain, trust but verify, business context, pharmaceutical data, strictly educational

4.1 Choosing the proper dataset

The section uses LLM-assisted discovery and comparison to choose a pharmaceutical dataset large and realistic enough for meaningful analysis and machine learning.

Key terms: availability, cardinality, records, translation, Indian Medicine Dataset, Kaggle Medicine Dataset, real-world data, synthetic datasets, outliers, malformed records

4.2 Set up the environment

Explains how to prepare an isolated Conda environment, launch Jupyter Notebook, and run Python code in notebook cells.

Key terms: Conda, isolated "sandbox", Miniconda, conda activate drug_analysis, jupyter notebook, manning_vibe_engineering, cells, Shift + Enter, Run

4.3 Exploratory data analysis

The section shows how to begin exploring an unfamiliar medicine dataset by asking an LLM to suggest analyses and create a Jupyter notebook.

Key terms: exploratory, LLM, Jupyter notebook, file_path, Manufacturer analysis

4.3.1 Data analysis when we know the questions

The section shows how to turn known questions about a drug dataset into a prompt for a runnable analysis notebook, then contrasts that focused approach with open-ended AI analysis.

Key terms: LLM prompt, Jupyter Notebook, data/updated_indian_medicine_data.csv, delegating all analysis, questions, expectations and boundaries, manufacturer's analysis, price per drug type, summary DataFrame

4.4 Applying feature engineering

The section uses LLM-assisted feature engineering to turn drug composition text into structured fields, then checks and improves the extracted data.

Key terms: short_composition, salt_composition, Active Pharmaceutical Ingredient (API), Is_Multi_Salt, Salt_Name, Dosage_Value, Dosage_Unit, features_engineered_medicine_data.csv, Products with Dosage Value, nan

4.5 Predicting the price of drugs with machine learning techniques

This section motivates drug-price prediction and identifies the data columns the proposed model will use.

Key terms: Dosage_Value, Is_Multi_Salt, Salt_Name, manufacturer_name, Dosage_Unit, margin, pricing

4.5.1 Supervised learning for predicting a label

This section defines the feature data and price label used to train a drug-price prediction model.

Key terms: label, features, X, y, price

4.5.2 The train/test data split

This section explains how to shuffle and split the drug-price dataset so a model can train on one portion and have its predictions checked against held-out prices.

Key terms: features, label, predicted price, accuracy, training set, test set, X, y, labels, shuffle

4.5.3 The full predict-the-price ML pipeline

This section brings together the supervised learning steps for training and evaluating a drug-price prediction model.

Key terms: X training dataset, y training dataset, X test set, y-test dataset, predict method, accuracy

4.5.4 Vibe engineer the price prediction

The section walks through an LLM-assisted drug price prediction pipeline, from preparing engineered features and encoding categories to training and evaluating a regression model.

Key terms: ML engineer, Role & Context, features_engineered_medicine_data.csv, Dosage_Value, Salt_Name, 99th percentile, outliers, X, y, categorical features

4.5.5 Accessing the results

This section interprets a drug-price model’s prediction chart, accuracy metrics, and feature-importance output to show what the model captures and where it falls short.

Key terms: Predicted vs. Actual Drug Price, R-squared (R²), Actual Price, predicted Price, Mean Absolute Error (MAE), Root Mean Square Error (RMSE), INR, Random Forest, feature importance, Meropenem salt name

4.5.6 Improving the model

This section uses baseline evaluation results to prompt an LLM for a revised price-prediction model, then weighs the mixed metric changes against the model’s practical limits.

Key terms: model evaluation, dosage, ablation study, drop-in replacement, Dosage_Bin, R², MAE, RMSE, rough price estimation, production environment

4.6 Building a digital guardian angel

Introduces a text-based risk classifier for medication requests and shows how its two classifications determine whether a human pharmacist is involved.

Key terms: classification system, LOW RISK, HIGH RISK, human pharmacist

4.6.1 Correlating long text with predicted class

This section sets up a drug-risk classification task using long medicine descriptions as input and risk labels derived from reported side effects.

Key terms: medicine description, side_effects column, high risk, low risk, train set, test set, accuracy

4.6.2 Tokenization of medicine description

This section shows how to turn medicine descriptions into binary word-presence vectors and explains why practical tokenizers and vocabulary size matter.

Key terms: medicine_description, dictionary, vector, tokenization, word normalization, tokenizer, input layer, neurons

4.6.3 Deep learning based classification with vibe engineering

This section uses an AI-generated notebook to build a deep-learning drug-risk classifier, then checks its usable data, training output, and classification results.

Key terms: Target Engineering, NLP Feature Engineering, High Risk, medicine_desc, side_effects, drug_interactions, class distribution, non-null fields, df.count(), epochs

4.6.4 How to use the model?

The section shows how to call the drug-risk model and why its predictions should be checked with queries resembling real user input.

Key terms: predict_high_risk(), medicine_description, side_effects, threshold, LOW RISK, HIGH RISK, test set description, user query, predicted probability, anxiety

4.6.5 Picking the proper threshold

The section shows how to choose a high-risk classification threshold by examining precision and recall, checking the choice with cross-validation and F1 score, and questioning unusually strong results.

Key terms: threshold, High Risk, Low Risk, false positives, false negatives, Precision/Recall vs. Threshold plot, precision, recall, F1-Score, K-Fold Cross-Validation

4.6.6 Understanding the architecture

Explains how the drug-risk classifier turns medical descriptions into a probability and compensates for rare high-risk cases during training.

Key terms: Text Tokenization and Padding, tokenizer, vocabulary, padding, Embedding Layer, 64-dimensional vector space, SpatialDropout1D, overfitting, Sequential, GRU (Gated Recurrent Unit)

4.7 Summary

Concepts explained in this chapter

← Chapter 3: Context fabric: optimizing context for AI agents Chapter 5: From autocomplete to agent fleets: the road to Continuous AI →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.