Logistic Regression Diabetes Prediction Model
Instructions for Users
DiabeticLogistic Model
This model predicts the likelihood of diabetes based on medical data using logistic regression.
Dataset
The model is trained on a dataset with features including:
- Glucose
- BloodPressure
- SkinThickness
- Insulin
- BMI
- DiabetesPedigreeFunction
- Age
Preprocessing
Features are normalized using StandardScaler
.
Usage
Downloading the Model
!pip install pandas scikit-learn joblib huggingface_hub
from huggingface_hub import hf_hub_download
import joblib
import pandas as pd
# Your Hugging Face token
token = "put your token here"
# Download the model and scaler from the Hugging Face Hub using the token
model_path = hf_hub_download(repo_id="rama0519/DiabeticLogistic123", filename="logistic_regression_model.joblib", use_auth_token=token)
scaler_path = hf_hub_download(repo_id="rama0519/DiabeticLogistic123", filename="scaler.joblib", use_auth_token=token)
# Load the model and scaler
model = joblib.load(model_path)
scaler = joblib.load(scaler_path)
# Example data
data = pd.DataFrame({
'Pregnancies': [6, 1],
'Glucose': [148, 85],
'BloodPressure': [72, 66],
'SkinThickness': [35, 29],
'Insulin': [0, 0],
'BMI': [33.6, 26.6],
'DiabetesPedigreeFunction': [0.627, 0.351],
'Age': [50, 31]
})
# Normalize the data
data_scaled = scaler.transform(data)
# Make predictions
predictions = model.predict(data_scaled)
print("Predictions:", predictions)
Fine-Tuning the Model
To fine-tune the model, follow these steps:
Load the Model and Data
from huggingface_hub import hf_hub_download
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
import joblib
# Your Hugging Face token
token = "put your token here"
# Download the model and scaler from the Hugging Face Hub using the token
model_path = hf_hub_download(repo_id="rama0519/DiabeticLogistic123", filename="logistic_regression_model.joblib", use_auth_token=token)
scaler_path = hf_hub_download(repo_id="rama0519/DiabeticLogistic123", filename="scaler.joblib", use_auth_token=token)
# Load the model and scaler
model = joblib.load(model_path)
scaler = joblib.load(scaler_path)
# Load your dataset
data = pd.read_csv('/content/Healthcare-Diabetes.csv')
# Drop the 'Id' column if it exists
if 'Id' in data.columns:
data = data.drop(columns=['Id'])
X = data.drop(columns=['Outcome'])
y = data['Outcome']
# Normalize the features
X_scaled = scaler.transform(X)
# Split the dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X_scaled, y, test_size=0.2, random_state=42)
Fine-Tune the Model
# Fine-tune the model
model.fit(X_train, y_train)
# Evaluate the fine-tuned model
y_pred = model.predict(X_test)
accuracy = accuracy_score(y_test, y_pred)
print(f'Fine-tuned Accuracy: {accuracy:.2f}')
Save the Fine-Tuned Model
joblib.dump(model, 'fine_tuned_logistic_regression_model.joblib')
- Downloads last month
- 0
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social
visibility and check back later, or deploy to Inference Endpoints (dedicated)
instead.