Reproduce Fisher linear discriminant figure
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Introduction
Fisher's Linear Discriminant (FLD) is a method used in statistics and machine learning to find a linear combination of features that best separates two or more classes of objects or events. The key objective is to maximize the ratio of the difference between the means of the classes to the variation within each class. This provides a linear classifier or, more commonly, a dimensionality reduction technique.
Conceptual Background
Linear Discriminant Analysis
Fisher's Linear Discriminant is one component of Linear Discriminant Analysis (LDA), which assumes that different classes generate data based on different Gaussian distributions. LDA is widely used in pattern recognition and machine learning for dimension reduction and classification.
Mathematical Formulation
Given a set of data points belonging to two classes, the goal is to project the data onto a line such that the separation between the two classes is maximized. The separation is quantified in terms of the difference between projected means relative to the variances in each class.
If are feature vectors of the dataset and is the weight vector, the projection of these vectors is given by . The weight vector should be chosen so that it maximizes Fisher’s criterion:
where:
• and are the means of the projected data for class 1 and class 2, respectively. • and are the variances of the projected data for class 1 and class 2, respectively.
Computing the Optimal Weight Vector
To find the weight vector, , that maximizes , we solve:
Where the within-class scatter matrix is defined as:
Example
Consider a simple dataset with two-dimensional features. We have two classes:
• Class 1: Points: (2, 3), (3, 4), (4, 5) • Class 2: Points: (1, 0), (0, -1), (-1, -2)
- Mean Calculation: Compute the means and . • •
- Scatter Matrices: • Compute using data points and means.
- Weight Vector: • Compute .
These computations will lead to the optimal direction we seek for projecting data to maximize class separation.
Summary Table
| Aspect | Explanation |
| Method | Fisher's Linear Discriminant |
| Goal | Maximize class separation by linear projection |
| Criterion | |
| Optimal Weight Vector | |
| Within-Class Scatter | |
| Example Classes | Class 1: (2, 3), (3, 4), (4, 5) Class 2: (1, 0), (0, -1), (-1, -2) |
Conclusion
Fisher's Linear Discriminant provides a simplistic yet powerful method for linear separation and dimensionality reduction. By finding the optimal projection direction, FLD enhances the ability to distinguish between classes highlighting significant directions in the feature space. Its methodological strength lies in balancing separation between class means with within-class variance, a principle that extends to many modern machine learning approaches.
Related reading
- Reproducible results in Tensorflow with tf.set_random_seed
- Reproducible results using Keras with TensorFlow backend
- Request for example Recurrent neural network for predicting next value in a sequence
- Rescaling after feature scaling, linear regression
- Reshape a Table to Convert Rows to Columns
- Reshape your data either using array.reshape-1, 1 if your data has a single feature or array.reshape1, -1 if it contains a single sample
- Requests not being distributed across gunicorn workers
- Require either of two arguments using argparse
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.