Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancing Loan Eligibility Estimator Model #5

Open
donna2864 opened this issue Oct 1, 2024 · 8 comments · May be fixed by #110
Open

Enhancing Loan Eligibility Estimator Model #5

donna2864 opened this issue Oct 1, 2024 · 8 comments · May be fixed by #110

Comments

@donna2864
Copy link

Problem Description:

The current Loan Eligibility Estimator lacks a developed predictive model, which is crucial for assessing loan approvals. Additionally, the existing system may not be considering several important attributes that significantly impact loan approval decisions. Developing a robust model will enhance the accuracy and reliability of the loan eligibility predictions.

Model Description:

I propose using a machine learning model such as Logistic Regression or Decision Trees to predict loan eligibility. These models are appropriate due to their ability to handle both categorical and numerical data, which is common in loan-related attributes. Moreover, they offer good interpretability, allowing us to identify the key factors contributing to loan approvals. If necessary, we could explore more advanced models like Random Forests or Neural Networks for better performance.

Estimated Time for Completion:

I estimate that it will take around 2-3 weeks to fully develop, train, and test the model. Factors such as data availability and preprocessing time may affect this timeline.

Expected Outcome:

Once implemented, the model is expected to provide accurate predictions of loan eligibility, improving decision-making. This will enhance the functionality of the Loan Eligibility Estimator by incorporating additional relevant features, leading to better performance and user satisfaction.

Additional Context:

It would be helpful to understand the data source we are using for model training. If the dataset is not available, acquiring relevant data is a crucial first step.

@yashasvini121, I would love to contribute to this issue under gssoc24-extd.

Thank you for your consideration.

@yashasvini121
Copy link
Owner

Sure, @donna2864, go ahead!!

@Coreharshit
Copy link

I want to work on this issue

@yashasvini121
Copy link
Owner

Hi @Coreharshit, this issue is already assigned. For now, you can work on other issues.

@yashasvini121
Copy link
Owner

Hi @donna2864,
A timeline of 2-3 weeks is quite long for this project. Could you let us know if it's possible to complete it within a week? Additionally, please provide a status update by the end of the week.

@donna2864
Copy link
Author

Sure i will try completing it within a week, i am a bit busy with exams, but will try to give my updates by then

@donna2864
Copy link
Author

hi i have completed the model, but now i have doubt regarding how to implement the predict.py file.
I am unable to understand how to move forward after the model is saved.
my predict file is something like this
import streamlit as st
import joblib

file = open('knn_model.pkl','rb')
classifier = joblib.load(file)

def predict_loan_approval(no_of_dependents, education, self_employed, income_annum, loan_amount,
loan_term, cibil_score, residential_assets_value, commercial_assets_value,
luxury_assets_value, bank_asset_value):
if education == "Graduate":
education = 0
else:
education = 1

if self_employed == "No":
    self_employed = 0
else:
    self_employed = 1

# Calculate Monthly Gross Income
monthly_gross_income =  income_annum / 12

# Calculate Monthly Debt Payments
monthly_debt_payments =  loan_amount / loan_term * 12

# Calculate Debt-to-Income Ratio
dti_ratio = monthly_debt_payments / monthly_gross_income

# Calculate Total Value of Assets
total_assets = residential_assets_value +  commercial_assets_value +  luxury_assets_value +  bank_asset_value

# Calculate Asset-to-Loan Ratio
asset_to_loan_ratio = total_assets / loan_amount

# Calculate Net Worth
net_worth = total_assets -  loan_amount

prediction = classifier.predict(
    [[no_of_dependents, education, self_employed, income_annum, loan_amount,
                       loan_term, cibil_score, residential_assets_value, commercial_assets_value,
                       luxury_assets_value, bank_asset_value, dti_ratio,  asset_to_loan_ratio, net_worth]])
if prediction == 0:
    prediction = 'APPROVED !'
else:
    prediction = 'REJECTED'

return prediction

Title of the Streamlit app

st.title('Loan Approval Predictor')

Input widgets for features

no_of_dependents = st.slider('Number of Dependents', min_value=0, max_value=10, value=0)
education = st.selectbox('Education', ['Graduate', 'Not Graduate'])
self_employed = st.radio('Employment Status', ['Yes', 'No'])
income_annum = st.number_input('Annual Income', value=0)
loan_amount = st.number_input('Loan Amount', value=0)
loan_term = st.number_input('Loan Term (in years)', value=0)
cibil_score = st.slider('CIBIL Score', min_value=0, max_value=1000, value=0)
residential_assets_value = st.number_input('Residential Assets Value', value=0)
commercial_assets_value = st.number_input('Commercial Assets Value', value=0)
luxury_assets_value = st.number_input('Luxury Assets Value', value=0)
bank_asset_value = st.number_input('Bank Asset Value', value=0)

Button to trigger prediction

if st.button('Predict Loan Approval'):
result = predict_loan_approval(no_of_dependents, education, self_employed, income_annum, loan_amount,
loan_term, cibil_score, residential_assets_value, commercial_assets_value,
luxury_assets_value, bank_asset_value)
st.write('Prediction Result: ...')
st.success('Your loan is {}'.format(result))

but this part is implemented differently, i am having a hard time how to deploy this to the streamlit application
This is my first time doing an open-source contribution so i am having a hard time trying to understand how each of the files in this project are related for doing the prediction part
also i dont know what should be there in model.py, as the same code has been done in the notebook folder.

Could you just help me out with that, I will be done with my exams tomorrow, will finish the remaining work under your guidance

Looking forward for your response
Thank you

@yashasvini121
Copy link
Owner

To correctly implement the predict_loan_approval() function, you'll need to identify the necessary parameters by reviewing the input fields you used to train your model. Pass those fields into the classifier accordingly. Unfortunately, I can't assist much with that right now since I haven't seen the code.

Luckily, you don't have to use Streamlit from scratch. If your project demands that, then it's different else, use the pre-defined classes by following the below instructions.

Once you've completed the predict_loan_approval() function, follow these steps:

  1. Adhere to the Project Structure to maintain consistency and proper organization.
  2. Create a new page in pages/<Page_Name.py> that utilizes the PageHandler class to render the page.
  3. Add your page details to pages/pages.json.
  4. Define the required form fields in form_configs/<form_name>.json. Eg:
  "House Price Form": {                     # Form Name, as mentioned in pages.json
    "Area (in square feet)": {              # Field name that will appear on the form UI
      "type": "number",                      
      # ....
      "field_name": "area"                  # Field names as accepted by the model predict fxn
    },
  1. [Optional] Try creating a model_details() function that prints the model details when called. You don't have to use it on your page, but it can be useful for debugging and reviewing the model.

Refer tutorial, Project Structure, House Price Estimator related code.

Hope this helps, let me know if you got any other queries.

@donna2864
Copy link
Author

ok will try thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Changes Requested
Development

Successfully merging a pull request may close this issue.

3 participants