# Importing required libraries from sklearn.datasets import load_breast_cancer # Built-in dataset (Breast Cancer) from sklearn.linear_model import LogisticRegression # Logistic Regression model from sklearn.model_selection import train_test_split # To split data into training & testing from sklearn.metrics import accuracy_score # To measure model performance # Step 1: Load the dataset (features = X, target labels = y) X, y = load_breast_cancer(return_X_y=True) # Step 2: Split dataset into training (80%) and testing (20%) sets X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=23) # Step 3: Create a Logistic Regression model # max_iter=10000 ensures the model has enough iterations to converge clf = LogisticRegression(max_iter=10000, random_state=0) # Step 4: Train the model using the training data clf.fit(X_train, y_train) # Step 5: Predict on the test data and calculate accuracy acc = accuracy_score(y_test, clf.predict(X_test)) * 100 # Step 6: Print the model accuracy in percentage print(f"Logistic Regression model accuracy: {acc:.2f}%") __ __