‘Stroke Predictor’ is a machine learning application that was built in Python and implemented to GUI using Python Tkinter. This model is intended to predict whether a person would have a stroke or not. This model performs data preprocessing the data, normalize the data using Standard Scaler, train the model using Logistic Regression algorithm, and implement it to GUI using Python Tkinter. This project was created by me and my team for our Machine Learning Final Project. The source code can be accessed on my GitHub.
GitHub - nadyatyandra/StrokePredictor
The ‘healthcare-dataset-stroke-data.csv’ dataset consists of data about the stroke patients’ condition. The dataset could be accessed from here.
The ‘brain.png’ and ‘correlation.png’ assets are used as the icon in the GUI window. They are converted from .png to .ico using this. The ‘brain.png’ could be accessed from here and the ‘correlation.png’ could be accessed from here.
Importing libraries that needed such as pandas, numpy, seaborn, matplotlib, sklearn, and tkinter.
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib
from matplotlib import pyplot as plt
matplotlib.use('TkAgg')
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import precision_score, recall_score, accuracy_score, f1_score, confusion_matrix
from tkinter import *
import tkinter as tk
import tkinter.font as TkFont
The runProgram() function wrap all functions. This function is intended to make us easier when we want to run the whole program as we only need to call this function.
def runProgram():
data = load_data()
x, y = preprocessing(data)
x, y = normalize(x, y)
trainModel(x, y)
buildGUI()
Load the data and store it into ‘data’ variable.