Questions tagged [scipy-optimize-minimize]

446 questions
2
votes
0 answers

Matlab fmincon equivalent in Python

I have a code in matlab and I want to convert it to python. The matlab code is as follows: options =…
2
votes
0 answers

Minimizing Least Squares Subject To Constraint

I am trying to rate NFL teams by minimizing the sum of squared errors subject to a constraint. My data looks like: dat = {"Home_Team": ["KC Chiefs", "LA Chargers", "Baltimore Ravens"], "Away_Team": ["Houston Texans", "Miami Dolphins", "KC…
2
votes
1 answer

Scipy function minimization

with the x1 and x2 dataframes being: alloc 0.400000 mean 0.000732 stdev 0.015961 rfr 0.000000 alloc 0.200000 mean 0.000957 stdev 0.016520 rfr 0.000000 def create_function_duo(x1df, x2df): def funct(xi): y=0 …
user3452643
  • 182
  • 1
  • 7
2
votes
1 answer

Resolved: Alternative to using Global Variable in Numba

I am currently using scipy minimize for my optimization problem but the compute time is significant. I came across numba which could be used to reduce the compute time. But when i try to use it over my objective function, it throws the following…
2
votes
0 answers

Scipy Optimizer cannot give the best result

I am trying to run a ipynb file which download the data from yahoo and run the scipy optimizer. My objective is to find the optimum weight allocation with the max sharpe ratio. Link for the ipynb :…
Po Steve
  • 21
  • 1
2
votes
1 answer

The minimize function of scipy.optimize doesn't give the right answer

I'm trying the solve a minimization problem using the minimize function of Scipy. The objective function is simply the ratio of two multivariate normal distributions with different mean and variance. I'm hoping to find the maximum of the function…
2
votes
0 answers

Scipy optimize minimize performs only 1 iteration

I 'am trying to optimize a function which takes an input list of weights and change pixels of images with those weights and then calculates some Score (NSS Score) . Our target is to find the best input weights that give the highest NSS Score . For…
2
votes
0 answers

How do you estimate the parameter error/uncertainties using the Nelder-Mead method in scipy.optimize.minimize using the final_simplex in the output

I am trying to estimate the error/uncertainties in the estimation of the power-law fitting parameters (m, n, b) of the form y = m(x-b)^n, which I fitted to a dataset. When I use the Nelder-Mead method from scipy.optimize.minimize I get a final…
2
votes
2 answers

scipy.optimize.minimize() constraints depend on cost function

I'm running a constrained optimisation with scipy.optimize.minimize(method='COBYLA'). In order to evaluate the cost function, I need to run a relatively expensive simulation to compute a dataset from the input variables, and the cost function is one…
Zak
  • 3,063
  • 3
  • 23
  • 30
2
votes
1 answer

scipy-optimize-minimize does not perform the optimization - CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL

I am trying to minimize a function defined as follows: utility(decision) = decision * (risk - cost) where variables take the following form: decision = binary array risk = array of floats cost = constant I know the solution will take the form…
2
votes
0 answers

What does the norm variable do in scipy.optimize.minimize BFGS

It the latest scipy 1.4.1 package we have the BFGS local minimization technique which has as a sub-parameter norm which is set to infinity, the doc says: norm : float Order of norm (Inf is max, -Inf is min). What does this mean? What values can…
2
votes
1 answer

scipy.optimize.minimize and Minuit returning initial guess value

I'm having trouble with scipy.minimize.optimize. Here is my code. from time import process_time import numpy as np from scipy.optimize import minimize class NMin(object): def __init__(self, error): self.error=error def func(self,…
gporta
  • 23
  • 3
2
votes
1 answer

Scipy Objective function

I am trying to convert my gurobi code into scipy but I am having trouble defining the objective function. When testing to see if I defined the function correctly I get the error: TypeError: 'float' object is not iterable The code is here: import…
the_dankest
  • 195
  • 3
  • 13
2
votes
2 answers

ValueError: tnc: invalid gradient vector from minimized function

I'm learning ML by myself, and I have an error when I try to code Logistic Regression in python.This is from Standford online course. I've tried many times, including change grad to grad.ravel()/grad.fatten(), but none of them worked. Input: import…
2
votes
1 answer

Custom convergence criterion in scipy optimise

I am optimising a function using scipy.optimize in the following manner: yEst=minimize(myFunction, y0, method='L-BFGS-B', tol=1e-6).x My problem is that I don't want to stop simply when the tolerance is less than a value (e.g. if on the nth…
JDoe2
  • 267
  • 1
  • 12