Questions tagged [linear-discriminant]

The tag has no usage guidance.

linear-discriminant
Filter by
Sorted by
Tagged with
27 votes
1 answer
1k views

Why eigenvector & eigenvalue in LDA become zero?

I'd like to implement fast PLDA (Probabilistic Linear Discriminant Analysis) in OpenCV. in this, LINK fast PLDA have been implemented in Matlab and Python. One of the parts of PLDA is LDA. I've ...
Saeid's user avatar
  • 548
8 votes
1 answer
12k views

Linear Discriminant Analysis vs Naive Bayes

What are the advantages and disadvantages of LDA vs Naive Bayes in terms of machine learning classification? I know some of the differences like Naive Bayes assumes variables to be independent, ...
jon givony's user avatar
6 votes
1 answer
12k views

LDA interpretation

I use the HMeasure package to involve the LDA in my analysis about credit risk. I have 11000 obs and I've chosen age and income to develop the analysis. I don't know exactly how to interpret the R ...
Dalila's user avatar
  • 181
4 votes
2 answers
5k views

R - "CAPdiscrim" and "lda" error "variable 1 appears to be constant within groups"

so I've been trawling through existing questions for solutions to this one, but to no avail. I have a dataset consisting of individuals (117), each with an observation from a different variable (12), ...
Aaarrrgh's My Game's user avatar
4 votes
0 answers
643 views

Why do LDA returns only 1 column in sklearn/Python?

The following code print "X type", type(X_all2) print "X shape", np.shape(X_all2) print "Y type", type(y_all2) print "Y shape", np.shape(y_all2) y_all2 = np.reshape(y_all2, (395, 1)) print "Y type"...
Dims's user avatar
  • 49.2k
3 votes
1 answer
20k views

How to perform prediction with LDA (linear discriminant) in scikit-learn?

I've been testing out how well PCA and LDA works for classifying 3 different types of image tags I want to automatically identify. In my code, X is my data matrix where each row are the pixels from an ...
Jack Simpson's user avatar
  • 1,681
3 votes
1 answer
7k views

Plot boundary lines between classes in python based on multidimensional data?

I am trying to plot boundary lines of Iris data set using LDA in sklearn Python based on this documentation. For two dimensional data, we can easily plot the lines using LDA.coef_ and LDA.intercept_....
Luxi's user avatar
  • 31
3 votes
3 answers
15k views

R Error : some group is too small for 'qda'

I used the MASS::qda() to find the classfier for my data and it always reported `some group is too small for 'qda' Is it due to the size of test data I used for model ? I increased the test sample ...
user2993059's user avatar
3 votes
2 answers
1k views

difference between sklearn.lda.LDA() and sklearn.discriminant_analysis.LinearDiscriminantAnalysis()

In duration of reading about LinearDiscriminantAnalysis using python , I had got two different methods to implement it which are available here , http://scikit-learn.org/stable/modules/generated/...
Shubham Sharma's user avatar
3 votes
0 answers
118 views

How can I plot a histogram on rotated axis in projection space (LDA)

I used the mean separation criterion (find parameter w that maximizes distance between class means) as well as Fisher LDA to find a nice line to separate two linearly separable classes. Then I plotted ...
dg_m87's user avatar
  • 67
3 votes
0 answers
352 views

Is it possible to get decision boundary equation for Quadratic Discriminant Analysis?

I use Python and sklearn packages. I used LDA for predictions and I can get the coefficients of the decision boundary. clf = LinearDiscriminantAnalysis(priors=[prob_norm, prob_anem]) clf.fit(X_train, ...
Arzental's user avatar
  • 103
3 votes
0 answers
1k views

sklearn LDA: difference between coef_ and scalings_?

I'm new to LDA. The documentation isn't very clear - what's the difference between coef_ and scalings_? My data has many features (F1, F2, ..., F10000) and some labeled classes (C1, C2, ..., C5). I ...
Ray Zhang's user avatar
  • 1,511
2 votes
2 answers
2k views

Subscript out of bounds while LDA analysis

I am trying to run linear discriminant analysis in R. My dataframe contains two groups of data with dimension of 102 and 24. I ran R-code as follows: mydata<-read.table() head(mydata) Factor ...
mohammad gerami's user avatar
2 votes
0 answers
109 views

Why are linear discriminant analysis in SPSS and Python not giving me the same results for coefficients?

Although the data I'm feeding into both SPSS and Python is identical, I'm getting different scores for eigenvalues and canonical discriminant function coefficients while tests of equality of group ...
mdiramali's user avatar
2 votes
1 answer
261 views

Apply PLSDA model to predict another data?

I am developing a discriminant model using PLSDA (mixOmics package, the model works well by external validations. To do external validation, I use the predict() function. However, suppose now I have ...
hn.phuong's user avatar
  • 835
2 votes
0 answers
306 views

MemoryError when shrinkage=true for LinearDiscriminantAnalysis

The rest of the scenarios the algorithm works well apart from setting the shrinkage parameter. In order to improve the accuracy of the algorithm I am using various techniques. In the scikit document ...
aja's user avatar
  • 35
1 vote
2 answers
4k views

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 ...
Schatzi121's user avatar
1 vote
1 answer
48 views

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 ...
user2352714's user avatar
1 vote
1 answer
541 views

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....
Leo's user avatar
  • 489
1 vote
1 answer
2k views

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....
Pollux's user avatar
  • 85
1 vote
1 answer
1k views

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. ...
Ben-Jamin-Griff's user avatar
1 vote
1 answer
818 views

Coefficients of the LDA using Matlab fitcdiscr

I'm using Matlab command fitcdiscr to implement an LDA with 379 features and 8 classes. I would like to get a global weight for each feature, to investigate their influence in the prediction. How can ...
Giulia's user avatar
  • 13
1 vote
1 answer
841 views

Comparing test performances

I'm trying to work with some data here and compare the test performance of glm and lda. The data is attached here. This is my general plan to try to do both of these: training = read.csv("train....
J. P.'s user avatar
  • 289
1 vote
1 answer
483 views

R console gives output regardless of error, but Shiny app does't due to error. How can I bypass the error in the Shiny app?

When I run the code below in the R console, I get the following error in line 10: "Error in lda.default(x, grouping, ...) : variables 5 6 appear to be constant within groups" However the rest of ...
Anuraag's user avatar
  • 11
1 vote
0 answers
46 views

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 =...
user4891693's user avatar
1 vote
1 answer
159 views

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. ...
GiulioGCantone's user avatar
1 vote
0 answers
76 views

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 ...
mg332842's user avatar
1 vote
0 answers
153 views

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 ...
Sara's user avatar
  • 11
1 vote
0 answers
1k views

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 ...
Vitalii's user avatar
  • 51
1 vote
0 answers
157 views

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 ...
Sean's user avatar
  • 617
1 vote
1 answer
79 views

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 ...
MiraculicKz's user avatar
1 vote
3 answers
3k views

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's user avatar
1 vote
1 answer
2k views

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 ...
Jens's user avatar
  • 8,762
1 vote
0 answers
1k views

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 ...
Anna's user avatar
  • 49
1 vote
1 answer
1k views

Canonical Discriminant Function in Python sklearn

I am learning about Linear Discriminant Analysis and am using the scikit-learn module. I am confused by the "coef_" attribute from the LinearDiscriminantAnalysis class. As far as I understand, these ...
SPL's user avatar
  • 11
1 vote
1 answer
635 views

What kind of LDA performs 'fitcdiscr' function?

I know that the new fitcdiscr MATLAB® function can perform several discriminant analysis, such as LDA or QDA. However, the mentions about 'regularization' and 'bayesian' inside the MATLAB® help ...
Víctor Martínez's user avatar
1 vote
1 answer
3k views

How to plot MASS:qda scores

From this question, I was wondering if it's possible to extract the Quadratic discriminant analysis (QDA's) scores and reuse them after like PCA scores. ## follow example from ?lda Iris <- data....
M. Beausoleil's user avatar
1 vote
0 answers
340 views

R coefficients in linear versus flexible discriminant function analysis

I am trying to understand flexible discriminant function analysis and specifically the "fda" command in the "mda" package in R. My understanding is that the default method is a simple linear ...
Julie L's user avatar
  • 761
1 vote
0 answers
277 views

How to reconstruct data from projections obtained with Linear Discriminant Analysis

I am trying to reconstruct data from the projections obtained with LDA. The idea would be to evaluate the reconstruction errors obtained from reduced sets of LDA factors. In the following matlab code, ...
acadela's user avatar
  • 11
0 votes
2 answers
707 views

Possible to force logistic regression or other classifier through specific probability?

I have a data set with a binary variable[Yes/No] and a continuous variable (X). I'm trying to make a model to classify [Yes/No] X. From my data set, when X = 0.5, 48% of the observations are Yes. ...
MLEN's user avatar
  • 2,182
0 votes
1 answer
85 views

Making 3D plot of data with LDA boundary

I am playing around with linear discriminant analysis and trying to plot the data in plotly in R and then plot the discriminating plane. When I try this I can get the data and the plane, but the ...
gunsnfloyd's user avatar
0 votes
1 answer
788 views

LDA accuracy is higher for reduced dataset than for original

I'm trying to reduce a dataset with LDA. I expect that on reduced dataset I will have less accuracy. However, depending on the random seed I get sometimes the reduced version is giving me higher ...
Sergey Ivanov's user avatar
0 votes
1 answer
31 views

Problem with column names in a function in R when running linear discriminant analysis (lda)

This is my dataset of example, where column D is the factor one. df <- data.frame(A=1:10, B=2:11, C=3:12, D="A") df[6:10, 4] <- "B" When I run a lda, it works nice: model &...
antecessor's user avatar
  • 2,732
0 votes
1 answer
104 views

Classification problem error using linear discriminant analysis

Hi am trying to implement the LInear Discriminant Analysis module for a project but am getting stuck here is the git repo : linear discriminant analysis: linear discriminant analysis the code : ...
PX374's user avatar
  • 31
0 votes
1 answer
511 views

NotImplementedError: shrinkage not supported

I'm running this code and I got an error witht the fit function from sklearn.discriminant_analysis import LinearDiscriminantAnalysis lda = LinearDiscriminantAnalysis(shrinkage='auto') lda.fit(np....
Nathane Berrebi's user avatar
0 votes
1 answer
108 views

Finding the means of the three classes the data have been assigned to in LDA

I am looking at example code for how to calculate Fisher’s LDA, which is based on Q = W^{-1}B. The data is imported as follows: aircraft = read_csv(file = "aircraft.csv") %>% mutate( ...
The Pointer's user avatar
  • 2,296
0 votes
1 answer
379 views

How to Obtain Constant Term in Linear Discriminant Analysis

Consider dput: structure(list(REAÇÃO = structure(c(0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1), format.spss = "F11.0"), IDADE = ...
neves's user avatar
  • 737
0 votes
1 answer
237 views

Linear Discriminant Analysis requirements

I'm trying to analyse a sparse dataset using sklearn LDA (but not only that one, I've also tried a personal implementation). The dataset has 14 columns and some varying number of columns which I've ...
Sergio HL's user avatar
0 votes
1 answer
1k views

How can I Plot the decision boundary of Fisher LDA in R?

I'm new to R and I have been trying to create Fisher LDA, but i'm having tough time getting around vectors and metrics in R. if some one could tell am I doing it right because i'm getting this error ...
Muhammed Eltabakh's user avatar
0 votes
1 answer
387 views

Incorrect number of dimensions when switching between 2 group and more than 2 group LDA in Shiny

I have been teaching myself how to make shiny apps to include wit research articles to make methods more available to practitioners. I am using shiny to make a web app that does discriminant function ...
Michael Kenyhercz's user avatar