adapt icon indicating copy to clipboard operation
adapt copied to clipboard

Issue with FA.score "'FA' object has no attribute 'n_domains_'"

Open ymouad opened this issue 3 years ago • 1 comments


AttributeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_13888/463825728.py in 12 13 model_FE = FA(X_src, y_src, X_tgt_train, y_tgt_train) ---> 14 FE_scores.append(model_FE.score(X_tgt_test, y_tgt_test)) 15 C = model_FE.estimator_.coef_ 16 src_sumCoef.append( np.sum(np.abs(C[0:X_tgt_test.shape[1]])) )

~\anaconda3\lib\site-packages\adapt\base.py in score(self, X, y, sample_weight, domain) 713 ] 714 if "domain" in args: --> 715 X = self.transform(X, domain=domain) 716 else: 717 X = self.transform(X)

~\anaconda3\lib\site-packages\adapt\feature_based_fa.py in transform(self, X, domain) 224 X = check_array(X, allow_nd=True) 225 if domain in ["tgt", "target"]: --> 226 X_emb = np.concatenate((np.zeros((len(X), X.shape[-1]*self.n_domains_)), 227 X, 228 X),

AttributeError: 'FA' object has no attribute 'n_domains_'

ymouad avatar Apr 15 '22 16:04 ymouad

It seems that you forgot to use fit in line 13, it should be:

model_FE = FA(estimator=Ridge()).fit(X_src, y_src, X_tgt_train, y_tgt_train)

antoinedemathelin avatar Apr 25 '22 16:04 antoinedemathelin