Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions docs/demos/S-RerF/MNIST_classification_using_structured_RerF.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"train_samples = 5000\n",
"\n",
"# Load data from https://www.openml.org/d/554\n",
"X, y = fetch_openml('mnist_784', version=1, return_X_y=True)"
"X, y = fetch_openml('mnist_784', version=1, return_X_y=True)\n",
"y = y.astype(int)"
]
},
{
Expand Down Expand Up @@ -73,12 +74,12 @@
"output_type": "stream",
"text": [
"rerfClassifier(feature_combinations=1.5, image_height=None, image_width=None,\n",
" max_depth=None, max_features='auto', min_parent=1,\n",
" max_depth=None, max_features='auto', min_samples_split=1,\n",
" n_estimators=100, n_jobs=8, oob_score=False,\n",
" patch_height_max=None, patch_height_min=1, patch_width_max=None,\n",
" patch_width_min=1, projection_matrix='Base', random_state=None)\n",
"rerfClassifier(feature_combinations=1.5, image_height=28, image_width=28,\n",
" max_depth=None, max_features='auto', min_parent=1,\n",
" max_depth=None, max_features='auto', min_samples_split=1,\n",
" n_estimators=100, n_jobs=8, oob_score=False, patch_height_max=5,\n",
" patch_height_min=1, patch_width_max=5, patch_width_min=1,\n",
" projection_matrix='S-RerF', random_state=None)\n"
Expand Down Expand Up @@ -110,7 +111,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"run time rerf 0.7958900928497314\n"
"run time rerf 1.1266508102416992\n"
]
}
],
Expand All @@ -130,7 +131,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"run time s_rerf 3.6138932704925537\n"
"run time s_rerf 6.353916883468628\n"
]
}
],
Expand Down Expand Up @@ -158,10 +159,10 @@
}
],
"source": [
"train_acc_rerf = clf_rerf.score(X_train, y_train.astype(int))\n",
"train_acc_rerf = clf_rerf.score(X_train, y_train)\n",
"print(\"train_acc rerf\", train_acc_rerf)\n",
"\n",
"train_acc_s_rerf = clf_s_rerf.score(X_train, y_train.astype(int))\n",
"train_acc_s_rerf = clf_s_rerf.score(X_train, y_train)\n",
"print(\"train_acc s_rerf\", train_acc_s_rerf)"
]
},
Expand All @@ -176,18 +177,18 @@
"name": "stdout",
"output_type": "stream",
"text": [
"score rerf 0.9361\n",
"score s_rerf 0.9427\n"
"score rerf 0.9376\n",
"score s_rerf 0.9436\n"
]
}
],
"source": [
"# sparsity = np.mean(clf.coef_ == 0) * 100\n",
"score = clf_rerf.score(X_test, y_test.astype(int))\n",
"score = clf_rerf.score(X_test, y_test)\n",
"print(\"score rerf\", score)\n",
"\n",
"# sparsity = np.mean(clf.coef_ == 0) * 100\n",
"score = clf_s_rerf.score(X_test, y_test.astype(int))\n",
"score = clf_s_rerf.score(X_test, y_test)\n",
"print(\"score s_rerf\", score)"
]
}
Expand Down