Skip to content

model.score does not work with WeakPDELibrary #155

Closed
@BMP-TUD

Description

@BMP-TUD

Hi, I noticed that when I want to analyse spatiotemporal data set with a weak pde formulation, the application of the score function does not work well, as it states a problem of dimensions of the predicted data. Here is an excerpt of the error message. In my analysis i attempted to use a data of spatial dims 300x300 and 50 time points with two variables --> u=array of 300,300,50,2.

error_pred=model.score(u)
Traceback (most recent call last):

  File "C:\Users\u0149745\AppData\Local\Temp/ipykernel_12676/3774757058.py", line 1, in <module>
    error_pred=model.score(u, metric=abs_error)

  File "C:\Users\u0149745\Anaconda3\envs\spirals\lib\site-packages\pysindy\pysindy.py", line 799, in score
    x_dot_predict = self.model.predict(x)

  File "C:\Users\u0149745\Anaconda3\envs\spirals\lib\site-packages\sklearn\utils\metaestimators.py", line 113, in <lambda>
    out = lambda *args, **kwargs: self.fn(obj, *args, **kwargs)  # noqa

  File "C:\Users\u0149745\Anaconda3\envs\spirals\lib\site-packages\sklearn\pipeline.py", line 469, in predict
    Xt = transform.transform(Xt)

  File "C:\Users\u0149745\Anaconda3\envs\spirals\lib\site-packages\pysindy\feature_library\weak_pde_library.py", line 473, in transform
    x = check_array(x)

  File "C:\Users\u0149745\Anaconda3\envs\spirals\lib\site-packages\sklearn\utils\validation.py", line 794, in check_array
    raise ValueError(

ValueError: Found array with dim 4. Estimator expected <= 2.

If I modify the data to estimate the score for the time series of one point, the error message is as follows:

error_pred=model.score(u[100,100,:,:])
Traceback (most recent call last):

  File "C:\Users\u0149745\AppData\Local\Temp/ipykernel_12676/1236244835.py", line 1, in <module>
    error_pred=model.score(u[100,100,:,:])

  File "C:\Users\u0149745\Anaconda3\envs\spirals\lib\site-packages\pysindy\pysindy.py", line 799, in score
    x_dot_predict = self.model.predict(x)

  File "C:\Users\u0149745\Anaconda3\envs\spirals\lib\site-packages\sklearn\utils\metaestimators.py", line 113, in <lambda>
    out = lambda *args, **kwargs: self.fn(obj, *args, **kwargs)  # noqa

  File "C:\Users\u0149745\Anaconda3\envs\spirals\lib\site-packages\sklearn\pipeline.py", line 469, in predict
    Xt = transform.transform(Xt)

  File "C:\Users\u0149745\Anaconda3\envs\spirals\lib\site-packages\pysindy\feature_library\weak_pde_library.py", line 492, in transform
    x_full = np.reshape(

  File "<__array_function__ internals>", line 180, in reshape

  File "C:\Users\u0149745\Anaconda3\envs\spirals\lib\site-packages\numpy\core\fromnumeric.py", line 298, in reshape
    return _wrapfunc(a, 'reshape', newshape, order=order)

  File "C:\Users\u0149745\Anaconda3\envs\spirals\lib\site-packages\numpy\core\fromnumeric.py", line 57, in _wrapfunc
    return bound(*args, **kwds)

ValueError: cannot reshape array of size 200 into shape (1,300,300,50,2)

Interestingly, this works perfectly fine, if I apply the normal PDE library on the same data set. Can you give me a hint where the problem could lay?

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions