| 5 | 1/1 | 返回列表 |
| 查看: 456 | 回復(fù): 2 | |||
| 當(dāng)前只顯示滿足指定條件的回帖,點(diǎn)擊這里查看本話題的所有回帖 | |||
xiaoyaojushi新蟲 (初入文壇)
|
[求助]
matlab求助
|
||
|
請(qǐng)問幫我解釋一下這個(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 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[碩博家園] 招收生物學(xué)/細(xì)胞生物學(xué)調(diào)劑 +4 | IceGuo 2026-03-26 | 5/250 |
|
|---|---|---|---|---|
|
[碩博家園] 求調(diào)劑 有機(jī)化學(xué)考研356分 +3 | Nadiums 2026-03-25 | 4/200 |
|
|
[考研] 本科雙非材料,跨考一志愿華電085801電氣,283求調(diào)劑,任何專業(yè)都可以 +6 | 芝士雪baoo 2026-03-28 | 7/350 |
|
|
[考研] 0856材料化工調(diào)劑 總分330 +11 | zhubinhao 2026-03-27 | 11/550 |
|
|
[考研] 275求調(diào)劑 +10 | Micky11223 2026-03-25 | 14/700 |
|
|
[考研]
|
y7czhao 2026-03-26 | 10/500 |
|
|
[考研] 299求調(diào)劑 +7 | 嗯嗯嗯嗯2 2026-03-27 | 7/350 |
|
|
[考研] 0703一志愿9,初試成績(jī):338,四六級(jí)已過,有科研經(jīng)歷,求調(diào)劑! +4 | Zuhui0306 2026-03-25 | 4/200 |
|
|
[考研] 一志愿南京航空航天大學(xué)材料學(xué)碩求調(diào)劑 +3 | @taotao 2026-03-28 | 3/150 |
|
|
[考研] 272求調(diào)劑 +7 | 腳滑的守法公民 2026-03-27 | 7/350 |
|
|
[考研] 283求調(diào)劑(080500) +4 | A child 2026-03-27 | 4/200 |
|
|
[考研] 085600,材料與化工321分,求調(diào)劑 +9 | 大饞小子 2026-03-27 | 9/450 |
|
|
[考研] 0703化學(xué)一志愿南京師范大學(xué)303求調(diào)劑 +3 | zzffylgg 2026-03-24 | 3/150 |
|
|
[考研] 276求調(diào)劑。有半年電池和半年高分子實(shí)習(xí)經(jīng)歷 +10 | 材料學(xué)257求調(diào)劑 2026-03-23 | 11/550 |
|
|
[考研]
材料學(xué)碩,求調(diào)劑
6+5
|
糖葫蘆888ll 2026-03-22 | 10/500 |
|
|
[考研] 329求調(diào)劑 +7 | 鈕恩雪 2026-03-25 | 7/350 |
|
|
[考研] 一志愿哈工大,085400,320,求調(diào)劑 +4 | gdlf9999 2026-03-24 | 4/200 |
|
|
[考研] 一志愿吉林大學(xué)材料與化工303分求調(diào)劑 +4 | 為學(xué)666 2026-03-24 | 4/200 |
|
|
[考研] 333求調(diào)劑 +3 | ALULU4408 2026-03-23 | 3/150 |
|
|
[考研] 求老師收我 +3 | zzh16938784 2026-03-23 | 3/150 |
|