0% found this document useful (0 votes)
19 views1 page

Untitled5.Ipynb - Colab

The document outlines a Python script that implements a Decision Tree Classifier to predict diabetes outcomes using a dataset. It preprocesses the data, splits it into training and testing sets, trains the model, and evaluates its accuracy, reporting an accuracy of 0.72 for a 50% training size. The script also includes data loading and cleaning steps using pandas and numpy.

Uploaded by

Haronamery
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)
19 views1 page

Untitled5.Ipynb - Colab

The document outlines a Python script that implements a Decision Tree Classifier to predict diabetes outcomes using a dataset. It preprocesses the data, splits it into training and testing sets, trains the model, and evaluates its accuracy, reporting an accuracy of 0.72 for a 50% training size. The script also includes data loading and cleaning steps using pandas and numpy.

Uploaded by

Haronamery
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/ 1

 Untitled5.

ipynb

  
RAM
  Disk
accuracy = accuracy_score(y_test, y_pred)
0s print(f'Accuracy: {accuracy:.2f}')

Training Size: 60%


Accuracy: 0.69
   !  
0s
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import classification_report, confusion_matrix

# Load the Dataset


url = "https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.da
columns = ['Pregnancies', 'Glucose', 'BloodPressure', 'SkinThickness', 'Insulin',
'BMI', 'DiabetesPedigreeFunction', 'Age', 'Outcome']
diabetes_data = pd.read_csv(url, header=None, names=columns)

# Data Preprocessing
diabetes_data[['Glucose', 'BloodPressure', 'SkinThickness', 'Insulin', 'BMI']] = diabetes_d
diabetes_data.dropna(inplace=True)

# Split the Dataset (50% training)


X = diabetes_data.drop('Outcome', axis=1)
y = diabetes_data['Outcome']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.50, random_state=42)

# Train the Model


model = DecisionTreeClassifier(random_state=42)
model.fit(X_train, y_train)

# Make Predictions
y_pred = model.predict(X_test)

# Evaluate the Model


print('Training Size: 50%')

from sklearn.metrics import accuracy_score

# Calculate accuracy
accuracy = accuracy_score(y_test, y_pred)
print(f'Accuracy: {accuracy:.2f}')

Training Size: 50%


Accuracy: 0.72

 Generate 10 random numbers using numpy  Close

[
Waiting...
]

You might also like