Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

predict method doesn't correctly form basis matrix #13

Open
bmeyers opened this issue Dec 2, 2024 · 1 comment
Open

predict method doesn't correctly form basis matrix #13

bmeyers opened this issue Dec 2, 2024 · 1 comment

Comments

@bmeyers
Copy link
Member

bmeyers commented Dec 2, 2024

The predict method uses default setting when extending the basis matrix to new times. So, when using a "standing wave" dictionary, the method does not construct the correct extension.

Fix: have constructor read all kwargs from init method, e.g., standing_wave.

@bmeyers
Copy link
Member Author

bmeyers commented Dec 2, 2024

Trying to transform data outside the training window, when using a standing wave basis:

spq2.inverse_transform(new_data, new_ix + len(transform2))

Results in the following error:

Cell In[55], line 1
----> 1 plt.plot(spq2.inverse_transform(new_data, new_ix + len(transform2)))

File [~/Documents/github/spcqe/src/spcqe/quantiles.py:287](http://localhost:8889/lab/tree/covariance_matrices/~/Documents/github/spcqe/src/spcqe/quantiles.py#line=286), in SmoothPeriodicQuantiles.inverse_transform(self, X, y)
    285 # get correct basis matrix and quantile estimates for time period of prediction
    286 if y is not None:
--> 287     new_quantiles = self.predict(y)
    288 else:
    289     new_quantiles = self.fit_quantiles

File [~/Documents/github/spcqe/src/spcqe/quantiles.py:172](http://localhost:8889/lab/tree/covariance_matrices/~/Documents/github/spcqe/src/spcqe/quantiles.py#line=171), in SmoothPeriodicQuantiles.predict(self, X, y)
    170 newb = self.extend_basis(np.max(time_index) + 1)
    171 newb = newb[time_index]
--> 172 newq = newb @ self.fit_parameters
    173 newq = np.sort(newq, axis=1)
    174 return newq

ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 112 is different from 217)```

Method works correctly when new index is inside old index range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant