olivertomic / hoggorm

Explorative multivariate statistics in Python
BSD 2-Clause "Simplified" License
81 stars 26 forks source link

PLSR ValueError #18

Closed ViesLink closed 5 years ago

ViesLink commented 6 years ago

First of all, thanks to you guys for organizing such a useful and lightweight algorithm package. In program PCA, it works perfectly。

The problem appears in PLSR,I got matrix A (shape(96, 158)) as arrX and matrix B (shape(96, 1)) as arrY. When I run code like ‘model = ho.nipalsPLS1(arrX=mathdata, vecy=value, numComp=4, Xstand=False, )’, I got error ‘ValueError: shapes (96,1,4) and (4,1,158) not aligned: 4 (dim 2) != 1 (dim 1)’。

My operating environment is win7 + Anaconda(python3.6)

I hope this situation can be resolved as soon as possible。 THX again.

olivertomic commented 6 years ago

No worries. Glad you found hoggorm useful so far. And sorry about the late reply ... drowning in work. Could you copy and paste the full error message for me? I could not reproduce the error with my own data.

ViesLink commented 5 years ago

Hi, Sorry about the late reply ,drowning in work too.

I have tried to import data from .csv(I used to import data from .mat(matlab data format))after that,and no errors have occurred,I don't know why there is such a difference. Anyway,it works(Modeling).

Apart from this,is there any function that can be used directly for prediction?I did not find related information in the help documentation.

olivertomic commented 5 years ago

Hi,

thank you for your feedback. If the error should occur again, I'd be very thankful if you could send me the error message. Using numpy.freeze (https://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.squeeze.html) at the place where the error occurs should fix the problem.

There is indeed a class method (function) that you can use for prediction. It is Y_predict(). You can find it here: http://hoggorm.readthedocs.io/en/latest/plsr.html#hoggorm.plsr1.nipalsPLS1.Y_predict

Thanks again for reporting back.