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- number of row in a dataframe 
Python :: convert every element in list to string python 
Python :: windows alert python 
Python :: source code of Tortoise and hare algorithm in python 
Python :: how to read a pkl file in python 
Python :: how to reverse array in ruby 
Python :: from PyQt5 import Qsci 
Python :: how to get iheight in pyqt5 
Python :: change the color of the button on hovering tkinter 
Python :: python loop through list 
Python :: how to run a function in interval in python 
Python :: rename columns in datarame pandas 
Python :: openpyxl change sheet name 
Python :: Pyo example 
Python :: get current directory python 
Python :: how to print a float with only 2 digits after decimal in python 
Python :: converting pandas._libs.tslibs.timedeltas.Timedelta to days 
Python :: all possible combinations of parameters 
Python :: why men are better than woman 
Python :: emoji in python 
Python :: activate venv enviroment 
Python :: Dummy or One Hot Encoding code with pandas 
Python :: python datetime to timestamp 
Python :: check date on template django 
Python :: python des 
Python :: how to sort in greatest to least python 
Python :: find angle mbc in python 
Python :: python execute file 
Python :: how to add row in spark dataframe 
Python :: how to stop python prompt 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =