Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
9 views
6 pages
LOan Final
1 ml
Uploaded by
rashmikaeonic
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save LOan final (1) For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
9 views
6 pages
LOan Final
1 ml
Uploaded by
rashmikaeonic
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save LOan final (1) For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save LOan final (1) For Later
You are on page 1
/ 6
Search
Fullscreen
10121124, 2:81 PM Loan import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns data=pd.read_csv("LoanApprovalPrediction.csv") data Loan 1D Gender Married Dependents Education Self Employed Applicantincome © \P001002 Male = No 0.0 Graduate No 584g 1 (P001003 Male Yes 10 Graduate No 4583 2 \P00100s Male Yes 0.0 Graduate Yes 3000 Not , 3 LP001006 Male Yes 20 Graduate No 2583 4 PO01008 © Male. No 00 Graduate No 6000 593 LP002978 Female No 0.0 Graduate No 2900 594 LP00297s Male Yes 3.0 Graduate No 4106 595 .P002983 Male Yes 10 Graduate No 8072 596 LP002984 Male Yes 20 Graduate No 7583 597 P0029 Female No 00 Graduate Yes 4583 598 rows x 13 columns data.head(5) Loan ID Gender Married Dependents Education Self Employed Applicantincome ¢ © (P0102 Male No 0.0 Graduate No 5849 1 [P001003 Male Yes 1.0 Graduate No 4583 2 (P001005 Male Yes 0.0 Graduate Yes 3000 3 (P001006 Male Yes 90 ra ane No 2583 4 (P001008 ~— Male No 0.0 Graduate No 6000 > obj = (data.dtypes == ‘object") print("categorical variable”, len(1ist (obj [obj]. index))) {i:13C:/Usors/ADMIN/Desktop/MLP projectLOAN.htmt 810121124, 2:81 PM In Loan categorical variable 7 fLoan_ID is completely unique and not correlated with any of the other column ‘Drop loan_ié column’ data.drop('Loan_I0" ],axis=1, inplace=True) obj = (data.dtypes == ‘object’) object_cols = list(obj[obj].index) plt. Figure(figsize=(18,36)) index = 1 for col in object_cols: y = data[col].value_counts() plt. subplot (11,4, index) plt.xticks (rotation=@) sns.barplot(x=list(y.index), y=y) Index m - i Re me io In In annual income low,high,medium convert in 1,2,3 from sklearn import preprocessing # Label_encoder object knows how # to understand word Labets. Label_encoder = preprocessing. LabelEncoder() obj = (data.dtypes == ‘object") for col in 1ist(obj[obj] index): data[col] = label_encoder. fit_transform(data[col]) Import label encoder categorical variable value convert in numerical value like # Again check the object datatype columns. Let’s find out if there is still any Lef obj = (data.dtypes object’) print("Categorical variables:", len(1ist(obj[obj].index))) Categorical variables: @ plt. figure (figsize=(12,6)) sns-heatmap(data.corr(), chap="Br8G' , fmt: Linewidth: 22, annot=True) shows how closely related two variables are. {i:13C:/Usors/ADMIN/Desktop/MLP projectLOAN.htmt calculates the correlation matrix of the dataset data. The correlation matrix10121124, 2:81 PM Loan Values range from -1 (perfect negative correlation) to 1 (perfect positive correlat #fnt='.2f'= the numbers inside the heatmap to show two decimal places. #linewidths=2: the width of the lines between the cells in the heatmap to 2 units #annot=True: is used, these exact numbers (like 1.0, 0.85, -0.38, etc.) Seaborn prints the exact numbers inside each colored box of the heatmap.''* out [20]: «Axes: > rootcontncome EM conpooincre pe en . “ct Property Area oo 2 Be: a 5 2 2 AS agg tbs 3 5 tn [21]: | eatplet]viauel Le the] plot fon the lector land] Mara tal] Status loFlehe epplleanes sns.catplot(x="Gender", y="Narried", hue="Loan_status", kind="bar”, data-data) Out [21]:
{i:13C:/Usors/ADMIN/Desktop/MLP projectLOAN.htmt10121124, 2:81 PM Loan Loan_status mmo m1 Married Gender #find out if there is any missing values in the dataset for col in data.colunns data[col] = data{col] .fillna(data[col] .mean()) data. isna().sum() adata[col]: Refers to the current column in the dataset. #1.fillna(): replaces all missing values in the column with a specified value. #2.data[col].mean(): This calculates the mean (average) of the non-missing values 4 #If there are any missing values in a column, it fills them with the average value #This checks how many missing values (NaNs) are Left in each colum after filling. #isna(): Identifies where the missing values are. sum(): Adds up the number of missing values in each column. {i:13C:/Usors/ADMIN/Desktop/MLP projectLOAN.htmt10121124, 2:81 PM Loan Gender Narried Dependents Education Self_Employed Applicant Income CoapplicantIncone Loananount Loan_Anount_Term Credit_History Property_Area Loan_status dtype: ints from sklearn.model_selection import train_test_split X = data.drop(['Loan_status’],axis=1) Y = data[ ‘Loan_status’] X.shape,Y.shape X train, X_test, Y_train, Y_test = train test_split(x, Y, X_train.shape, X_test.shape, Y_train.shape, Y_test.shape ((358, 11), (248, 11), (358,), (248,)) from sklearn.neighbors import kNeighborsClassifier from sklearn.ensenble import RandonForestClassifier from sklearn.svm import SVC from sklearn.linear_model import LogisticRegression from sklearn import metrics knn = KNeighborsClassifier(n_neighbors=3) rfc = RandonForestClassifier(n_estinators = 7, criterion = ‘entropy’, random_state =7) sve = Svc() Lc = LogisticRegression() # making predictions on the training set for clf in (rfc, kan, svc,l¢ clf.fit(X_train, Y_train) Yipred = clf.predict(X_train) print("Accuracy score of ", clf._class_._name_, "=", 1o0*metrics.accuracy_score(¥_train, Accuracy score of RandonForestClassifier = 98.04469273743017 Accuracy score of KNeighborsClassifier = 78.49162011173185 Accuracy score of SVC = 68.715837988826¢ Accuracy score of LogisticRegression = 80.16759776536313, {i:13C:/Usors/ADMIN/Desktop/MLP projectLOAN.htmt vp10121124, 2:81 PM Loan : \anaconda\Lib\site-packages\sklearn\linear_model\_logistic.py:469: Convergenceliarn ing: lbfgs failed to converge (status=1) STOP: TOTAL NO. of ITERATIONS REACHED LIMIT. Increase the nunber of iterations (max_iter) or scale the data as shown in: https://scikit-Learn.org/stable/modules/preprocessing-html Please also refer to the documentation for alternative solver option https://scikit-learn.org/stable/modules/1inear_model .html#logistic-regression a iter_i = _check_optimize_result( # making predictions on the testing set for clf in (rfc, knn, svc,lc): clf.Fit(Xtrain, Y_train) Y_pred = clf.predict(x_test) print("Accuracy score of “, clf._class_._name_, 1ee*metrics.accuracy_score(Y_test, Y_pred)) Accuracy score of RandonForestClassifier Accuracy score of KNeighborsClassifier Accuracy score of SVC = 69.16666666666667 Accuracy score of LogisticRegression = 79,58333333333333 :\anaconda\Lib\site-packages\sklearn\linear_model\_logistic.py:469: ConvergenceWarn ing: lbfgs failed to converge (status=1) STOP: TOTAL NO. of ITERATIONS REACHED LIMIT. 82.5 33. 7499999999999 Increase the nunber of iterations (max_iter) or scale the data as shown in: https://scikit-Learn.org/stable/modules/preprocessing-html Please also refer to the documentation for alternative solver options: https://scikit-learn.org/stable/modules/1inear_model.html#logistic-regression 1 _Ater_i = _check_optimize_result( {i:13C:/Usors/ADMIN/Desktop/MLP projectLOAN.htmt
You might also like
Supervised Learning
PDF
100% (1)
Supervised Learning
15 pages
Standard Bank Home Loan Prediction
PDF
No ratings yet
Standard Bank Home Loan Prediction
11 pages
Loan Prediction
PDF
No ratings yet
Loan Prediction
26 pages
Loan Prediction
PDF
No ratings yet
Loan Prediction
33 pages
Python Code For Loan Default Prediction
PDF
No ratings yet
Python Code For Loan Default Prediction
4 pages
DT RF
PDF
No ratings yet
DT RF
7 pages
Final Project Making Predictions From Data-Course 2: October 6, 2020
PDF
No ratings yet
Final Project Making Predictions From Data-Course 2: October 6, 2020
20 pages
Inline: Import As Import As Import As Import As Matplotlib Import
PDF
100% (1)
Inline: Import As Import As Import As Import As Matplotlib Import
15 pages
LDA CreditCardDefault Code N
PDF
No ratings yet
LDA CreditCardDefault Code N
11 pages
Predicting Credit Risk 1713295035
PDF
No ratings yet
Predicting Credit Risk 1713295035
19 pages
12 Useful Pandas Techniques in Python For Data Manipulation
PDF
100% (2)
12 Useful Pandas Techniques in Python For Data Manipulation
19 pages
A Note On R
PDF
No ratings yet
A Note On R
90 pages
I Love Merge
PDF
No ratings yet
I Love Merge
56 pages
Step - 05
PDF
No ratings yet
Step - 05
56 pages
SSRN Id3769854
PDF
No ratings yet
SSRN Id3769854
8 pages
SanatKulkarni - AP22110010183 - Assignment3-1
PDF
No ratings yet
SanatKulkarni - AP22110010183 - Assignment3-1
4 pages
Ids Lab
PDF
No ratings yet
Ids Lab
14 pages
StarterNotebook - Jupyter Notebook
PDF
No ratings yet
StarterNotebook - Jupyter Notebook
12 pages
05 E RandomForest LoanData
PDF
No ratings yet
05 E RandomForest LoanData
8 pages
0loan - Eligibility - Prediction - Python - Ipynb - Colab
PDF
No ratings yet
0loan - Eligibility - Prediction - Python - Ipynb - Colab
6 pages
Kritika Sejwal 24MCI10023 ML Lab Project Report
PDF
No ratings yet
Kritika Sejwal 24MCI10023 ML Lab Project Report
10 pages
Loan Approval
PDF
No ratings yet
Loan Approval
12 pages
Da Lab Mannual
PDF
No ratings yet
Da Lab Mannual
25 pages
Feature Engineering - 01
PDF
No ratings yet
Feature Engineering - 01
31 pages
Loan Status Prediction
PDF
No ratings yet
Loan Status Prediction
23 pages
Feature Engg Code
PDF
No ratings yet
Feature Engg Code
16 pages
Bank Marketing Ingles
PDF
No ratings yet
Bank Marketing Ingles
37 pages
Week 12 Assignment
PDF
No ratings yet
Week 12 Assignment
8 pages
Cleaning Data
PDF
No ratings yet
Cleaning Data
18 pages
Loan
PDF
No ratings yet
Loan
11 pages
Download
PDF
No ratings yet
Download
10 pages
Machine Learning (P1)
PDF
No ratings yet
Machine Learning (P1)
9 pages
'Universalbank - CSV': #Reading The File
PDF
No ratings yet
'Universalbank - CSV': #Reading The File
4 pages
Building Logistic Regression Model in Python
PDF
No ratings yet
Building Logistic Regression Model in Python
24 pages
Lab 02
PDF
No ratings yet
Lab 02
12 pages
PA v0.25
PDF
No ratings yet
PA v0.25
18 pages
Day89 90 Loan Predictions Model 1706059551
PDF
No ratings yet
Day89 90 Loan Predictions Model 1706059551
25 pages
#Group: B (ML) : Numpy NP Pandas PD
PDF
No ratings yet
#Group: B (ML) : Numpy NP Pandas PD
9 pages
Predictive 23-06-2025 - Jupyter Notebook
PDF
No ratings yet
Predictive 23-06-2025 - Jupyter Notebook
14 pages
DA Programs
PDF
No ratings yet
DA Programs
44 pages
Ranvijay 12203409
PDF
No ratings yet
Ranvijay 12203409
13 pages
Maths
PDF
No ratings yet
Maths
21 pages
Credit - Defaulters - Prediction Using Logostic Regression
PDF
No ratings yet
Credit - Defaulters - Prediction Using Logostic Regression
17 pages
Hands-On Activity 3.3 Random Forest Mantaring - Ipynb - Mantaring
PDF
No ratings yet
Hands-On Activity 3.3 Random Forest Mantaring - Ipynb - Mantaring
13 pages
DSBDA Practicals
PDF
No ratings yet
DSBDA Practicals
16 pages
Credit Card Approve Predict Bynvd
PDF
No ratings yet
Credit Card Approve Predict Bynvd
90 pages
DSBDA Prac4 2
PDF
No ratings yet
DSBDA Prac4 2
1 page
Machine File
PDF
No ratings yet
Machine File
27 pages
PA v0.21
PDF
No ratings yet
PA v0.21
17 pages
Loan Approval Model Prediction
PDF
No ratings yet
Loan Approval Model Prediction
10 pages
Exp 3
PDF
No ratings yet
Exp 3
6 pages
Kunal Assignment 3
PDF
No ratings yet
Kunal Assignment 3
19 pages
R Assignment
PDF
No ratings yet
R Assignment
8 pages
Loan Default Logistics Regression
PDF
No ratings yet
Loan Default Logistics Regression
6 pages
Loan Approval Prediction
PDF
No ratings yet
Loan Approval Prediction
23 pages
ML Spy Programs
PDF
No ratings yet
ML Spy Programs
16 pages
Experiment 2 FDL - Jupyter Notebook
PDF
No ratings yet
Experiment 2 FDL - Jupyter Notebook
2 pages
ML
PDF
No ratings yet
ML
23 pages
ML Practicals
PDF
No ratings yet
ML Practicals
11 pages