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

Cross Validation or Optimization for EquivalentSources #543

Open
mdtanker opened this issue Nov 26, 2024 · 2 comments
Open

Cross Validation or Optimization for EquivalentSources #543

mdtanker opened this issue Nov 26, 2024 · 2 comments
Labels
enhancement Idea or request for a new feature

Comments

@mdtanker
Copy link
Member

Description of the desired feature:

Is there a reason there is no cross-validation equivalent for harmonica.EquivalentSources like there is for verde.SplineCV? I find myself quite often manually running cross-validations for the equivalent source parameters as shown in the Estimating damping and depth parameters user guide:

dampings = [0.01, 0.1, 1, 10,]
depths = [5e3, 10e3, 20e3, 50e3]

equivalent_sources = hm.EquivalentSources()

scores = []
for params in parameter_sets:
    equivalent_sources.set_params(**params)
    score = np.mean(
        vd.cross_val_score(
            equivalent_sources,
            coordinates,
            data.gravity_disturbance_mgal,
        )
    )
    scores.append(score)

It would be great to be able to instead use

eqs = hm.EquivalentSourcesCV(
    dampings=[0.01, 0.1, 1, 10,], 
    depths=[5e3, 10e3, 20e3, 50e3],
)

eqs.fit(coordinates, data.gravity_disturbance_mgal,)

Also, related to this verde issue; I have an equivalent function for performing an optimization for the optimal equivalent source parameters, instead of a grid-search which would be done with the above cross-validation.

Are you willing to help implement and maintain this feature?

Yes if there is enough interest to justify doing this.

@mdtanker mdtanker added the enhancement Idea or request for a new feature label Nov 26, 2024
@santisoler
Copy link
Member

Hi @mdtanker! I don't think there's any special reason besides that no one wrote such class.

Whenever I needed to do cross validation for eq sources I was doing the same thing as you. Maybe it would be nice to have a class for it instead.

I don' t have an immediate use for it, but if you want to code it, feel free to do so!

@mdtanker
Copy link
Member Author

mdtanker commented Dec 8, 2024

Ok good to know, I'll see if I can find some time to make a PR for hm.EquivalentSourcesCV.

Any thoughts on the optimization aspect of this? Same idea as fatiando/verde#474 where instead of a grid-search CV, we use a hyperparameter optimization where the users defines the number of trials and the max/min values of damping/depth.

I guess we should first implement the simple CV and then consider adding the optimization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Idea or request for a new feature
Projects
None yet
Development

No branches or pull requests

2 participants