Hello all !
I have an optimization problem, namely I have several input variables(x_1, x_2, x_3, x_4,x_5) and one output variable (y_total).
I have a black box function here, that is I have the input and output variables but do not have the model which gives me this output value.
It holds:
y_1 = 2 * x_1 + 5
y_2 = -2 * x_2 + 5
y_3 = 0.8* x_3 - 6
y_total = y_1 + y_2 + y_3
Start parameters:
x_1 = 120
x_2 = 30
x_3 = 4
For this example we have y_total = 2 * 120 + 5 + -2 * 30 + 5 + 0.8* - 6 = = 185,2
How can I use python to find out what are my optimal coefficients(x_1, x_2, x_3,) to get y_total = 500 as the result?
This is what I did so far:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
Loading data
data = pd.read_csv("...")
data = pd.DataFrame(data)
Input variables
x = data.iloc[0:,0:5]
x = np.array(x)
#output (y_total = 100)
y = data.iloc[0:,5:6]
y = np.array(y)
split training test
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test=train_test_split(x,y,test_size=0.3, random_state=False)
Building the model
from sklearn.linear_model import LinearRegression
model = LinearRegression()
model.fit(x_train, y_train)
Apply trained model to make prediction
y_pred = model.predict(x_test)
print(y_pred)
print('Coefficients:', model.coef_)
But here I only get coefficients of 0 (do anyone know why?).
I once read something about hyperparameter tuning, but I don't know how it could fit to my problem.
Can anyone recommend me what optimization should I use to solve my problem?
Many thanks !