From a2305c0a23cf32112f68bec0ec15ae3ab32a8bdc Mon Sep 17 00:00:00 2001 From: franzi Date: Mon, 17 Oct 2022 19:17:05 +0200 Subject: [PATCH] fix minimize to work with tree models --- notebooks/5_quality_prediction.ipynb | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/notebooks/5_quality_prediction.ipynb b/notebooks/5_quality_prediction.ipynb index cb1ad97..94d0ec7 100644 --- a/notebooks/5_quality_prediction.ipynb +++ b/notebooks/5_quality_prediction.ipynb @@ -23,20 +23,11 @@ "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", - "from scipy.stats import pearsonr\n", "from scipy.optimize import minimize\n", "# machine learning stuff\n", "from sklearn.metrics import mean_absolute_error\n", "from sklearn.dummy import DummyRegressor\n", - "from sklearn.preprocessing import MaxAbsScaler\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", + "from sklearn.model_selection import train_test_split\n", "# interactive plotting (parallel coordinate plot)\n", "import plotly.express as px\n", "# suppress unnecessary warnings\n", @@ -350,7 +341,7 @@ " # the start value for the optimization is the original water content.\n", " # to get realistic values, we additionaly specify bounds\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", " water_new = res.x[0]\n", " # check the final strength prediction\n",