From 55e2f82aef27779b8cc3c2b566538fce02bf96cc Mon Sep 17 00:00:00 2001 From: Thierry Moudiki Date: Tue, 6 Feb 2024 01:10:42 +0100 Subject: [PATCH] add notebook --- ...i_20240206_tuning_BCN_classifier_Pt2.ipynb | 103 +++++++++++++----- 1 file changed, 73 insertions(+), 30 deletions(-) diff --git a/GPopt/demo/thierrymoudiki_20240206_tuning_BCN_classifier_Pt2.ipynb b/GPopt/demo/thierrymoudiki_20240206_tuning_BCN_classifier_Pt2.ipynb index 2ba0c7d..a25ce60 100644 --- a/GPopt/demo/thierrymoudiki_20240206_tuning_BCN_classifier_Pt2.ipynb +++ b/GPopt/demo/thierrymoudiki_20240206_tuning_BCN_classifier_Pt2.ipynb @@ -12,21 +12,19 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "id": "cxJzB_Pwry-O" + }, "outputs": [], "source": [ - "!pip uninstall -y BCN GPopt " + "!pip uninstall -y BCN GPopt" ] }, { "cell_type": "code", "execution_count": null, "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "L7dr5u5k8hW9", - "outputId": "f26bd34b-d73b-4fee-b97a-3df46a0d8018" + "id": "L7dr5u5k8hW9" }, "outputs": [], "source": [ @@ -37,11 +35,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "IBA5fko_BA4V", - "outputId": "122f3221-2fb1-409e-c4e8-17d9d1d8709c" + "id": "IBA5fko_BA4V" }, "outputs": [], "source": [ @@ -79,7 +73,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "id": "LIGGEBbxCznR" }, @@ -90,7 +84,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": { "id": "fIgPu1vBAd7X" }, @@ -151,11 +145,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "dU2gF9rYC_Q_", - "outputId": "600a5854-6c32-4603-d8b4-d4c0d4a44263" + "id": "dU2gF9rYC_Q_" }, "outputs": [], "source": [ @@ -174,20 +164,73 @@ }, { "cell_type": "code", - "execution_count": null, + "source": [ + "print(res_opt.best_score)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "7xw2ii1auV6N", + "outputId": "050fce15-672d-466d-eb51-595b24d0bfad" + }, + "execution_count": 19, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "-0.9857142857142858\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "res_opt.best_params[\"B\"] = int(res_opt.best_params[\"B\"])\n", + "res_opt.best_params[\"nu\"] = 10**res_opt.best_params[\"nu\"]\n", + "res_opt.best_params[\"lam\"] = 10**res_opt.best_params[\"lam\"]\n", + "res_opt.best_params[\"r\"] = 1 - 10**res_opt.best_params[\"r\"]\n", + "res_opt.best_params[\"tol\"] = 10**res_opt.best_params[\"tol\"]\n", + "res_opt.best_params[\"col_sample\"] = np.ceil(res_opt.best_params[\"col_sample\"])\n", + "res_opt.best_params[\"n_clusters\"] = np.ceil(res_opt.best_params[\"n_clusters\"])" + ], "metadata": { - "id": "zo4LTC_PDEGp" + "id": "sddAUZp5tEGw" }, - "outputs": [], + "execution_count": 20, + "outputs": [] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "id": "zo4LTC_PDEGp", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "0361a23c-ff05-4eb2-f4d4-6ed4f3ea5ed4" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + " |======================================================================| 100%\n", + "\n", + " Elapsed: 0.3253192901611328\n", + "\n", + "\n", + " Test set accuracy: 1.0\n", + "\n", + " Elapsed: 0.0092620849609375\n" + ] + } + ], "source": [ "start = time()\n", - "estimator = bcn.BCNClassifier(B=int(parameters[0][0]),\n", - " nu=10**parameters[0][1],\n", - " lam=10**parameters[0][2],\n", - " r=1-10**parameters[0][3],\n", - " tol=10**parameters[0][4],\n", - " col_sample=np.ceil(parameters[0][5]),\n", - " n_clusters=np.ceil(parameters[0][6]),\n", + "estimator = bcn.BCNClassifier(**res_opt.best_params,\n", " activation=\"tanh\",\n", " type_optim=\"nlminb\").fit(X_train, y_train)\n", "print(f\"\\n Elapsed: {time() - start}\")\n", @@ -220,4 +263,4 @@ }, "nbformat": 4, "nbformat_minor": 0 -} +} \ No newline at end of file