Skip to content

Commit

Permalink
add notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
thierrymoudiki committed Feb 6, 2024
1 parent 4f2ccfd commit 55e2f82
Showing 1 changed file with 73 additions and 30 deletions.
103 changes: 73 additions & 30 deletions GPopt/demo/thierrymoudiki_20240206_tuning_BCN_classifier_Pt2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -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": [
Expand Down Expand Up @@ -79,7 +73,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {
"id": "LIGGEBbxCznR"
},
Expand All @@ -90,7 +84,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {
"id": "fIgPu1vBAd7X"
},
Expand Down Expand Up @@ -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": [
Expand All @@ -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",
Expand Down Expand Up @@ -220,4 +263,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}

0 comments on commit 55e2f82

Please sign in to comment.