Giter VIP home page Giter VIP logo

stochopy's Introduction

Hello there ๐Ÿ‘‹

Python Fortran

I'm Keurfon Luu. I am currently a geoscientist at INTERA and a Lawrence Berkeley National Laboratory affiliate. Despite my academic background in geophysics/seismology, I am enthused by open source software development and share most of the scientific codes I develop. In that regard, I am doing my best to develop user-friendly yet numerically efficient codes that everyone can use.

Don't hesitate to check out my pinned repositories to see which of my projects are the most popular and why so!

stochopy's People

Contributors

keurfonluu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

stochopy's Issues

IndexError: boolean index did not match indexed array along dimension 1

Thank you. I encountered the following problem.
Traceback (most recent call last):
File " in
ea.optimize(solver = "cpso", sync = True)
File "/site-packages/stochopy/evolutionary_algorithm.py", line 293, in optimize
xstart = xstart, sync = sync)
File "/stochopy/evolutionary_algorithm.py", line 755, in _cpso
pbest[idx] = np.array(X[idx])
IndexError: boolean index did not match indexed array along dimension 1; dimension is 80 but corresponding boolean dimension is 1

The execution is as follows

 func = "rastrigin"
# mpi_comm = MPI.COMM_WORLD
# mpi_rank = mpi_comm.Get_rank()    
n_dim = 80 
popsize = 4 + np.floor(3.*np.log(n_dim))

lower = np.full(n_dim, -40)
upper = np.full(n_dim, -20)

# Initialize solver; calc_cost calculates the residual after running a FEM problem.
ea = Evolutionary(calc_cost, lower = lower, upper = upper, eps1 = 1e-2, popsize = popsize,  max_iter = 2000, mpi = False, random_state = -1)

# Solve
starttime = time()
ea.optimize(solver = "cpso", sync = True)    
print(ea)
print("Elapsed time: %.2f seconds" % (time() - starttime))

Using scipy's DE genetic algorithm for initial parameter estimation in non-linear regression

I see you have written optimization code using Python and Differential Evolution. Scipy has solvers for non-linear equations, however scipy's default initial parameter values are all 1.0. This can be suboptimal, and in more complex equations often results in the algorithms finding a local minimum in error space. For this reason, the authors of scipy added the Differential Evolution genetic algorithm for initial parameter estimation for use in optimization. The module is named scipy.optimize.differential_evolution.

Because their implementation uses the Latin Hypercube algorithm to ensure a thorough search of parameter space, this particular scipy module requires parameter bounds.

I have used scipy's Differential Evolution genetic algorithm to determine initial parameters for fitting a double Lorentzian peak equation to Raman spectroscopy data of carbon nanotubes and found that the results were excellent. The GitHub project, with a test spectroscopy data file, is:

https://github.com/zunzun/RamanSpectroscopyFit

My background is in nuclear engineering and industrial radiation physics, and I love Python, so if you have any questions please let me know.

James Phillips

cannot import name 'Evolutionary' from 'stochopy'

Hi keurfonluu,

Thank you for sharing such a wonderful package!

I try to use the your dispersion inversion code, and find that there is a problem with:
from stochopy import Evolutionary
ImportError: cannot import name 'Evolutionary' from 'stochopy' (~/.conda/envs/pg/lib/python3.8/site-packages/stochopy/__init__.py)

I installed evodcinv with pip. and the version of stochopy is (2.0.1)

Do you know where this problem might come from?

Thanks in advance.

Kind regards,
Wen

Can this be used for hyper-parameters?

Hi.
Can stochOpy be used for hyper-parameters just like in the Bayesian-Optimization package?
For example I want to find the optimal C parameter from SVR regression sklearn that can minimize MAE objective function.
So the example is as follows:

dicts={'params':{'C':[-1e3,1e3]}}
def MAE_func(**param):
    model.set_params(**param)
    model.fit(train, y_train)
 
cv = Evolutionary(MAE_func,lower=lower,upper=upper,max_iter = 200,snap = True)
xopt, gfit = cv.optimize(solver = "cpso")

But it returns an error:

File "/home/lemma/train.py", line 1998, in optimize_genetic1
xopt, gfit = cv.optimize(solver = "cpso")
File "/home/lemma/Evo.py", line 279, in optimize
xstart = xstart, sync = sync)
File "/home/lemma/Evo.py", line 666, in _cpso
pfit = self._eval_models(X)
File "/home/lemma/Evo.py", line 306, in _eval_models
fit_mpi[i] = self._func(self._unstandardize(models[i,:]))
File "/home/lemma/Evo.py", line 78, in
self._func = lambda x: func(x, *args, **kwargs)
TypeError: fun() takes exactly 0 arguments (1 given)

Not sure what went wrong with this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.