Code Monkey home page Code Monkey logo

bayesicfitting's Issues

Fitter fails with error when using weights

I am trying to fit a polynomial model of order 2 to data with weights. The .fit() fails with the following error:

ValueError: Length of passed values is 3, index implies 189.
The size of each x, y and weights is 189. As far as I can tell, the error is in getHessian() method.

A simple notebook with demonstration of the problem is available here, the data file used in the notebook is here.

Let me know if you have problems accessing the code and the datafile.

Tests failed :: TypeError: calling <class 'BayesicFitting.source.kernels.Uniform.Uniform'>

Hi,

During packing your project for Guix I faced with this issue in tests:

Traceback (most recent call last):
  File "/tmp/guix-build-python-bayesicfitting-3.0.1.drv-0/BayesicFitting-3.0.1/setup.py", line 9, in <module>
    setup(
  File "/gnu/store/7my837qpak6w6vk8ifd99d24kmgjyp61-python-setuptools-64.0.3/lib/python3.9/site-packages/setuptools/__init__.py", line 87, in setup
    return distutils.core.setup(**attrs)
  File "/gnu/store/7my837qpak6w6vk8ifd99d24kmgjyp61-python-setuptools-64.0.3/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 185, in setup
    return run_commands(dist)
  File "/gnu/store/7my837qpak6w6vk8ifd99d24kmgjyp61-python-setuptools-64.0.3/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
    dist.run_commands()
  File "/gnu/store/7my837qpak6w6vk8ifd99d24kmgjyp61-python-setuptools-64.0.3/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 973, in run_commands
    self.run_command(cmd)
  File "/gnu/store/7my837qpak6w6vk8ifd99d24kmgjyp61-python-setuptools-64.0.3/lib/python3.9/site-packages/setuptools/dist.py", line 1217, in run_command
    super().run_command(command)
  File "/gnu/store/7my837qpak6w6vk8ifd99d24kmgjyp61-python-setuptools-64.0.3/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 992, in run_command
    cmd_obj.run()
  File "/gnu/store/7my837qpak6w6vk8ifd99d24kmgjyp61-python-setuptools-64.0.3/lib/python3.9/site-packages/setuptools/command/test.py", line 224, in run
    self.run_tests()
  File "/gnu/store/7my837qpak6w6vk8ifd99d24kmgjyp61-python-setuptools-64.0.3/lib/python3.9/site-packages/setuptools/command/test.py", line 227, in run_tests
    test = unittest.main(
  File "/gnu/store/mhdb6jc5ilr43mxx1zqkbwj5gj7jq6wp-python-3.9.9/lib/python3.9/unittest/main.py", line 100, in __init__
    self.parseArgs(argv)
  File "/gnu/store/mhdb6jc5ilr43mxx1zqkbwj5gj7jq6wp-python-3.9.9/lib/python3.9/unittest/main.py", line 124, in parseArgs
    self._do_discovery(argv[2:])
  File "/gnu/store/mhdb6jc5ilr43mxx1zqkbwj5gj7jq6wp-python-3.9.9/lib/python3.9/unittest/main.py", line 244, in _do_discovery
    self.createTests(from_discovery=True, Loader=Loader)
  File "/gnu/store/mhdb6jc5ilr43mxx1zqkbwj5gj7jq6wp-python-3.9.9/lib/python3.9/unittest/main.py", line 154, in createTests
    self.test = loader.discover(self.start, self.pattern, self.top)
  File "/gnu/store/mhdb6jc5ilr43mxx1zqkbwj5gj7jq6wp-python-3.9.9/lib/python3.9/unittest/loader.py", line 349, in discover
    tests = list(self._find_tests(start_dir, pattern))
  File "/gnu/store/mhdb6jc5ilr43mxx1zqkbwj5gj7jq6wp-python-3.9.9/lib/python3.9/unittest/loader.py", line 405, in _find_tests
    tests, should_recurse = self._find_test_path(
  File "/gnu/store/mhdb6jc5ilr43mxx1zqkbwj5gj7jq6wp-python-3.9.9/lib/python3.9/unittest/loader.py", line 483, in _find_test_path
    tests = self.loadTestsFromModule(package, pattern=pattern)
  File "/gnu/store/7my837qpak6w6vk8ifd99d24kmgjyp61-python-setuptools-64.0.3/lib/python3.9/site-packages/setuptools/command/test.py", line 57, in loadTestsFromModule
    tests.append(self.loadTestsFromName(submodule))
  File "/gnu/store/mhdb6jc5ilr43mxx1zqkbwj5gj7jq6wp-python-3.9.9/lib/python3.9/unittest/loader.py", line 191, in loadTestsFromName
    return self.loadTestsFromModule(obj)
  File "/gnu/store/7my837qpak6w6vk8ifd99d24kmgjyp61-python-setuptools-64.0.3/lib/python3.9/site-packages/setuptools/command/test.py", line 57, in loadTestsFromModule
    tests.append(self.loadTestsFromName(submodule))
  File "/gnu/store/mhdb6jc5ilr43mxx1zqkbwj5gj7jq6wp-python-3.9.9/lib/python3.9/unittest/loader.py", line 191, in loadTestsFromName
    return self.loadTestsFromModule(obj)
  File "/gnu/store/7my837qpak6w6vk8ifd99d24kmgjyp61-python-setuptools-64.0.3/lib/python3.9/site-packages/setuptools/command/test.py", line 57, in loadTestsFromModule
    tests.append(self.loadTestsFromName(submodule))
  File "/gnu/store/mhdb6jc5ilr43mxx1zqkbwj5gj7jq6wp-python-3.9.9/lib/python3.9/unittest/loader.py", line 211, in loadTestsFromName
    raise TypeError("calling %s returned %s, not a test" %
TypeError: calling <class 'BayesicFitting.source.kernels.Uniform.Uniform'> returned Uniform: 1 if |x| < 1 else 0, not a test

Combined model behavior and VoigtModel

Hello,

I'm trying to use BayesicFitting in spectrum analysis. The model contains several (many) Voigt profiles and coded as VoigtModel() + VoigtModel() + .... The model also has one more model of Astropy model type. But it seems that combined model recognize only one VoitModel + Astropy Model. Moreover, I cannot specify parameters for VoigtModel (although in help there's a statement that I can do it via model.setParameters). What am I doing wrong?

compiling error

Hi Do,

I'm still working on getting everything installed. During installation I'm getting a few python errors:

file: OrderEngine.py, line 98: command is unfinished
file:FrogEngine.py", line 149: indx = []S SyntaxError: invalid syntax

finally I'm getting the following error message during installation:

Searching for python>=3.5
Reading https://pypi.python.org/simple/python/
No local packages or working download links found for python>=3.5
error: Could not find suitable distribution for Requirement.parse('python>=3.5')

However, my python version is 3.6!

lastly, it would be great if the relevant files would be copied to the "site-packages" directory of my python installation. Then you do not need to add anything to the python path.

Again, thanks,
VT

"from FitPlot import plotFit" in example notebooks

Hi,
I'm getting an error that in some example notebooks the following routine could not be found:

from FitPlot import plotFit

I could find plotFit in source/Plotter.py, however, the keyword "ftr" was missing.
Thank you,
VT

Is a 4 parameter logistic model possible?

Hello! For my research I'm trying to using a Bayesian approach to fit my dataset with a sigmoid model and have had success using your 3-parameter logistic function (LogisticModel()). I'd like to add a parameter to allow for an asymmetric sigmoid by raising the denominator to the power of p_4:

y = p_1 / ( 1 + exp( ( p_2 - x )/p_3 ) )**p_4

Is there a way to alter the 3-parameter LogisticModel() to incorporate this or otherwise create a new model class that has a parameter for asymmetry?

Thank you for you help!

bspline missing from setup.py

I installed BayesicFitting from pypi in a fresh conda environment (Python=3):
conda create --name bayesPython3 python=3 astropy matplotlib numpy scipy ipython conda activate bayesPython3 pip install BayesicFitting

This leads to a corrupted installation:
` (bayesPython3) michaelm@lin-migo-1:~$ ipython
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import BayesicFitting

ModuleNotFoundError Traceback (most recent call last)
in ()
----> 1 import BayesicFitting

~/bin/anaconda2_v5.1/envs/bayesPython3/lib/python3.6/site-packages/BayesicFitting/init.py in ()
27 from .source.AnnealingAmoeba import AnnealingAmoeba
28 from .source.ArctanModel import ArctanModel
---> 29 from .source.BSplinesModel import BSplinesModel
30 from .source.BaseFitter import BaseFitter
31 from .source.BaseModel import BaseModel

~/bin/anaconda2_v5.1/envs/bayesPython3/lib/python3.6/site-packages/BayesicFitting/source/BSplinesModel.py in ()
4 # import (modified) bspline from Juha Jeronen
5 from . import bspline
----> 6 from . import splinelab
7
8 from .LinearModel import LinearModel

~/bin/anaconda2_v5.1/envs/bayesPython3/lib/python3.6/site-packages/BayesicFitting/source/splinelab.py in ()
18 import numpy as np
19
---> 20 import bspline
21
22

ModuleNotFoundError: No module named 'bspline' `

This is an issue with setup.py: the line for bspline is commented out.

Stay tuned for a (pretty trivial) pull request.

NeuralNetModel not found at package import

I just installed BayesicFitting and tried to import it in my python 3.7 interactive session:

(works) xmmm24: BayesicFitting $ ipython
Python 3.7.4 (default, Aug 13 2019, 15:17:50) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import BayesicFitting                                                                                           
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-389169ef999f> in <module>
----> 1 import BayesicFitting

~/miniconda3/envs/works/lib/python3.7/site-packages/BayesicFitting-2.5.0-py3.7.egg/BayesicFitting/__init__.py in <module>
     96 from .source.MultipleOutputProblem import MultipleOutputProblem
     97 from .source.NestedSampler import NestedSampler
---> 98 from .source.NeuralNetModel import NeuralNetModel
     99 from .source.NoiseScale import NoiseScale
    100 from .source.NonLinearModel import NonLinearModel

ModuleNotFoundError: No module named 'BayesicFitting.source.NeuralNetModel'

In [2]:                                                                                                                 

I cannot find a file called NeuralNetModel in sources, so I had to comment this line in __init__.py and re-install the package again, in order to have it working.

#from .source.NeuralNetModel import NeuralNetModel

[Feature Request] Correlated errors in X- and Y-

Hello, Do.

I just came across your very nice package and paper, and am still digesting the large amount of material here. In my main field, mass spectrometry, it often happens that we need to fit data with correlated errors in X and Y, such as a 3-isotope plot of X/Z vs. Y/Z, where X, Y, and Z are isotopes of the same element. For linear fits there are simple equations to find the best fit line, as described by York & Evensen (2004) https://doi.org/10.1119/1.1632486, but the situation is more complicated for higher order polynomials, exponentials, and the like.

I looked at your ErrorsInXandYProblem, but it seems that the weights are only defined in the Y-direction. Would you have any thoughts regarding the implementation of a method that accepts X-weights and correlations between X- and Y-uncertainties?

Thank you.

Can't import BayesicFitting: No module named 'BayesicFitting.source.CrossEngine'

import BayesicFitting results in error message

`---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
in
----> 1 import BayesicFitting

~/anaconda3/envs/miricle.test/lib/python3.8/site-packages/BayesicFitting/init.py in
47 from .source.ConstantModel import ConstantModel
48 from .source.ConvergenceError import ConvergenceError
---> 49 from .source.CrossEngine import CrossEngine
50 from .source.CurveFitter import CurveFitter
51 #from .source.CyclicResults import CyclicResults

ModuleNotFoundError: No module named 'BayesicFitting.source.CrossEngine'`

This is under BayesicFitting 2.7.0 installed via pip

Tag style issue with v.3.2.1

Hi,

While refreshing astronomical packages for Guix, I encountered an issue
where the recently applied tag v.3.2.1 does not style others, causing problems
with refreshing the version downstream.

I wondering if it may updated?

Thanks,
Oleg

UserModel does not work for multiple dimensions

Trying to create a UserModel for two-dimensional xdata causes a problem:

import numpy as np
import BayesicFitting
from BayesicFitting import UserModel, Fitter

def fitfunc(x, p):

    return x[:,0]*p[0] + x[:,1]*p[1] + p[2]

# Make 10 random 2-dimensional points
x = np.random.rand(10,2)

# Make fake data + noise
p = np.array([1,2,3])
cleandata = fitfunc(x, p)
noisedata = cleandata * np.random.normal(1, 0.05, x.shape[0])

# Find model parameters from noisy data
model = UserModel(len(p), fitfunc, ndim=2)
fitter = Fitter(x, model)
param = fitter.fit(noisedata)

Results in

ValueError: Model (1) and xdata (2) must be of the same dimensionality.

Also, checking model.ndim immediately after creation (with ndim=2) shows that ndim=1.

Hardcoded number of cycles for Monte Carlo

The number of cycles for Monte Carlo calculation (file MonteCarlo.py) of the confidence interval is currently hardcoded in the class to 25. Maybe it would be better to have this as an input parameter the user can change, if necessary.

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.