Skip to content

Commit 4d79ffe

Browse files
authored
Add files via upload
1 parent 9a656b0 commit 4d79ffe

11 files changed

+21445
-140
lines changed

App_SVM.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import streamlit as st
2+
import pandas as pd
3+
import numpy as np
4+
import joblib
5+
6+
# Load the trained SVM model
7+
svc_model = joblib.load('mymodel.joblib')
8+
9+
# Set up Streamlit app
10+
st.title('Loan Eligibility Prediction')
11+
12+
# Create input form for user
13+
st.write('Enter Applicant Details:')
14+
gender = st.selectbox('Gender', ['Male', 'Female'])
15+
married = st.selectbox('Marital Status', ['Yes', 'No'])
16+
dependents = st.text_input('Number of Dependents', '0')
17+
education = st.selectbox('Education', ['Graduate', 'Not Graduate'])
18+
self_employed = st.selectbox('Self Employed', ['Yes', 'No'])
19+
applicant_income = st.text_input('Applicant Income', '')
20+
coapplicant_income = st.text_input('Coapplicant Income', '')
21+
loan_amount = st.text_input('Loan Amount', '')
22+
loan_amount_term = st.text_input('Loan Amount Term', '')
23+
credit_history = st.selectbox('Credit History', ['1', '0'])
24+
property_area = st.selectbox('Property Area', ['Urban', 'Rural', 'Semiurban'])
25+
26+
# Map categorical variables to numerical values
27+
gender_map = {'Male': 1, 'Female': 0}
28+
married_map = {'Yes': 1, 'No': 0}
29+
education_map = {'Graduate': 1, 'Not Graduate': 0}
30+
self_employed_map = {'Yes': 1, 'No': 0}
31+
property_area_map = {'Urban': 1, 'Rural': 2, 'Semiurban': 0}
32+
33+
# Convert categorical variables to numerical values
34+
gender_val = gender_map[gender]
35+
married_val = married_map[married]
36+
education_val = education_map[education]
37+
self_employed_val = self_employed_map[self_employed]
38+
property_area_val = property_area_map[property_area]
39+
40+
# When user clicks the 'Predict' button
41+
if st.button('Predict'):
42+
# Create input data array with numerical values
43+
input_data = np.array([[gender_val, married_val,
44+
int(dependents),
45+
education_val,
46+
self_employed_val,
47+
float(applicant_income),
48+
float(coapplicant_income),
49+
float(loan_amount),
50+
float(loan_amount_term),
51+
float(credit_history),
52+
property_area_val]])
53+
54+
55+
st.write("Input Data Shape:", input_data.shape)
56+
st.write("Input Data:", input_data)
57+
58+
# Predict loan eligibility
59+
eligibility = svc_model.predict(input_data)
60+
61+
# Display prediction result
62+
st.subheader(f'Eligibility: {eligibility[0]}')
63+
64+

0 commit comments

Comments
 (0)