mirror of
https://github.com/ArthurDanjou/ml_exercises.git
synced 2026-01-14 12:14:38 +01:00
fix minimize to work with tree models
This commit is contained in:
@@ -23,20 +23,11 @@
|
|||||||
"import numpy as np\n",
|
"import numpy as np\n",
|
||||||
"import pandas as pd\n",
|
"import pandas as pd\n",
|
||||||
"import matplotlib.pyplot as plt\n",
|
"import matplotlib.pyplot as plt\n",
|
||||||
"from scipy.stats import pearsonr\n",
|
|
||||||
"from scipy.optimize import minimize\n",
|
"from scipy.optimize import minimize\n",
|
||||||
"# machine learning stuff\n",
|
"# machine learning stuff\n",
|
||||||
"from sklearn.metrics import mean_absolute_error\n",
|
"from sklearn.metrics import mean_absolute_error\n",
|
||||||
"from sklearn.dummy import DummyRegressor\n",
|
"from sklearn.dummy import DummyRegressor\n",
|
||||||
"from sklearn.preprocessing import MaxAbsScaler\n",
|
"from sklearn.model_selection import train_test_split\n",
|
||||||
"from sklearn.pipeline import make_pipeline\n",
|
|
||||||
"from sklearn.linear_model import ElasticNetCV\n",
|
|
||||||
"from sklearn.svm import SVR\n",
|
|
||||||
"from sklearn.ensemble import RandomForestRegressor, StackingRegressor\n",
|
|
||||||
"from sklearn.model_selection import GridSearchCV, train_test_split\n",
|
|
||||||
"from sklearn import tree\n",
|
|
||||||
"from sklearn.inspection import plot_partial_dependence, permutation_importance\n",
|
|
||||||
"from sklearn.manifold import TSNE\n",
|
|
||||||
"# interactive plotting (parallel coordinate plot)\n",
|
"# interactive plotting (parallel coordinate plot)\n",
|
||||||
"import plotly.express as px\n",
|
"import plotly.express as px\n",
|
||||||
"# suppress unnecessary warnings\n",
|
"# suppress unnecessary warnings\n",
|
||||||
@@ -350,7 +341,7 @@
|
|||||||
" # the start value for the optimization is the original water content.\n",
|
" # the start value for the optimization is the original water content.\n",
|
||||||
" # to get realistic values, we additionaly specify bounds\n",
|
" # to get realistic values, we additionaly specify bounds\n",
|
||||||
" # based on the actual min/max values for the water content\n",
|
" # based on the actual min/max values for the water content\n",
|
||||||
" res = minimize(_loss_fun, np.array([water_org]), bounds=[(value_min, value_max)])\n",
|
" res = minimize(_loss_fun, np.array([water_org]), bounds=[(value_min, value_max)], method=\"Powell\")\n",
|
||||||
" # the optimized water content is stored in res.x (again a np.array)\n",
|
" # the optimized water content is stored in res.x (again a np.array)\n",
|
||||||
" water_new = res.x[0]\n",
|
" water_new = res.x[0]\n",
|
||||||
" # check the final strength prediction\n",
|
" # check the final strength prediction\n",
|
||||||
|
|||||||
Reference in New Issue
Block a user