Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,28 +5,21 @@ import matplotlib.pyplot as plt
|
|
| 5 |
from sklearn.model_selection import train_test_split
|
| 6 |
from sklearn.neighbors import KNeighborsClassifier
|
| 7 |
import gradio as gr
|
| 8 |
-
|
| 9 |
# Load data
|
| 10 |
-
nexus_bank = pd.read_csv('C:/Users/IT zone computer/nexus_bank_dataa.csv')
|
| 11 |
-
|
| 12 |
-
|
| 13 |
# Preprocessing
|
| 14 |
X = nexus_bank[['salary', 'dependents']]
|
| 15 |
y = nexus_bank['defaulter']
|
| 16 |
-
|
| 17 |
# Train-test split
|
| 18 |
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.15, random_state=90)
|
| 19 |
-
|
| 20 |
# Model training
|
| 21 |
knn_classifier = KNeighborsClassifier()
|
| 22 |
knn_classifier.fit(X_train, y_train)
|
| 23 |
-
|
| 24 |
# Prediction function
|
| 25 |
def predict_defaulter(salary, dependents):
|
| 26 |
input_data = [[salary, dependents]]
|
| 27 |
knn_predict = knn_classifier.predict(input_data)
|
| 28 |
return "Yes! It's a Defaulter" if knn_predict[0] == 1 else "No! It's not a Defaulter"
|
| 29 |
-
|
| 30 |
# Interface
|
| 31 |
interface = gr.Interface(
|
| 32 |
fn=predict_defaulter,
|
|
@@ -34,6 +27,5 @@ interface = gr.Interface(
|
|
| 34 |
outputs="text",
|
| 35 |
title="Defaulter Prediction"
|
| 36 |
)
|
| 37 |
-
|
| 38 |
# Launch the interface
|
| 39 |
interface.launch()
|
|
|
|
| 5 |
from sklearn.model_selection import train_test_split
|
| 6 |
from sklearn.neighbors import KNeighborsClassifier
|
| 7 |
import gradio as gr
|
|
|
|
| 8 |
# Load data
|
| 9 |
+
nexus_bank = pd.read_csv('C:/Users/IT zone computer/Desktop/knn dataset/nexus_bank_dataa.csv')
|
|
|
|
|
|
|
| 10 |
# Preprocessing
|
| 11 |
X = nexus_bank[['salary', 'dependents']]
|
| 12 |
y = nexus_bank['defaulter']
|
|
|
|
| 13 |
# Train-test split
|
| 14 |
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.15, random_state=90)
|
|
|
|
| 15 |
# Model training
|
| 16 |
knn_classifier = KNeighborsClassifier()
|
| 17 |
knn_classifier.fit(X_train, y_train)
|
|
|
|
| 18 |
# Prediction function
|
| 19 |
def predict_defaulter(salary, dependents):
|
| 20 |
input_data = [[salary, dependents]]
|
| 21 |
knn_predict = knn_classifier.predict(input_data)
|
| 22 |
return "Yes! It's a Defaulter" if knn_predict[0] == 1 else "No! It's not a Defaulter"
|
|
|
|
| 23 |
# Interface
|
| 24 |
interface = gr.Interface(
|
| 25 |
fn=predict_defaulter,
|
|
|
|
| 27 |
outputs="text",
|
| 28 |
title="Defaulter Prediction"
|
| 29 |
)
|
|
|
|
| 30 |
# Launch the interface
|
| 31 |
interface.launch()
|