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", type(y_all2)
print "Y shape", np.shape(y_all2)
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
lda = LinearDiscriminantAnalysis(n_components=2)
X_r = lda.fit(X_all2, y_all2).transform(X_all2)
print "R type", type(X_r)
print "R shape", np.shape(X_r)
Returns following:
X type <type 'numpy.ndarray'>
X shape (395, 48)
Y type <type 'numpy.ndarray'>
Y shape (395,)
Y type <type 'numpy.ndarray'>
Y shape (395, 1)
R type <type 'numpy.ndarray'>
R shape (395, 1)
I.e. lda.fit()
returns 1 column despite it is said n_components=2
.
Why and how to force to return 2 columns?