-
Notifications
You must be signed in to change notification settings - Fork 3
/
fuzzy_mortgage.m
161 lines (107 loc) · 3.96 KB
/
fuzzy_mortgage.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
% ===================================================================================
% Problem: Assessment of a mortgage application is normally based on evaluating the
% market value and location of the house, the applicant's assets and income,
% and the repayment plan, which is decided by the applicant's income and
% bank's interest charges.
% ===================================================================================
% Hit any key to load Rule Base 1: Home Evaluation.
pause
a1=readfis('mortgage_1.fis');
% Hit any key to display a fuzzy model of Home Evaluation as a block diagram.
pause
figure('name','Block diagram of a fuzzy model for Home Evaluation');
plotfis(a1);
% Hit any key to display fuzzy sets for the linguistic variable "Location".
pause
figure('name','Location');
plotmf(a1,'input',1);
% Hit any key to display fuzzy sets for the linguistic variable "Market value".
pause
figure('name','Market value, $');
plotmf(a1,'input',2);
% Hit any key to display fuzzy sets for the linguistic variable "House".
pause
figure('name','House');
plotmf(a1,'output',1);
% Hit any key to bring up the Rule Editor.
pause
ruleedit(a1);
% Hit any key to generate a three-dimensional surface for Rule Base 1.
pause
figure('name','Three-dimensional surface for Rule Base 1');
gensurf(a1,[1 2],1);
% Hit any key to load Rule Base 2: Applicant Evaluation.
pause
a2=readfis('mortgage_2.fis');
% Hit any key to display a fuzzy model of Applicant Evaluation as a block diagram.
pause
figure('name','Block diagram of a fuzzy model for Applicant Evaluation');
plotfis(a2);
% Hit any key to display fuzzy sets for the linguistic variable "Asset".
pause
figure('name','Asset, $');
plotmf(a2,'input',1);
% Hit any key to display fuzzy sets for the linguistic variable "Income".
pause
figure('name','Income, $');
plotmf(a2,'input',2);
% Hit any key to display fuzzy sets for the linguistic variable "Applicant".
pause
figure('name','Applicant');
plotmf(a2,'output',1);
% Hit any key to bring up the Rule Editor.
pause
ruleedit(a2);
% Hit any key to generate a three-dimensional surface for Rule Base 2.
pause
figure('name','Three-dimensional surface for Rule Base 2');
gensurf(a2,[1 2],1);
% Hit any key to load Rule Base 3: Credit Evaluation.
pause
a3=readfis('mortgage_3.fis');
% Hit any key to display a fuzzy model of Credit Evaluation as a block diagram.
pause
figure('name','Block diagram of a fuzzy model for Credit Evaluation');
plotfis(a3);
% Hit any key to display fuzzy sets for the linguistic variable "Interest".
pause
figure('name','Interest, %');
plotmf(a3,'input',2);
% Hit any key to display fuzzy sets for the linguistic variable "Credit".
pause
figure('name','Credit, $');
plotmf(a3,'output',1);
% Hit any key to bring up the Rule Editor.
pause
ruleedit(a3);
% Hit any key to generate three-dimensional plots for Rule Base 3.
pause
figure('name','Three-dimensional surface for Rule Base 3');
gensurf(a3,[3 4],1);
% Hit any key to continue.
pause
figure('name','Three-dimensional surface for Rule Base 3');
gensurf(a3,[2 3],1);
% Hit any key to bring up the Rule Viewer.
pause
ruleview(a3);
% Hit any key to continue.
pause
% CASE STUDY
% ====================================================================================
% Suppose, it is required to assess a mortgage application for a house with the market
% value of $450,000 in a fair location. The applicant's assets are $200,000 and his
% income is $56,000 per year. The bank's current interest rate is 4.6%. The applicant
% requested a credit of $350,000.
% ====================================================================================
% Hit any key to obtain results of the home evaluation.
pause
home=evalfis([5.5 450],a1)
% Hit any key to obtain results of the applicant evaluation.
pause
applicant=evalfis([200 56],a2)
% Hit any key to obtain results of the credit evaluation.
pause
credit=evalfis([56 4.6 applicant home],a3)*1000
echo off
disp('End of fuzzy_mortgage.m')