# -*- coding: utf-8 -*-
"""
Created on Sat Mar  9 23:58:10 2024
@author: 20279
"""

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

# Read dataset
df = pd.read_excel("D:/ProjectData/fdy_dataset-0-predict4.xlsx")

# Split into features and labels
X = df.iloc[:, :-1]   # features
y = df.iloc[:, -1]    # labels

# Split into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)

# Initialize logistic regression model
lr = LogisticRegression()

# Fit the model
lr.fit(X_train, y_train)

# Predict on the test set
y_pred = lr.predict(X_test)

# Calculate performance metrics
accuracy = accuracy_score(y_test, y_pred)
print("Accuracy:", accuracy)

# Print classification report
print("Classification Report:\n", classification_report(y_test, y_pred))
