Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

lda scikit learn

import numpy as np
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
y = np.array([1, 1, 1, 2, 2, 2])
clf = LinearDiscriminantAnalysis()
clf.fit(X, y)

print(clf.predict([[-0.8, -1]]))
Comment

scikit learn lda

from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
lda = LDA(n_components = 2)
X_train = lda.fit_transform(X_train, y_train)
X_test = lda.transform(X_test)
Comment

PREVIOUS NEXT
Code Example
Python :: python nth prime function 
Python :: pyautogui press 
Python :: pyqt5 close event 
Python :: stop program python 
Python :: rnadom number python 
Python :: python tar a directory 
Python :: pandas convert entries in a column after groupby in list 
Python :: How to recursively sort the elements of a stack, in Python? 
Python :: decision tree regressor 
Python :: how to check type inside a list in python 
Python :: python get average of list 
Python :: initialize dictionary to zero in python 
Python :: transpose matrix numpy 
Python :: get just filename without extension from the path python 
Python :: if elseif in single line python 
Python :: function without return python 
Python :: palindrome string python 
Python :: sort a list numbers in python 
Python :: render template in django 
Python :: python allowed variable caracters 
Python :: 13 pseudo random numbers between 0 to 3 python 
Python :: python basic flask app 
Python :: pandas drop column in dataframe 
Python :: flask error 
Python :: how to remove a string inside another string python 
Python :: skip element in list comprehension 
Python :: Converting objects into integers 
Python :: df rename columns 
Python :: custom validation in django models 
Python :: does jupyter notebook need internet 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =