| 3 | 1/1 | 返回列表 |
| 查看: 453 | 回復(fù): 2 | |||
xiaoyaojushi新蟲 (初入文壇)
|
[求助]
matlab求助
|
|
請問幫我解釋一下這個(gè)程序的意思吧,希望能詳細(xì)解釋一下每句的意思! function [res mi]=forward_sel_class(X,Y,k) % Forward feature selection using the MI criterion. % X is a dataset (n x d) with n samples and d features and Y is the class % vector with classes denoted 1, 2 ... c. [s1,s2]=size(X); res = []; remainingset = [1:size(X,2)]; for j=1:size(X,2) j; currscore=[]; for i=1:length(remainingset) tempset = [res remainingset(i)]; tempscore=miv_opt(X(:,tempset),Y,k); currscore(i, =tempscore;end [winnerscore, winner] = max(currscore); mi(i)=winnerscore; res = [res remainingset(winner)]; remainingset(winner) = []; end function res = miv(X,Y,k) if(size(Y,1) > size(Y,2)) Y = Y'; end warning off % Estimate mutual information between X ad Y with Y a discrete random variable % and X a real random vector % k must be smaller than the minimum number of points in a class. load digammaMAT; Y = 1 + Y - min(Y); [N,d] = size(X); % Sample size and dimension C = full(ind2vec(Y))'; % Matrix of binary class description [N, L] = size(C); % Sample size and number of classes cN = sum(C); % sample size of each class for l=1:L, digammacN(l) = digammaMAT(cN(l));end distmat = pairwisedistances(X,2); epsilonallclasses = zeros(N,1); epsilonsameclass = zeros(N,1); for j = 1:N % get vector of all distances dist = distmat(j, ;% sort this vector [sorteddistances, distanceindices] = sort(dist); % find the distance to the k th neighbour epsilonallclasses(j) = 2*sorteddistances(k+1); % the first neighbour is the point itself % find the distance to the k th neighbour in the same class whichclass = Y(j); mask = C(:,whichclass); mask = mask(distanceindices); sorteddistancesinsameclass = sorteddistances(find(mask)); epsilonsameclass(j) = 2*sorteddistancesinsameclass(k+1); end res = digammaMAT(N) - 1/N * sum(cN.*digammacN)+ d/N * sum((log(epsilonallclasses))-(log(epsilonsameclass))); res=res/log(2); % ajout % if (isnan(res)==1)|(res==-Inf)|(res<0) % res=0; % end % if j is specified, output is the distance from all points in X to j % otherwise, output is a full squared distance matrix with all distances % between all points function [res] = pairwisedistances(X, pp,j) [n,p] = size(X); if nargin < 3 %outClass = class(X); Y = zeros(1,n*(n-1)./2, 'single'); k = 1; for i = 1:n-1 dsq = zeros(n-i,1,'single'); for q = 1:p dsq = dsq + abs(X(i,q) - X((i+1):n,q)).^pp; end Y(k k+n-i-1)) = (dsq).^(1/pp);k = k + (n-i); end res = squareform(Y); else res = (sum(abs(X-repmat(X(j, ,n,1)).^pp,2)).^(1/pp);end [ 來自科研家族 人工智能 ] |
超級(jí)版主 (文學(xué)泰斗)
No gains, no pains.
![]() |
專家經(jīng)驗(yàn): +21105 |
| 3 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 265求調(diào)劑 +8 | 梁梁校校 2026-03-17 | 8/400 |
|
|---|---|---|---|---|
|
[考研] 281求調(diào)劑(0805) +12 | 煙汐憶海 2026-03-16 | 23/1150 |
|
|
[考研] 材料080500調(diào)劑求收留 +6 | 一顆meteor 2026-03-13 | 6/300 |
|
|
[考研] 08工學(xué)調(diào)劑 +4 | 用戶573181 2026-03-20 | 4/200 |
|
|
[考研] 304求調(diào)劑 +5 | 曼殊2266 2026-03-18 | 5/250 |
|
|
[考研] 求調(diào)劑 +3 | 暗涌afhb 2026-03-16 | 3/150 |
|
|
[論文投稿]
申請回稿延期一個(gè)月,編輯同意了。但系統(tǒng)上的時(shí)間沒變,給編輯又寫郵件了,沒回復(fù)
10+3
|
wangf9518 2026-03-17 | 4/200 |
|
|
[考研] 081700化工學(xué)碩調(diào)劑 +3 | 【1】 2026-03-16 | 3/150 |
|
|
[考研] 294求調(diào)劑材料與化工專碩 +14 | 陌の森林 2026-03-18 | 14/700 |
|
|
[考研] 材料與化工求調(diào)劑 +7 | 為學(xué)666 2026-03-16 | 7/350 |
|
|
[考研] 332求調(diào)劑 +3 | ydfyh 2026-03-17 | 3/150 |
|
|
[考研] 304求調(diào)劑 +6 | 司空. 2026-03-18 | 6/300 |
|
|
[考研] 一志愿武理材料305分求調(diào)劑 +5 | 想上岸的鯉魚 2026-03-18 | 6/300 |
|
|
[考研] 一志愿西南交大,求調(diào)劑 +4 | 材化逐夢人 2026-03-18 | 4/200 |
|
|
[考研] 收復(fù)試調(diào)劑生 +4 | 雨后秋荷 2026-03-18 | 4/200 |
|
|
[考研] 303求調(diào)劑 +4 | 睿08 2026-03-17 | 6/300 |
|
|
[考研] 334求調(diào)劑 +3 | 志存高遠(yuǎn)意在機(jī)?/a> 2026-03-16 | 3/150 |
|
|
[考研] 277材料科學(xué)與工程080500求調(diào)劑 +3 | 自由煎餅果子 2026-03-16 | 3/150 |
|
|
[考研] 288求調(diào)劑 +4 | 奇點(diǎn)0314 2026-03-14 | 4/200 |
|
|
[考研] 297求調(diào)劑 +4 | 學(xué)海漂泊 2026-03-13 | 4/200 |
|