gemelli icon indicating copy to clipboard operation
gemelli copied to clipboard

Misorder labels from contructed tensor after tensor factorization

Open lam-c opened this issue 4 years ago • 0 comments

Hey @cameronmartino, @gwarmstrong, Thanks for this awesome tool.

I was concerned about the sorting procedure for loadings when fitting tensor factorization, would it cause misorder of loading labels in the label step?

Codes of sorting procedure excerpted from factorization.py line 219 - 224 in _fit function

# save array of loadings for subjects
self.subjects = loads[0].copy()
self.subjects = self.subjects[self.subjects[:, 0].argsort()]
# save array of loadings for features
self.features = loads[1].copy()
self.features = self.features[self.features[:, 0].argsort()]

Codes of labeling step excerpted from factorization.py since line 335 in label function

# DataFrame single non-condition dependent loadings
self.subjects = pd.DataFrame(self.subjects,
                             columns=self.biplot_labels,
                             index=construct.subject_order)  # self.subjects reordered, but construct.subject_order didn't
self.features = pd.DataFrame(self.features,
                             columns=self.biplot_labels,
                             index=construct.feature_order)  # self.features reordered, but construct.feature_order didn't
......

lam-c avatar Jan 18 '21 07:01 lam-c