This tutorial is the continuation of the last tutorial and now let us proceed ahead. In today's tutorial we will be studying LDA, which we have conceptually understood as Linear Discrimination Analysis. This is a technique similar to PCA but its concept is slightly different. So let us see how we can implement it through SK learn. So we will first start with importing. So here also I will take some dummy data. So we will import numpy as np and after this, from S K Learn dot LDA import LDA. So this the package we have and till it connects let us make our data set also. So, dataset np dot A R R A Y array and inside this here we will take the dataset again , the similar dataset that we had taken in PCA.
so let me go to the notebook, the recent notebook here, and I will open this PCA notebook and from there we will carry the dataset. So, modules are not found. Sklearn dot LDA , module not found, OK, so S K Learn dot LDA, so this is a bit strange because in sklearn LDA module should be there , examples, open examples , OK so let's see, let's see , importing libraries, OK they are teaching us to import libraries., that's fine, so from sklearn import LDA no module found , sklearn dot LDA OK. OK,let's search for stack overflow , oh may be it’s name has changed and I have not seen it recently , so let’s check this out, it seems that you have installed newer version of sklearn, OK, OK, so import sklearn and use something like , OK, OK
so import sklearn and then use from sklearn dot discriminant, so we will use this , so let’s use this . we will copy this and let’s try it once , so copy and here we will take a new cell ,add it and then try this out , so let’s try this one and it’s working fine. So whenever this is happening, whenever this happens what you should do is to go to stack overflow and read the document there and after reading you can change it OK. So I did not check which version was there, that I did not check. So now in this version it is working, sklearn dot discriminant analysis import linear discriminant analysis as LDA , so here is how our package will work. So now being very positive about the next thing, now let’s execute it .
So here in the data set as we had earlier first taken negative so minus1 comma minus1 we are taking here and after that one more value we will take and that will be minus2 and minus1 and then one more value, OK, already I have opened that so I will be able to take data from there, so I will take these values OK, so I am putting this data from here to her OK, so my X is ready. Now we will delete this , fine then, so now let us take Y also, output also , y is equal to because it is a supervised approach , so here np. A R R A Y , np dot array and here how many values do I have , so you can see I have 1,2,3,4,5,6 values so for these 6 values here I will write 1,2,3,4,5,6, so I have taken six values, so we have taken Y also. So my X and Y are ready OK.It is a supervised approach so I should have X and Y both and now let’s proceed further. Now here we will make an object of LDA and because it is a classifier so LDA , we are making a LDA classifier, LDA now , here while making the classifier see here it is solver , so we can make changes in solver so we are solving it with SVD , so we kept everything default and made an object of it. Now after this we will use LDA dot fit , like we did in PCA , in a similar manner we will use fit here and pass X and Y here. So it will learn X and Y and after learning, now let us go, so here if you want to predict then you can predict, for any new data set, how, LDA dot predict method it has, predict and here you pass like you pass minus 0.9 , it’s negative and close to minus1 and you also pass minus1 so this minus1 , so this minus1 is close to minus1 , so here I should have given it in a separate list so here I have given it in another list , so see here we get 1 in output , so why has 1 come as result because you would have seen that that for negative one’s I have written 1,1,1 and for positive pairs I have written 2,2,2 so because of this you will notice that the output here is 1 . So in a similar fashion , if we write something positive like 4 and 1 then the output should be 2 and 2 is the output. So this is LDA. So LDA works in this manner and you can try now , on your own data set and after performing it on your data set you can further use your data with ML algorithms. So the next parts to this we will see in the next session. So keep watching , remain motivated, thank you.
If you have any questions or comments related to this course then you can post them beneath this video using the discussion button and by means of this you can discuss this course with other learners too.
good learning but the content titles are jumbled up, like first title of this module is decision tree dichotomiser which is practical part ahead of theory part. Same with the SVM practical 1 title has
Isakki Alias Devi P
yes, i am happy to learning for machine learning in LearnVern.it i s easily understanding for Beginners.
Superb and amazing 😍🤩 enjoyable experience.
Muhammad Nazam Maqbool
Absolutely good course... will suggest it to everyone. has superb content that is covered in a fantastic way.
super course and easily understanding and Good explaned
Ruturaj Nivas Patil
Very well explained in entire course. Great course for everyone as it takes from scratch to advance level.