Questions tagged [linear-discriminant]
103 questions
1
vote
0 answers
Why is the confusion matrix and test error the same despite the LDA being done different datasets
library(ISLR2)
df = Auto
df$mclass <- as.factor(ifelse(df$mpg <20, 'low', ifelse(df$mpg >= 20 & df$mpg < 27, 'medium', 'high')))
I have split the dataset into test and training
test = df[df$year == 75,]
test.direction = test$mclass
training = …

user4891693
- 35
- 1
- 2
- 5
1
vote
1 answer
Alternatives to kmeans() for spotting small clusters for k=2
I have a tibble with two columns, D1 and D2. These are distributed as the figure.
I want to split the obs. in 2 clusters. The theory predicts that one of the two will be much smaller than the other.
To me, given the liner relation (R^2 = .9)…

GiulioGCantone
- 195
- 1
- 10
1
vote
0 answers
Trying to conduct a Stepwise LDA in R but keep receiving an error message
I am running a stepwise LDA to look at how to discriminant against two groups (P vs NP) based on 4 variables. I ran the lda function with no problems but when I try to do the stepwise function I get this message:
Error in if (any(member < 0) ||…

mg332842
- 11
- 1
1
vote
0 answers
Diagonal Quadratic Linear discriminant and Diagonal Linear discriminant analysis in python
I implemented linear discriminant analysis and quadratic discriminant analysis on my dataset using LDA() and QDA() functions in sklearn python as classifier to predict cancer dataset. now I need to do diagonal linear discriminant analysis and…

Sara
- 11
- 1
1
vote
2 answers
R LDA (linear discriminant analysis) how to get / compute LDA scores from LDA coefficients / loadings
I am using the lda function in R to fit a model. After fitting a model, I would like to use the fits to then put into a computer program to classify based on inputs. I only see the coefficients of linear discriminants and group means. I thought I…

Schatzi121
- 73
- 1
- 7
1
vote
1 answer
Printing the results of an increasing cumulative loop as a single data frame in R
I've been running a least discriminant analysis on the results of a principal components analysis in R, and I've been calculating the appropriate number of PCs to use based on the minimum number of PCs that represent a certain threshhold of…

user2352714
- 314
- 1
- 15
1
vote
1 answer
How to use sklearn RFECV to select the optimal features to pass to a dimensionality reduction step before fitting my estimator
How can I use sklearn RFECV method to select the optimal features to pass to a LinearDiscriminantAnalysis(n_components=2) method for dimensionality reduction, before fitting my estimator using a KNN.
pipeline = make_pipeline(Normalizer(),…

Ben-Jamin-Griff
- 45
- 7
1
vote
0 answers
R: How to calculate the threshold for LDA in the case of three classes?
The result of discriminant analysis for the three classes are two discriminant functions LD1 and LD2.
In the case of two classes, there is one discriminant function LD1, and the threshold of discrimination can be calculated as follows:
M1 is the…

Vitalii
- 71
- 1
- 7
1
vote
0 answers
Why is my matrix of linear discriminant analysis coefficients 2x1 and not 2x2?
I am running some Linear Discriminant Analysis on some stock market data. I am following the lab in Chapter 4 of 'An Introduction to Statistical Learning'. My problem involves 2 predictors (x variables) and 2 classes to which they can be assigned.
I…

Sean
- 587
- 4
- 20
1
vote
1 answer
Equivalent to fitcdiscr in R (regarding Coeffs.linear and Coeffs.Const)
I am currently translating some MATLAB scripts to R for Multivariate Data Analysis. Currently I am trying to generate the same data as the Coeffs.Linear and Coeffs.Const part of the fitdiscr function in MATLAB.
The code being used…

MiraculicKz
- 11
- 3
1
vote
1 answer
Linear Discriminant Analysis (Error: index 1 is out of bounds)
I have a data set. the first 10 numbers are my features (one,two,...,ten) and the last column is my target (There are only 2 targets including MID and HIGH). The data is saved in a txt format (data.txt)…

Leo
- 479
- 2
- 6
- 16
1
vote
1 answer
How to explain variables weight from a Linear Discriminant Analysis?
I'm working on a supervised classification. To begin I would like to find variables which have important weight to discriminate each class. My code is the following :
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
X =…

Pollux
- 85
- 1
- 3
- 10
1
vote
3 answers
Linear Discriminant Analysis with scikit learn in Python
I am getting into machine learning and recently I have studied classification of linear separable data using linear Discriminant Analysis. To do so I have used the scikit-learn package and the…

user112110
- 31
- 1
- 4
1
vote
1 answer
Python mean shift clustering of complex-number numpy array
I’ve inherited some code that was written about a year ago, so I guess back then it was using numpy 1.13 (now v1.15.2), scipy 1.00rc (now v1.1.0), and sklearn 0.19 (now v.0.20.0).
It implements Fisher’s LDA to reduce an n-dimensional space to an…

Jens
- 8,423
- 9
- 58
- 78
1
vote
0 answers
Implement Linear Discriminant Analysis
I try to implement LDA from scratch using this notes https://web.stanford.edu/class/stats202/content/lec9.pdf (page 34)
To check my implementation, I compare my priors, group means, and coefficients of linear discriminants with lda() function in…

Anna
- 49
- 7