fix in PCALR

This commit is contained in:
Alejandro Moreo Fernandez 2021-06-11 10:52:30 +02:00
parent 3d544135f1
commit 2586e6ed7d
2 changed files with 7 additions and 2 deletions

View File

@ -14,6 +14,7 @@ Do we want to cover cross-lingual quantification natively in QuaPy, or does it m
Current issues:
==========================================
SVMperf-based learners do not remove temp files in __del__?
In binary quantification (hp, kindle, imdb) we used F1 in the minority class (which in kindle and hp happens to be the
negative class). This is not covered in this new implementation, in which the binary case is not treated as such, but as
an instance of single-label with 2 labels. Check

View File

@ -26,8 +26,10 @@ class PCALR(BaseEstimator):
def fit(self, X, y):
self.learner.fit(X, y)
self.pca = TruncatedSVD(self.n_components).fit(X, y)
# embedded = self.pca.transform(X)
nF = X.shape[1]
self.pca = None
if nF > self.n_components:
self.pca = TruncatedSVD(self.n_components).fit(X, y)
self.classes_ = self.learner.classes_
return self
@ -40,4 +42,6 @@ class PCALR(BaseEstimator):
return self.learner.predict_proba(X)
def transform(self, X):
if self.pca is None:
return X
return self.pca.transform(X)