I'm trying to use Canonical Correlation Analysis (CCA) in scikit-learn. Still, I'm getting a TypeError, which asserts inverse_transform() takes 2 positional arguments but 3 were given.
Here is my code:
from sklearn.ensemble import RandomForestRegressor
from sklearn.cross_decomposition import CCA
from sklearn.model_selection import RandomizedSearchCV
mycca = CCA(n_components=4)
mycca.fit(x, y)
x, y = mycca.transform(x, y)
x_test = mycca.transform(x_test)
parameters = {
'n_estimators': [50 , 100, 200, 300],
'max_depth': [3, 5, 6 ,8 , 9 ,10]
}
modell = RandomForestRegressor(max_leaf_nodes=2)
modell = RandomizedSearchCV(modell,
param_distributions=parameters,
cv=5,
n_iter=10,
n_jobs=-1
)
modell.fit(x , y)
predicted = modell.predict(x_test).flatten()
mycca.inverse_transform(x_test, predicted)
And the last line throws a TypeError:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-34-7d035a65b067> in <module>
----> 1 mycca.inverse_transform(x_test, predicted)
TypeError: inverse_transform() takes 2 positional arguments but 3 were given
It's ridiculous since I passed two arguments exactly, named x_test and predicted. If you're curious about shape of x_test and predicted:
>>>x_test.shape, predicted.shape
((1, 4), (4,))
>>>x_test, predicted
(array([[-0.36689807, -0.03637745, 0.1099326 , -0.22595879]]),
array([-0.02223153, -0.11932753, 0.08806947, -0.0044004 ]))
How to fix this?

