Skip to content

Commit

Permalink
Merge pull request #4 from lincc-frameworks/awo/scaffolding-for-extra…
Browse files Browse the repository at this point in the history
…ctor-and-classifier

Rough scaffolding for feature extractor and classifier.
  • Loading branch information
drewoldag authored Dec 4, 2024
2 parents 5501825 + a5c8d38 commit 50234fd
Show file tree
Hide file tree
Showing 23 changed files with 47,223 additions and 110 deletions.
145 changes: 145 additions & 0 deletions Using_RESSPECT_Walkthrough.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "3d07c5ba-09e5-4d50-ad87-07dcd0f481f0",
"metadata": {},
"outputs": [],
"source": [
"# https://resspect.readthedocs.io/en/latest/"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dab55b9a-e3dd-4e87-b849-fa5a62b36989",
"metadata": {},
"outputs": [],
"source": [
"from resspect import fit_snpcc"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "88c74cf5-bfe5-4685-9335-bdfe8c63f051",
"metadata": {},
"outputs": [],
"source": [
"path_to_data_dir = 'data/SIMGEN_PUBLIC_DES/' # raw data directory \n",
"features_file = 'results/Malanchev.csv' # output file \n",
"feature_extractor = 'malanchev'\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "360ecf08-9c52-4075-8617-4deb1959bb94",
"metadata": {},
"outputs": [],
"source": [
"fit_snpcc(path_to_data_dir=path_to_data_dir, features_file=features_file, feature_extractor=feature_extractor)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9df62bef-2588-4fd4-8039-41cfd9bb91bc",
"metadata": {},
"outputs": [],
"source": [
"from resspect.learn_loop import learn_loop\n",
"\n",
"nloops = 1000 # number of iterations\n",
"method = 'malanchev' # only option in v1.0\n",
"ml = 'RandomForest' # classifier\n",
"strategy = 'UncSampling' # learning strategy\n",
"input_file = 'results/Malanchev.csv' # input features file\n",
"metric = 'results/metrics.csv' # output metrics file\n",
"queried = 'results/queried.csv' # output query file\n",
"train = 'original' # initial training\n",
"batch = 1 # size of batch\n",
"\n",
"learn_loop(nloops=nloops, features_method=method, classifier=ml,\n",
" strategy=strategy, path_to_features=input_file, output_metrics_file=metric,\n",
" output_queried_file=queried, training=train, batch=batch)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ef3b8d05-d53c-402b-836c-f5b6a2efc0f4",
"metadata": {},
"outputs": [],
"source": [
"nloops = 1000 # number of iterations\n",
"method = 'malanchev' # only option in v1.0\n",
"ml = 'RandomForest' # classifier\n",
"strategy = 'RandomSampling' # learning strategy\n",
"input_file = 'results/Malanchev.csv' # input features file\n",
"metric = 'results/metrics_random.csv' # output metrics file\n",
"queried = 'results/queried_random.csv' # output query file\n",
"train = 'original' # initial training\n",
"batch = 1 # size of batch\n",
"\n",
"learn_loop(nloops=nloops, features_method=method, classifier=ml,\n",
" strategy=strategy, path_to_features=input_file, output_metrics_file=metric,\n",
" output_queried_file=queried, training=train, batch=batch)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3ffa34f1-64f5-46ea-93f7-f8935cba1cc6",
"metadata": {},
"outputs": [],
"source": [
"from resspect.plot_results import Canvas\n",
"\n",
"# define parameters\n",
"path_to_files = ['results/metrics.csv','results/metrics_random.csv']\n",
"strategies_list = ['UncSampling', 'RandomSampling']\n",
"output_plot = 'plots/metrics.png'\n",
"\n",
"#Initiate the Canvas object, read and plot the results for\n",
"# each metric and strategy.\n",
"cv = Canvas()\n",
"cv.load_metrics(path_to_files=path_to_files,\n",
" strategies_list=strategies_list)\n",
"cv.set_plot_dimensions()\n",
"cv.plot_metrics(output_plot_file=output_plot,\n",
" strategies_list=strategies_list)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1f88d53b-1591-4aed-8ee1-35904d8b23b2",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
3 changes: 2 additions & 1 deletion docs/notebooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Notebooks

.. toctree::

Introducing Jupyter Notebooks <notebooks/intro_notebook>
Load pre-trained models <notebooks/use_resspect_to_load_pretrained_model>
Use LAISS in RESSPECT <notebooks/use_resspect_learn_loop_with_laiss>
25 changes: 0 additions & 25 deletions docs/notebooks/README.md

This file was deleted.

Loading

0 comments on commit 50234fd

Please sign in to comment.