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

Is it possible to use the RSNNS library to perform RBF interpolation when the target output is longer than the input? #22

Open
Jsalas424 opened this issue May 26, 2023 · 6 comments

Comments

@Jsalas424
Copy link

Is it possible to use the RSNNS library to perform RBF interpolation when the target output is longer than the input?

There are 4 columns, "fitted" which stands for a value for each surf_x, surf_y, and surf_z value. surf_x etc. and all values of "outputs" all represent a coordinate in 3D space.

The goal is to use RBF interpolation to find the "fitted" value corresponding to the coordinates found in "outputs" where all values of surf_x in "inputs" can be found in column [,1] of "outputs".

library(RSNNS)

> dim(inputs)
[1] 2312    4

> head(inputs)
      fitted    surf_x    surf_y   surf_z
1 -2.0260418 -64.20550 -84.79310 219.4273
2  1.2358981 -67.00667 -79.65610 227.9487
3 -1.3667838 -62.88993 -86.83528 218.1500
4  0.1172459 -66.91177 -79.44738 227.0095
5  1.1278194 -67.30763 -80.56429 226.5518
6 -2.7412495 -62.88353 -85.40290 218.0784

> dim(outputs)
[1] 6971    3

> head(outputs)
        [,1]    [,2]    [,3]
[1,] -38.000 -41.794 180.858
[2,] -39.542 -50.167 175.664
[3,] -33.440 -56.959 173.340
[4,] -17.804 -60.643 181.561
[5,]  -8.156 -50.190 201.004
[6,] -23.019 -36.171 196.698

rbf_res <- RSNNS::rbf(x = inputs,
               y = outputs)

Error in checkInput(x, y) : nrows of 'x' and 'y' must match
@cbergmeir
Copy link
Owner

Hi, I'm not sure if I understand correctly what you try to do, but it seems this is a quite standard regression problem where what you call inputs is the training set and what you call outputs is a test set. Your actual inputs in training are surf_x, surf_y, and surf_z, and fitted is the target. Then, in testing, in your "outputs" dataset, you only have surf_x, surf_y, and surf_z and want to find the "fitted" values. So what you need is something like the following to train the model:

rbf_res <- RSNNS::rbf(x = inputs[,c("surf_x","surf_y","surf_z")],
               y = inputs[,"fitted"])

Then, to predict on your new data, you need:

res = predict(rbf_res, newdata=outputs)

Any particular reason to use RBF for this? Otherwise I'd use any standard Machine Learning algorithm like a random forest or so.

@Jsalas424
Copy link
Author

Jsalas424 commented May 30, 2023

@cbergmeir

Cubic RBF interpolation has been specifically validated for my goal: https://ieeexplore.ieee.org/document/5626616

Relevant excerpt:
image

I'm about to leave on an extended vacation and will test this when I return, thank you!

@cbergmeir
Copy link
Owner

Sure, give it a go and let me know if it works (or not).

@Jsalas424
Copy link
Author

Can this be used to fit a cubic or multiquadric RBF?

@cbergmeir
Copy link
Owner

It seems to have Multiquadratic, yes. Best you check in the SNNS Manual, page 175ff for the details: http://gentoo.osuosl.org/distfiles/SNNSv4.2.Manual.pdf

@cbergmeir
Copy link
Owner

There are some demos in RSNNS that should allow you to figure out how to use these parameters from SNNS in RSNNS. They are in the demo folder in the package.

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

2 participants