Questions tagged [scipy-optimize]

Tag used for questions regarding minimizing or maximizing objective functions with python module `scipy.optimize`. Also add more generic tags to your question (`python`, `scipy`)

Module SciPy optimize is used for minimizing (or maximizing) objective functions. It includes solvers for nonlinear problems, linear programming, constrained and nonlinear least-squares, root finding and curve fitting.

1017 questions
0
votes
0 answers

Can't construct constraints (of scipy.optimize.minimize) with append

To resolve a quadratic minimum problem I used scipy.Optimize.Minimize. First I initialize my function and some points : def func(x): return 1/4*(x[0]**2+x[1]**2) + x[2] P1=[] for i in range(3): P1.append((rd.uniform(-1,1),…
0
votes
0 answers

optimize a function with two bounded matrices as inputs

I am trying to optimise a loss function which takes two inputs "m, d" as inputs. Both of these are (32, 32, 1) matrices. I am not able to figure out how to bound/constrain their values between 0 and 1. "m, d" are filters that I apply to some input…
Shantnav
  • 105
  • 1
  • 7
0
votes
2 answers

basinhopping_bounds() got an unexpected keyword argument 'f_new'

I'm getting this error when using basin-hopping: basinhopping_bounds() got an unexpected keyword argument 'f_new' I'm trying to implement the analysis of X,F models in Python to solving a DTLZ7 problem. So, I've started with a problem with 4 linear…
0
votes
0 answers

When using sigma to force fit at certain points using curve_fit, I don't know what points I am actually fitting through

I am fitting my data with a polynomial with curve_fit. I have forced the fit to go through certain data points, but I actually don't know what those points are. If this is my fitting function: popt, pcov = curve_fit(func3, xdata1, ydata1, p0=(1,…
D.Kim
  • 151
  • 3
  • 10
0
votes
1 answer

A problem with optimization of function that contains loops

I have a problem with optimizing of a function that contains loops. I start with paricular lista=[0.002,0.006,0.003,0.02,0.008,0.006,0.05] of floats and the intervals `(0,k*0.0025),(0.005,k*0.005),(0.005,k*0.0125), where upper border depends. So,…
0
votes
1 answer

callback function throws a error in scipy.optimize.minimize class

I am using scipy.minimize for an optimization problem. This is my code import numpy as np from scipy.optimize import minimize from scipy.optimize import Bounds #bounds = Bounds([25, 36], [26,…
0
votes
1 answer

scipy.optimize.minimum with 'trust-constr' gives different optimal values with different initial values

I am using scipy library for an optimization problem. My objective function is a SVR regressor. Different initial values give different optimal values. why is it? import numpy as np from scipy.optimize import minimize from scipy.optimize import…
chink
  • 1,505
  • 3
  • 28
  • 70
0
votes
2 answers

How to get optimized parameters using curve_fit for two independent variables?

I want to do curve fitting for two independent paramaters x and y.And I want to optimize my parameters a,b and c. I have tried optimizing my parameters using curve_fit in scipy. But my parameters are not getting optimized. I used the following…
0
votes
1 answer

How to differentiate keyword args in least_squares() function?

I have a function of four input variables which I am trying to minimize using the Levenburg-Marquardt optimization method. The previous results where the Hessian/Gradient is calculated using Forward Difference Approximation wasn't accurate enough…
0
votes
1 answer

Optimize changing variables to get max Pearson's correlation coefficient for multiple columns

Amendment: If I have a pandas DataFrame that includes 5 columns Col1 & Col2 & Col3 & Col4 & Col5 and I need to get max Pearson's correlation coefficient between(Col2,Col3) & (Col2,Col4) & (Col2,Col5) by considering the values in Col1 The modified…
Sidhom
  • 935
  • 1
  • 8
  • 15
0
votes
1 answer

Can python optimize a variable to get max Pearson's correlation coefficient?

If I have pandas dataframe includes 3 columns Col1 & Col2& Col3 and I need to get max Pearson's correlation coefficient between Col2 and Col3 By considering the values in Col1 where the modified values For Col2 obtained by the next…
Sidhom
  • 935
  • 1
  • 8
  • 15
0
votes
1 answer

Scipy.optimize.curve_fit does not fit

Say I want to fit a sine function using scipy.optimize.curve_fit. I don't know any parameters of the function. To get the frequency, I do Fourier transform and guess all the other parameters - amplitude, phase, and offset. When running my program, I…
DenGor
  • 205
  • 7
  • 18
-1
votes
0 answers

Problem with optimizing a value function featuring integrals and fractional powers using Scipy quad and optimize

I am trying to run a dynamic optimization with Scipy, that features a definite integral with fixed bounds. However, the optimization fails to send back any value for my objective function, and report two issues (detailed report below) : Roundoff…
GaL
  • 21
  • 3
-1
votes
2 answers

How to optimise equation parameters in python?

I am trying to fit a custom equation to a dataset with 1 dependent variable (y1 - 1D numpy float array with 45 entries) and two independent variables (x1 - 2D numpy float array with 45 entries). I am trying to get the optimized values of the…
Deep Roy
  • 7
  • 1
-1
votes
1 answer

I am optimizing f(x) using scipy.optimize.minimize and the value of f(x) cannot be negative but scipy.optimize returns a min value as negative

The minimized function value of f(x) should be greater than or equal to 0. However, scipy.optimize.minimize provides a negative value of f(x). Is there any way we could put a constraint on the function value?