tag:blogger.com,1999:blog-37324607.post2782936907946760214..comments2023-11-03T08:31:23.698-04:00Comments on Data Mining in MATLAB: Linear Discriminant Analysis (LDA)Will Dwinnellhttp://www.blogger.com/profile/03379859054257561952noreply@blogger.comBlogger21125tag:blogger.com,1999:blog-37324607.post-28544797441637665312019-08-26T06:50:15.238-04:002019-08-26T06:50:15.238-04:00Dear Mr. Dwinnell,
thank you so much for your LDA...Dear Mr. Dwinnell,<br /><br />thank you so much for your LDA implementation!<br /><br />Can you please explain me the reason why you have implemented the covariance matrix in this way:<br />PooledCov = PooledCov + ((nGroup(i) - 1) / (n - k) ).* cov(Input(Group,:));<br /><br />What do you think about this implementation:<br />PooledCov = PooledCov + nGroup(i)/(n * k).*cov(Input(Group,:));<br /><br /><br />With best regards<br />AlexAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-37324607.post-11886585138850967682017-09-13T23:25:15.118-04:002017-09-13T23:25:15.118-04:00hi Will, thanks a lot for the post.
just wanna as...hi Will, thanks a lot for the post.<br /><br />just wanna ask you, your LDA code its for dimentionality reduction or classification? thanksAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-37324607.post-90628659271524333182017-02-27T10:35:29.518-05:002017-02-27T10:35:29.518-05:00Hi Will, thanks for this post. I have a data set 3...Hi Will, thanks for this post. I have a data set 320 by 75 and I am predicting some certain states using random forest, so the data set serves as input to random forest.<br /><br />Does LDA work well for reducing feature dimension in regression task? According to what i have read so far, it seems to me like it is only good for classification.<br /><br />Meanwhile i got the following result when i implemented dimension reduction: > In LDA (line 76) <br />Warning: Matrix is singular, close to<br />singular or badly scaled. Results may<br />be inaccurate. RCOND = NaN. Vincent Somto Igwehttps://www.blogger.com/profile/08033126380385192735noreply@blogger.comtag:blogger.com,1999:blog-37324607.post-9742349429681500862016-02-01T11:27:07.725-05:002016-02-01T11:27:07.725-05:00Can you help me out in classification, I have 400 ...Can you help me out in classification, I have 400 subjects and have a 102 dimensional column vector for each,<br />for each subject 7 observation of training, so ihave 2800 lines:<br />I tried to program this algorithm LDA :<br />Input=X(2800,102);<br />% Input= Input';<br />Target=X(2800,1);<br />%Calculate linear discriminant coefficients<br />W = LDA(Input,Target)<br /> % Calulcate linear scores for training data<br /> L = [ones(2800,1) Input] * W';<br /> <br /> % Calculate class probabilities<br /> P = exp(L) ./ repmat(sum(exp(L),2),[1 400]);<br />as a result, I found all the value of P = NaN<br />Anonymoushttps://www.blogger.com/profile/09509958914946760410noreply@blogger.comtag:blogger.com,1999:blog-37324607.post-88277623458615726032015-10-07T03:22:25.635-04:002015-10-07T03:22:25.635-04:00hi tis code is very useful and how the features ar...hi tis code is very useful and how the features are reduced finally i cant understand that and what are the features extracted...sylviaahttps://www.blogger.com/profile/16091676251554051368noreply@blogger.comtag:blogger.com,1999:blog-37324607.post-4441080189324297192014-09-03T01:29:52.138-04:002014-09-03T01:29:52.138-04:00hi
i recently read a paper that uses LDA as a func...hi<br />i recently read a paper that uses LDA as a function to reduce dimentionality .in this article author said that :<br />"In order to reduce the dimensionality of the iriscode and remove the redundancy present in the code, LDA is applied to the<br />iriscode features. Only the top 80 LDA coefficients are retained and these ..."<br />i want to use your code as LDA, but i do'nt know how can i retain top 80 coefficient? i'm so confused .if you help me ,i will appreciate you .Anonymoushttps://www.blogger.com/profile/17988201306085111487noreply@blogger.comtag:blogger.com,1999:blog-37324607.post-5201545904958995392012-05-09T05:36:15.160-04:002012-05-09T05:36:15.160-04:00Nauman, The error message you received indicates t...Nauman, The error message you received indicates that your installation of MATLAB is not aware of any <i>LDA</i> function. MATLAB only knows about the functions which are built into itself, and any which you add to it. You need to download the LDA function from MATLAB Central (check near the top of this posting).Will Dwinnellhttps://www.blogger.com/profile/03379859054257561952noreply@blogger.comtag:blogger.com,1999:blog-37324607.post-31474622195358800512012-05-08T23:13:16.000-04:002012-05-08T23:13:16.000-04:00hello , I am trying to run your code but Matlab is...hello , I am trying to run your code but Matlab is not excepting LDA as a command :o<br /><br />X = [randn(10,2); randn(15,2) + 1.5];<br />>> Y = [zeros(10,1); ones(15,1)];<br />>> W = LDA(X,Y)<br />??? Undefined function or method 'LDA' for input arguments of type 'double'.Naumannoreply@blogger.comtag:blogger.com,1999:blog-37324607.post-33112998951051661852012-01-09T02:10:39.109-05:002012-01-09T02:10:39.109-05:00Thank for your answer.Thank for your answer.laguna357https://www.blogger.com/profile/10582028333747613753noreply@blogger.comtag:blogger.com,1999:blog-37324607.post-17019815751636757112012-01-06T07:00:47.136-05:002012-01-06T07:00:47.136-05:00Assuming that the target variable used in the exam...Assuming that the target variable used in the example above, <i>Y</i>, had three distinct values, representing three class to be categorized, then calculation of the linear scores would be exactly the same:<br /><br /><i>% Calulcate linear scores for training data<br />L = [ones(25,1) X] * W';</i><br /><br />...and calculation of the probability estimates would be nearly the same, with the last element of the second parameter to <i>repmat()</i> being the number of classes, which is 3 in this case:<br /><br /><i>% Calculate class probabilities<br />P = exp(L) ./ repmat(sum(exp(L),2),[1 3]);</i>Will Dwinnellhttps://www.blogger.com/profile/03379859054257561952noreply@blogger.comtag:blogger.com,1999:blog-37324607.post-18886694905106850182012-01-06T02:26:11.962-05:002012-01-06T02:26:11.962-05:00Thx for your code.
How can I check the probabilit...Thx for your code.<br /><br />How can I check the probabilities if my data has more than 2 classes.laguna357https://www.blogger.com/profile/10582028333747613753noreply@blogger.comtag:blogger.com,1999:blog-37324607.post-71371872539713253652012-01-04T06:08:08.309-05:002012-01-04T06:08:08.309-05:00with6:
In a sense, yes. Assuming that the number...with6:<br /><br />In a sense, yes. Assuming that the number of classes is less than the number of predictor variables, then the set of discriminant functions is a reduced set of data.<br /><br />Of course, as with PCA, all of the original predictor variables will still be needed, but any downstream analysis will have less variables to deal with.Will Dwinnellhttps://www.blogger.com/profile/03379859054257561952noreply@blogger.comtag:blogger.com,1999:blog-37324607.post-79228096679183859192012-01-04T05:56:42.505-05:002012-01-04T05:56:42.505-05:00It's probably a stupid question, but is it pos...It's probably a stupid question, but is it possible to do dimension reduction with this code, and if it is, I would like to know how that would work.<br />Thank you.wirth6https://www.blogger.com/profile/05801819648339418355noreply@blogger.comtag:blogger.com,1999:blog-37324607.post-48084400546250512042011-06-17T21:02:00.255-04:002011-06-17T21:02:00.255-04:00shreyas,
That is very many candidate input variab...shreyas,<br /><br />That is very many candidate input variables for so few observations. I expect that you'll need to either select a much smaller number of inputs from this list or reduce them some other way (as by PCA).Will Dwinnellhttps://www.blogger.com/profile/03379859054257561952noreply@blogger.comtag:blogger.com,1999:blog-37324607.post-31867105661844998152011-06-17T11:38:51.310-04:002011-06-17T11:38:51.310-04:00Can you help me out in classification, I have 123 ...Can you help me out in classification, I have 123 subjects and have a 16384 dimension column vector for each, I have been able to use PCA for projecting data in Eigen space and doing the recognition.But I am confused with how to do it with LDA, as in things appear to be hazy.shreyashttps://www.blogger.com/profile/16515520556179175270noreply@blogger.comtag:blogger.com,1999:blog-37324607.post-50313031416539026652011-04-26T22:32:30.746-04:002011-04-26T22:32:30.746-04:00Hi Mr Will,
I found your post is very informati...Hi Mr Will,<br /> I found your post is very informative. Thanks!<br />However, I would like to ask any idea to use principal component prior to disciminant analysis? Im a beginner in Matlab, and Im facing difficulties in writing the script. Thank you! My email: megumi.wai@gmail.com<br /><br />Thank you in advance!Mun Waihttps://www.blogger.com/profile/10967708543338132563noreply@blogger.comtag:blogger.com,1999:blog-37324607.post-45953229175423191112011-04-17T13:44:11.987-04:002011-04-17T13:44:11.987-04:00Hello Mr Will Dwinnell
I was looking a matlab code...Hello Mr Will Dwinnell<br />I was looking a matlab code about LDA and i found your code. It is nice, however i need to use 5 different data in it. So, If i will write the input and target as a following form, is it right or not:<br />X = [c1 ; c2; c3; c4; c5]; <br />Y = [zeros(689,1); ones(689,1); 2*ones(309,1); 3*ones(692,1); 4*ones(689,1)];<br /><br />It is urgent, please reply to me ASAP. <br />Thanks beforehand.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-37324607.post-84690807990453256202011-01-19T14:39:49.753-05:002011-01-19T14:39:49.753-05:00hi
thanks for your answerhi<br />thanks for your answerUnknownhttps://www.blogger.com/profile/02632114045827983490noreply@blogger.comtag:blogger.com,1999:blog-37324607.post-65442023361696795212011-01-19T13:54:04.781-05:002011-01-19T13:54:04.781-05:00mohammad reza:
I assume that you mean classificat...mohammad reza:<br /><br />I assume that you mean classification when there are more than 2 groups? Linear discriminants can do this. If you want to try this with my LDA() function, just use a target variable with more than 2 distinct values.Will Dwinnellhttps://www.blogger.com/profile/03379859054257561952noreply@blogger.comtag:blogger.com,1999:blog-37324607.post-23672492768527223722010-12-29T05:57:03.872-05:002010-12-29T05:57:03.872-05:00Jaidev Deshpande:
Thanks!
mohammad reza:
I hav...Jaidev Deshpande:<br /><br />Thanks!<br /><br /><br />mohammad reza:<br /><br />I have heard "discriminant function analysis" (also the term "multiple discriminant analysis") used to refer to linear discriminant analysis, so my understanding is that they are the same thing.Will Dwinnellhttps://www.blogger.com/profile/03379859054257561952noreply@blogger.comtag:blogger.com,1999:blog-37324607.post-64911631404842507492010-12-11T17:59:27.896-05:002010-12-11T17:59:27.896-05:00Dear Will
Great to have you back on the blog afte...Dear Will<br /><br />Great to have you back on the blog after so long.Anonymoushttps://www.blogger.com/profile/01082878986852695651noreply@blogger.com