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 parameters. What is wrong in the following code? This is the code I am using:
import numpy as np
from scipy.optimize import curve_fit
# Define your custom exponential equation
def custom_exponential_equation(X, param1, param2, param3):
# X is a 2D array with shape (N, 2), where N is the number of data points
# X[:, 0] corresponds to the first independent variable
# X[:, 1] corresponds to the second independent variable
y = param1 * np.exp(param2 * (X[:, 0]* (X[:, 1]**param3))
return y
initial_params = [1.0, 1.0, 1.0]
# Perform the curve fitting
params, _ = curve_fit(custom_exponential_equation, x1, y1, p0=initial_params)
print(params)
The error message is:
Result from function call is not a proper array of floats.