This document outlines a Python code implementation for logistic regression using the breast cancer dataset in a Colab environment. It includes steps for data loading, preprocessing, model training, and evaluation of accuracy. Additionally, it provides a placeholder for predicting outcomes for new patients based on the trained model.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
5 views2 pages
LR Model
This document outlines a Python code implementation for logistic regression using the breast cancer dataset in a Colab environment. It includes steps for data loading, preprocessing, model training, and evaluation of accuracy. Additionally, it provides a placeholder for predicting outcomes for new patients based on the trained model.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
AI/ML WORKSHOP (01/02/2025)
PYTHON CODE IN COLAB FOR LOGISTIC REGRESSION
# Import necessary libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns from sklearn.datasets import load_breast_cancer from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.linear_model import LogisticRegression from sklearn.metrics import accuracy_score # Load the breast cancer dataset cancer = load_breast_cancer() X, y = cancer.data, cancer.target
print("First 5 rows of the dataset:") print(df.head())
# Split dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Apply Logistic Regression model
model = LogisticRegression(max_iter=100) #LR alg model.fit(X_train, y_train)
# Make predictions y_pred = model.predict(X_test) # tesing
# Evaluate the model
accuracy = accuracy_score(y_test, y_pred) #tesing-y value print("Model Accuracy:", accuracy) _____________ end of model building--------------------- //if u want to test for new breast cancer patients new_pred = model.predict(GIVE 30 values AS PER FORMAT) # tesing