diff --git a/IME672_project/Proj.ipynb b/IME672_project/Proj.ipynb index 4444552..a693f09 100644 --- a/IME672_project/Proj.ipynb +++ b/IME672_project/Proj.ipynb @@ -3313,6 +3313,13 @@ "ridge_regressor.fit(x_train,y_train)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": 57, @@ -5641,6 +5648,103 @@ "print(\"\\nRMSE:\\n\",rmse_test,rmse_train)" ] }, + { + "cell_type": "code", + "execution_count": 80, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
BayesianRidge()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
" + ], + "text/plain": [ + "BayesianRidge()" + ] + }, + "execution_count": 80, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.linear_model import BayesianRidge\n", + "br_reg = BayesianRidge()\n", + "br_reg.fit(x_train,y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([1668.20495034, 1679.94492734, 913.64922033, ..., 1282.17224146,\n", + " 473.76584417, 1836.95624818])" + ] + }, + "execution_count": 83, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "br_reg.predict(x_test)" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([ 2.14911786e+03, 1.79137805e+02, 1.58422799e+03, -1.76336580e+03,\n", + " -2.06966485e+02, -9.64991490e+01, -3.59451467e+01, 1.20811300e+03,\n", + " 4.63318397e+02, -1.17801277e+02, -1.73995862e+02, -1.05291009e+02,\n", + " -1.45517075e+02, -4.08851312e+02, 1.73110503e+03, -1.37393040e+02,\n", + " -1.22026370e+02, -1.03060886e+02, -1.19399700e+02, -1.78063514e+02,\n", + " -1.16492327e+02, 2.76553693e-10, -1.45549124e+02, -3.52070971e+01,\n", + " -1.81655358e+02, -1.12378682e+02, -1.05109365e+02, -6.32679934e+01,\n", + " -1.20354808e+02, -1.21063182e+02, 2.35545128e+00, -1.03861844e+02,\n", + " -1.06205028e+02, -1.42506556e+02, -1.08923435e+02, 8.49374765e+00])" + ] + }, + "execution_count": 81, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "br_reg.coef_" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RMSE:\n", + " 490.458 491.25\n" + ] + } + ], + "source": [ + "y_pred_train = br_reg.predict(x_train)\n", + "y_pred = br_reg.predict(x_test)\n", + "rmse_test = float(format(np.sqrt(mean_squared_error(y_test, y_pred)),'.3f'))\n", + "rmse_train = float(format(np.sqrt(mean_squared_error(y_train, y_pred_train)),'.3f'))\n", + "print(\"\\nRMSE:\\n\",rmse_test,rmse_train)" + ] + }, { "cell_type": "code", "execution_count": null,