{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "cdf017bb", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "from sklearn.linear_model import LogisticRegression\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.preprocessing import StandardScaler" ] }, { "cell_type": "code", "execution_count": null, "id": "1411b520", "metadata": {}, "outputs": [], "source": [ "# Load patient data\n", "df = pd.read_csv('patient_data.csv')\n", "X = df.drop('diagnosis', axis=1)\n", "y = df['diagnosis']" ] }, { "cell_type": "code", "execution_count": null, "id": "abe11b89", "metadata": {}, "outputs": [], "source": [ "# Preprocess — BUG: scaler fit on ALL data before split\n", "scaler = StandardScaler()\n", "X_scaled = scaler.fit_transform(X)\n", "X_train, X_test, y_train, y_test = train_test_split(\n", " X_scaled, y, test_size=0.2\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "748b6189", "metadata": {}, "outputs": [], "source": [ "# Train model — BUG: no random seed\n", "model = LogisticRegression()\n", "model.fit(X_train, y_train)" ] }, { "cell_type": "code", "execution_count": null, "id": "c2ec2976", "metadata": {}, "outputs": [], "source": [ "# Evaluate — no subgroup reporting\n", "accuracy = model.score(X_test, y_test)\n", "print(f'Accuracy: {accuracy}')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.12.0" } }, "nbformat": 4, "nbformat_minor": 5 }