This project implements a Support Vector Machine (SVM) classifier to predict whether a person is diabetic based on medical data. The model is trained using scikit-learn, with StandardScaler for feature scaling to improve accuracy.
- Uses Support Vector Machine (SVM) for classification
- Standardizes input features with StandardScaler
- Takes user input for real-time diabetes prediction
- Outputs whether the person is diabetic or not diabetic
git clone https://github.com/Strange0000/diabetes-prediction-svm.git
cd diabetes-prediction-svmpip install -r requirements.txtThis model is trained using the Pima Indians Diabetes Dataset, which consists of the following features:
PregnanciesGlucoseBloodPressureSkinThicknessInsulinBMIDiabetesPedigreeFunctionAge
python predict.pyinput_data = (5,166,72,19,175,25.8,0.587,51)
# Output: The person is diabetic- Load the dataset and preprocess it.
- Train an SVM Classifier with a linear kernel.
- Standardize input features using StandardScaler.
- Predict diabetes based on new user input.
import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler
from sklearn import svm
# Load dataset (ensure you have trained the model)
df = pd.read_csv('diabetes.csv')
scaler = StandardScaler()
X = scaler.fit_transform(df.drop('Outcome', axis=1))
# Train SVM Model
clf = svm.SVC(kernel='linear')
clf.fit(X, df['Outcome'])
# Sample Prediction
input_data = np.array([[5,166,72,19,175,25.8,0.587,51]])
scaled_data = scaler.transform(input_data)
result = clf.predict(scaled_data)
print('Diabetic' if result[0] == 1 else 'Not Diabetic')- Python π
- Scikit-Learn π€
- NumPy π’
- Pandas π
- Matplotlib π
Feel free to fork this project and submit pull requests!
This project is licensed under the MIT License.
If you like this project, give it a β on GitHub!