📄 fuzzy_b.m
字号:
%Script for the fuzzy inference systemglobal modelglobal memb_funglobal model_biasglobal archglobal format_outglobal initglobal no_setsglobal mod_idglobal mod_pathglobal mhist_idglobal mhist_pathglobal err_idglobal err_pathglobal ehist_idglobal ehist_pathglobal pred_idglobal pred_pathglobal memo_idglobal memo_pathcurrent_dir=pwd;c=computer;if isunix current_dir=[current_dir,'/'];else if strcmp(c(1:2),'PC') current_dir=[current_dir,'\']; end if strcmp(c(1:2),'MA') current_dir=[current_dir,':']; endend%__________________________________________________________________%%%The 'data' (the training set) matrix is stored in the file: data_id='data.mat'; data_path=current_dir;%%%Save the memoranda in the file: memo_id='memo_id'; memo_path=current_dir;%__________________________________________________________________%Train one model of given complexity or find the best complexity? %pr='one_mod'; pr='evaluate'; %pr='comp_err';%__________________________________________________________________%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%for model training only_____________%%%%complexity comp=5;%Save the trained model in the file: mod_id='model.mat'; mod_path=current_dir;%Save the computation diary in the file: mhist_id='mhist.txt'; mhist_path=current_dir;%__________________________________________________________________%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%for model evaluating only___________%%%The trained model is stored in the file: tmod_id='model.mat'; tmod_path=current_dir;%%%The 'in' (test set) matrix is stored in the file: in_id='in.mat'; in_path=current_dir;%Save the predicted output in the file: pred_id='out_hat.mat'; pred_path=current_dir;%__________________________________________________________________%%%%%%%%%%%%%%%%%for complexity-error exploration only_____________%%%range of complexity comp_min=10; comp_max=20;%%%validation valid='x_valid';%%%no_sets x_valid no_sets=10;%Save the error Vs complexity matrix in the file: err_id='errors.mat'; err_path=current_dir;%Save the computation diary in the file: ehist_id='ehist.txt'; ehist_path=current_dir;%__________________________________________________________________%%%model type model='fuz';%_______for complexity-error exploration and model training only:__%%%form of membership functions memb_fun='gaussian'; %memb_fun='triangular';%_______for complexity-error exploration and model training only:__%%%Bias %model_bias='bias'; model_bias='no_bias';%_______for complexity-error exploration and model training only:__%%%architecture arch='comb'; %arch='weigthed';%_______for complexity-error exploration and model training only:__%%%format_out format_out='linear'; %format_out='constant';%%%cluster: initialization of the centers and bases %init='k_mean'; init='HFC';%__________________________________________________________________if strcmp(pr,'one_mod') eval(['load ',data_path,data_id]); fuz_aux(pr,comp,data); elseif strcmp(pr,'evaluate') eval(['load ',tmod_path,tmod_id]); eval(['load ',in_path,in_id]); fuz_aux(pr,centers,bases,par,bias,in);elseif strcmp(pr,'comp_err') eval(['load ',data_path,data_id]); fuz_aux(pr,comp_min,comp_max,data); end %__________________________________________________________________clear model valid memb_fun model_bias clear arch format_out init no_sets clear mod_id mod_path mhist_id mhist_path clear err_id err_path ehist_id ehist_pathclear pred_id pred_path in_id in_pathclear tmod_id tmod_pathclear memo_id memo_path clear pr clear centers bases par bias in clear comp comp_min comp_maxclear data data_id data_path clear c current_dir %__________________________________________________________________
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -