📄 trips.m
字号:
%
% We can now probe the FIS to understand how the clusters got converted
% internally into membership functions and rules.
fuzzy(myfis)
%%
% *Figure 3:* The graphical editor for building Fuzzy Inference Systems
% (FIS)
%%
% |fuzzy| is the function that launches the graphical editor for building
% fuzzy systems. |fuzzy(myfis)| launches the editor set up to edit
% |myfis|, the FIS that we just generated. As can be seen, the FIS has 5
% inputs and 1 output with the inputs mapped to the outputs through a
% rulebase (white box in the figure).
%
% Let's now try to analyze how the cluster centers and the membership
% functions are related.
mfedit(myfis)
%%
% *Figure 4:* The graphical membership function editor
%%
% |mfedit(myfis)| launches the graphical membership function editor. It
% can also be launched by clicking on the inputs or the outputs in the
% FIS editor launched by |fuzzy|.
%
% Notice that all the inputs and outputs have exactly 3 membership
% functions. The 3 membership functions represent the 3 clusters that were
% identified by |subclust|.
%
% Each input in the FIS represents an input variable in the input dataset
% |datin| and each output in the FIS represents an output variable in the
% output dataset |datout|.
%
% By default, the first membership function, |in1cluster1|, of the first
% input |population| would be selected in the membership function editor.
% Notice that the membership function type is "gaussmf" (gaussian type
% membership function) and the parameters of the membership function are
% |[1.162 1.877]|, where |1.162| represents the spread coefficient of the
% gaussian curve and |1.877| represents the center of the gaussian curve.
% |in1cluster1| captures the position and influence of the first cluster
% for the input variable |population|. |(C(1,1)=1.877, S(1)=1.1621 )|
%
% Similarly, the position and influence of the other 2 clusters for the
% input variable |population| are captured by the other two membership
% functions |in1cluster2| and |in1cluster3|.
%
% The rest of the 4 inputs follow the exact pattern mimicking the position
% and influence of the 3 clusters along their respective dimensions in the
% dataset.
%
% Now, let's explore how the fuzzy rules are constructed.
ruleedit(myfis)
%%
% *Figure 5:* The graphical rule editor
%%
% |ruleedit| is the graphical fuzzy rule editor. As you can notice, there
% are exactly three rules. Each rule attempts to map a cluster in the input
% space to a cluster in the output space.
%
% The first rule can be explained simply as follows. If the inputs to the
% FIS, |population|, |dwelling units|, |num vehicles|, |income|, and
% |employment|, strongly belong to their respective |cluster1| membership
% functions then the output, |num of trips|, must strongly belong to its
% |cluster1| membership function. The (1) at the end of the rule is to
% indicate that the rule has a weight or an importance of "1". Weights can
% take any value between 0 and 1. Rules with lesser weights will count for
% less in the final output.
%
% The significance of the rule is that it succinctly maps cluster 1 in
% the input space to cluster 1 in the output space. Similarly the other
% two rules map cluster 2 and cluster 3 in the input space to cluster 2
% and cluster 3 in the output space.
%
% If a datapoint closer to the first cluster, or in other words
% having strong membership to the first cluster, is fed as input to |myfis|
% then rule1 will fire with more <#28 firing strength> than the other two
% rules. Similarly, an input with strong membership to the second cluster
% will fire the second rule will with more firing strength than the other
% two rules and so on.
%
% The output of the rules (firing strengths) are then used to generate the
% output of the FIS through the output membership functions.
%
% The one output of the FIS, |num of trips|, has 3 linear membership
% functions representing the 3 clusters identified by |subclust|. The
% coefficients of the linear membership functions though are not taken
% directly from the cluster centers. Instead, they are estimated from the
% dataset using least squares estimation technique.
%
% All 3 membership functions in this case will be of the form |a*population
% + b*dwelling units + c*num vehicles + d*income + e*employment + f|, where
% |a|, |b|, |c|, |d|, |e| and |f| represent the coefficients of the linear
% membership function. Click on any of the |num of trips| membership
% functions in the membership function editor to observe the parameters of
% these linear membership functions.
%
%% Using the FIS for data exploration
% You can now use the FIS that has been constructed to understand the
% underlying dynamics of relationship being modeled.
surfview(myfis)
%%
% *Figure 6:* Input-Output Surface viewer
%%
% |surfview| is the surface viewer that helps view the input-output
% surface of the fuzzy system. In other words, this tool simulates the
% response of the fuzzy system for the entire range of inputs that the
% system is configured to work for. Thereafter, the output or the response
% of the FIS to the inputs are plotted against the inputs as a surface.
% This visualization is very helpful to understand how the system is going
% to behave for the entire range of values in the input space.
%
% In the plot above the surface viewer shows the output surface for two
% inputs |population| and |num of dwelling units|. As you can see the
% number of auto trips increases with increase in population and dwelling
% units, which sounds very rational. You can change the inputs in the X and
% Y drop-down boxes to observe the output surface with respect to the inputs
% you choose.
ruleview(myfis)
%%
% *Figure 7:* Rule viewer that simulates the entire fuzzy inference process
%%
% |ruleview| is the graphical simulator for simulating the FIS response for
% specific values of the input variables. Now, having built the fuzzy system,
% if we want to understand how many trips will occur for a particular
% demographic setup, say an area with a particular population, a certain
% number of dwelling units and so on, this tool will help you simulate the
% FIS response for the input of your choice.
%
% Another feature of this GUI tool is, it gives you a snapshot of the
% entire fuzzy inference process, right from how the membership functions
% are being satisfied in every rule to how the final output is being
% generated through <#28 defuzzification>.
%
%% Conclusion
% This example has attempted to convey how clustering and fuzzy logic can
% be employed as effective techniques for data modeling and analysis.
%
% Fuzzy logic has also found various
% applications in other areas of technology like non-linear control,
% automatic control, signal processing, system identification, pattern
% recognition, time series prediction, data mining, financial applications
% etc.,
%
% Explore other demos and the documentation for more insight into fuzzy
% logic and its applications.
%
%% Glossary
%
% *input space* - it is a term used to define the range of all possible
% values in the dataset. When using |subclust| the input space refers to
% the entire range of values between the maximum and minimum in each
% dimension (column) of the dataset.
%
% *defuzzification* - the process of transforming a fuzzy output of a fuzzy
% inference system into a crisp output.
%
% *firing strength* - The degree to which the antecedent part of a fuzzy
% rule is satisfied. Also known as degree of fulfillment.
%
% *fuzzy inference system (FIS)* - The overall name for a system that uses
% fuzzy reasoning to map an input space to an output space
%
% *Reference:*
%
% [Chi94] - S. Chiu, "Fuzzy Model Identification Based on Cluster
% Estimation," J. of Intelligent & Fuzzy Systems, Vol. 2, No. 3, 1994.
displayEndOfDemoMessage(mfilename)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -