lda scikit learn

Solutions on MaxInterview for lda scikit learn by the best coders in the world

showing results for - "lda scikit learn"
Ulysse
18 Sep 2019
1import numpy as np
2from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
3X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
4y = np.array([1, 1, 1, 2, 2, 2])
5clf = LinearDiscriminantAnalysis()
6clf.fit(X, y)
7
8print(clf.predict([[-0.8, -1]]))
Ida
19 Jul 2019
1from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
2lda = LDA(n_components = 2)
3X_train = lda.fit_transform(X_train, y_train)
4X_test = lda.transform(X_test)