


下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、function center, U, obj_fcn = FCMClust(data, cluster_n, options % FCMClust.m 采用模糊C均值對(duì)數(shù)據(jù)集data聚為cluster_n類 % 用法: % 1. center,U,obj_fcn = FCMClust(Data,N_cluster,options; % 2. center,U,obj_fcn = FCMClust(Data,N_cluster; % 輸入: % data - nxm矩陣,表示n個(gè)樣本,每個(gè)樣本具有m的維特征值 % N_cluster - 標(biāo)量,表示聚合中心數(shù)目,即類別數(shù) % options -
2、 4x1矩陣,其中 % options(1: 隸屬度矩陣U的指數(shù),>1 (缺省值: 2.0 % options(2: 最大迭代次數(shù) (缺省值: 100 % options(3: 隸屬度最小變化量,迭代終止條件 (缺省值: 1e-5 % options(4: 每次迭代是否輸出信息標(biāo)志 (缺省值: 1 % 輸出: % center - 聚類中心 % U - 隸屬度矩陣 % obj_fcn - 目標(biāo)函數(shù)值 % Example: % data = rand(100,2; % center,U,obj_fcn = FCMClust(data,2; % plot(data(:,1, data(:,2
3、,'o' % hold on; % maxU = max(U; % index1 = find(U(1,: = maxU; % index2 = find(U(2,: = maxU; % line(data(index1,1,data(index1,2,'marker','*','color','g' % line(data(index2,1,data(index2,2,'marker','*','color','r' % plot(center(1
4、2,1,center(1 2,2,'*','color','k' % hold off; % % if nargin = 2 & nargin = 3, %判斷輸入?yún)?shù)個(gè)數(shù)只能是2個(gè)或3個(gè) error('Too many or too few input arguments!' end data_n = size(data, 1; % 求出data的第一維(rows數(shù),即樣本個(gè)數(shù) in_n = size(data, 2; % 求出data的第二維(columns數(shù),即特征值長度 % 默認(rèn)操作參數(shù) default_optio
5、ns = 2; % 隸屬度矩陣U的指數(shù) 100; % 最大迭代次數(shù) 1e-5; % 隸屬度最小變化量,迭代終止條件 1; % 每次迭代是否輸出信息標(biāo)志 if nargin = 2, options = default_options; else %分析有options做參數(shù)時(shí)候的情況 % 如果輸入?yún)?shù)個(gè)數(shù)是二那么就調(diào)用默認(rèn)的option; if length(options < 4, %如果用戶給的opition數(shù)少于4個(gè)那么其他用默認(rèn)值; tmp = default_options; tmp(1:length(options = options; options = tmp; end
6、% 返回options中是數(shù)的值為0(如NaN,不是數(shù)時(shí)為1 nan_index = find(isnan(options=1; %將denfault_options中對(duì)應(yīng)位置的參數(shù)賦值給options中不是數(shù)的位置. options(nan_index = default_options(nan_index; if options(1 <= 1, %如果模糊矩陣的指數(shù)小于等于1 error('The exponent should be greater than 1!' end end %將options 中的分量分別賦值給四個(gè)變量; expo = options(1;
7、 % 隸屬度矩陣U的指數(shù) max_iter = options(2; % 最大迭代次數(shù) min_impro = options(3; % 隸屬度最小變化量,迭代終止條件 display = options(4; % 每次迭代是否輸出信息標(biāo)志 obj_fcn = zeros(max_iter, 1; % 初始化輸出參數(shù)obj_fcn U = initfcm(cluster_n, data_n; % 初始化模糊分配矩陣,使U滿足列上相加為1, % Main loop 主要循環(huán) for i = 1:max_iter, %在第k步循環(huán)中改變聚類中心ceneter,和分配函數(shù)U的隸屬度值; U, cen
8、ter, obj_fcn(i = stepfcm(data, U, cluster_n, expo; if display, fprintf('FCM:Iteration count = %d, obj. fcn = %fn', i, obj_fcn(i; end % 終止條件判別 if i > 1, if abs(obj_fcn(i - obj_fcn(i-1 < min_impro, break; end, end end iter_n = i; % 實(shí)際迭代次數(shù) obj_fcn(iter_n+1:max_iter = ; % % % 子函數(shù)1 function
9、 U = initfcm(cluster_n, data_n % 初始化fcm的隸屬度函數(shù)矩陣 % 輸入: % cluster_n - 聚類中心個(gè)數(shù) % data_n - 樣本點(diǎn)數(shù) % 輸出: % U - 初始化的隸屬度矩陣 U = rand(cluster_n, data_n; col_sum = sum(U; U = U./col_sum(ones(cluster_n, 1, :; % % 子函數(shù)2 function U_new, center, obj_fcn = stepfcm(data, U, cluster_n, expo % 模糊C均值聚類時(shí)迭代的一步 % 輸入: % data
10、- nxm矩陣,表示n個(gè)樣本,每個(gè)樣本具有m的維特征值 % U - 隸屬度矩陣 % cluster_n - 標(biāo)量,表示聚合中心數(shù)目,即類別數(shù) % expo - 隸屬度矩陣U的指數(shù) % 輸出: % U_new - 迭代計(jì)算出的新的隸屬度矩陣 % center - 迭代計(jì)算出的新的聚類中心 % obj_fcn - 目標(biāo)函數(shù)值 mf = U.expo; % 隸屬度矩陣進(jìn)行指數(shù)運(yùn)算結(jié)果 center = mf*data./(ones(size(data, 2, 1*sum(mf'' % 新聚類中心(5.4式 dist = distfcm(center, data; % 計(jì)算距離矩陣 obj_fcn = sum(sum(dist.2.*mf; % 計(jì)算目標(biāo)函數(shù)值 (5.1式 tmp = dist.(-2/(expo-1; U_new = tmp./(ones(cluster_n, 1*sum(tmp; % 計(jì)算新的隸屬度矩陣 (5.3式 % % 子函數(shù)3 function out = distfcm(center, data % 計(jì)算樣本點(diǎn)距離聚類中心的距離 % 輸入: % center - 聚類中心 % data - 樣本點(diǎn) % 輸出: % out - 距離 ou
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- “腎藏精主水”探討補(bǔ)腎活血復(fù)方調(diào)節(jié)p38MAPK-NF-κB-AQP4心衰水液代謝障礙機(jī)制研究
- 改性生物炭對(duì)含酚廢水的吸附性能研究
- 結(jié)構(gòu)拉縫粘彈性阻尼器的減震性能研究
- 《宋代教育》翻譯實(shí)踐報(bào)告(第六章節(jié)選一)
- 頜面部影像技術(shù)課件
- 企業(yè)培訓(xùn)溝通課件
- 《智能網(wǎng)聯(lián)整車綜合測(cè)試》課件-車道保持控制場景測(cè)試評(píng)價(jià)
- 2025年湖北省中考招生考試數(shù)學(xué)真題試卷(真題+答案)
- 《電子產(chǎn)品制造技術(shù)》課件-第6章 電子產(chǎn)品的調(diào)試與檢驗(yàn)
- 預(yù)檢分診知識(shí)課件
- 2024年天津高考數(shù)學(xué)真題試題(原卷版+含解析)
- 《大數(shù)據(jù)分析技術(shù)》課程標(biāo)準(zhǔn)
- 最簡單封陽臺(tái)安全免責(zé)協(xié)議書
- 2024年危險(xiǎn)化學(xué)品經(jīng)營單位安全管理人員考試練習(xí)題(附答案)
- (正式版)JBT 3300-2024 平衡重式叉車 整機(jī)試驗(yàn)方法
- 《無人機(jī)航跡規(guī)劃》課程標(biāo)準(zhǔn)(高職)
- 養(yǎng)老院健康檔案模板
- 夏季高溫期間建筑施工安全注意事項(xiàng)
- 2024年中小學(xué)教師職稱審定答辯題目
- 鋼絲繩吊裝時(shí)最大允許吊裝重物對(duì)應(yīng)表
- 《金融反欺詐與大數(shù)據(jù)風(fēng)控研究報(bào)告(2023)》
評(píng)論
0/150
提交評(píng)論