July 2018
Beginner to intermediate
146 pages
3h 39m
English
Like PCA, linear-discriminant analysis is a linear transformation method that aims to transform m-dimensional data into an n-dimensional output space.
However, unlike PCA, which tries to retain the maximum information, LDA aims to identify a set of n features that result in the maximum separation (or discrimination) of classes. Since LDA requires labeled data in order to determine its components, it is a type of supervised learning algorithm.
Let's now apply the LDA algorithm to the Iris dataset:
#Import LDAfrom sklearn.discriminant_analysis import LinearDiscriminantAnalysis#Define the LDA Object to have two componentslda = LinearDiscriminantAnalysis(n_components = 2)#Apply LDAlda_iris = lda.fit_transform(X, y) ...
Read now
Unlock full access