Skip to content
Advertisement

Constrained Multi-Linear Regression using Gekko

I have a multilinear regression problem where I have the prior information about the range of the output (dependent variable y) – The prediction must always lie in that range.

I want to find the coefficients (upper and lower bound) of each feature (independent variables) in order to make the linear regression model restricted to the desired range of output.

For example, I want to apply this solution on sklearn.datasets.load_boston where I know that the price of the house will be in the range of [10, 40] (the actual min and max values of y are [5,50]).

In the following example, my objective is 10 < yp < 40 and based on this I want to find the min and max bound of all the coefficients

JavaScript

The listed code either gives me a solution not found error. Can you point out what I’m doing wrong here, or am I missing something important? Also, how can I get both the Upper and Lower bound of c for all independent variables?

Advertisement

Answer

Try IMODE=2 for regression mode. There are a few modifications such as x[:,i] to load the data and ci.LOWER=0 as the lower bounds and ci.UPPER=1 as the upper bound.

JavaScript

The solution to this constrained problem is obtained with the IPOPT or APOPT (slightly faster).

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement