Let’s say I have a set of input variables (
D) and I predict a target (
y) using a machine learning model (
XGBRegressor in my case) with a reasonable performance (5% relative error on test set).
from sklearn.datasets import make_regression import pandas as pd from xgboost import XGBRegressor X, y = make_regression(n_samples=500, n_features=4, n_informative=2, noise=0.3) X = pd.DataFrame(X, columns=['A', 'B', 'C', 'D']) model = XGBRegressor() model.fit(X, y)
Now, I want to do some kind of sensitivity analysis on this model by answering two questions:
What is the impact of a 5% independent increase in variables
D) on the target variable?
D; which combination of values of
D) increases the target
yvalue by 10, minimizing the sum of
I have already answered question one (see this gist). However, how can question 2 be coded? I imagine that this implies an optimization problem.