[BUG] MASE transform and fit separation
dokato opened this issue · comments
Expected Behavior
I can call fit
and then transform
on MASE object.
Actual Behavior
MASE works when I use the fit_transform
method. When I try to generate separate embeddings for my individual graphs it fails with a quite not intuitive error.
Example Code
# this works
Vhat = embedder.fit_transform(adj_list)
# this doesn't
embedder = MASE(n_components=5)
embedder.fit(adj_list)
embedder.transform(adj_list[0])
Full Traceback
---------------------------------------------------------------------------
NotFittedError Traceback (most recent call last)
/var/folders/zt/s4rb4_kj4pnbmcqw7xyw52hw0000gn/T/ipykernel_19051/4212279286.py in <module>
----> 1 embedder.transform(pass_to_ranks(conn_mats[0]))
~/projects/graspologic/graspologic/embed/base.py in transform(self, X)
305
306 # checks
--> 307 check_is_fitted(self, "is_fitted_")
308 if isinstance(X, nx.classes.graph.Graph):
309 X = import_graph(X)
~/anaconda3/envs/grasp2/lib/python3.9/site-packages/sklearn/utils/validation.py in check_is_fitted(estimator, attributes, msg, all_or_any)
1343
1344 if not fitted:
-> 1345 raise NotFittedError(msg % {"name": type(estimator).__name__})
1346
1347
NotFittedError: This MultipleASE instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator.
At first I thought that MASE
fit
method just lacks
self.is_fitted_ = True
line. But then I noticed that whole _compute_oos_prediction
abstract method is not implemented here.
Isn't that just as simple as in ASE? I.e.:
return X @ Vhat
Not sure @bdpedigo if this is what you referred to in our email conversation as a "tricky part"?
Your Environment
- Python version: 3.9.7
- graspologic version: 1.0.0
you are correct, because of some changes to the base class a separate fit/transform was added when it should not have been (see #797)
a transform (for new graph(s)) could absolutely be implemented. I can show you how to do it given a network and the V matrices (or it may be mentioned in the original paper) if having a transform is important for your application. And we could totally add it to graspologic as well, but we'd just need to sketch out an API for it.