0% found this document useful (0 votes)
8 views2 pages

AI Phase3

The document outlines a Python script for training a Logistic Regression model on a diabetes dataset. It includes steps for data loading, preprocessing, splitting into training and testing sets, model training, and evaluation, achieving an accuracy of approximately 74.68%. A warning indicates that the model did not converge, suggesting adjustments to the number of iterations or data scaling.

Uploaded by

jeinjas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

AI Phase3

The document outlines a Python script for training a Logistic Regression model on a diabetes dataset. It includes steps for data loading, preprocessing, splitting into training and testing sets, model training, and evaluation, achieving an accuracy of approximately 74.68%. A warning indicates that the model did not converge, suggesting adjustments to the number of iterations or data scaling.

Uploaded by

jeinjas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

cccc

October 31, 2023

[5]: # Import necessary libraries


import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score

# Load the dataset


data = pd.read_csv('/content/diabetes.csv') # Replace 'diabetes_dataset.csv'␣
↪with your dataset

# Data preprocessing
# (handle missing values, scale/normalize features, etc.)

# Split data into features and target variable


X = data.drop('Outcome', axis=1)
y = data['Outcome']

# Split the data 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)

# Choose a model and train it


model = LogisticRegression()
model.fit(X_train, y_train)

# Make predictions
predictions = model.predict(X_test)

# Evaluate the model


accuracy = accuracy_score(y_test, predictions)
print(f"Accuracy: {accuracy}")

Accuracy: 0.7467532467532467
/usr/local/lib/python3.10/dist-packages/sklearn/linear_model/_logistic.py:458:
ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

1
Increase the number of iterations (max_iter) or scale the data as shown in:
https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
https://scikit-learn.org/stable/modules/linear_model.html#logistic-
regression
n_iter_i = _check_optimize_result(

You might also like