Skip to content

Commit

Permalink
add google colab and github buttons to machine learning tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
ghernandez-57 committed May 16, 2024
1 parent d8c2de2 commit a88f67e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Machine Learning Tutorial

[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/danforthcenter/plantcv-tutorial-machine-learning/HEAD?labpath=index.ipynb)
<a target="_blank" href="https://colab.research.google.com/github/danforthcenter/plantcv-tutorial-machine-learning.git">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a>
[![Static Badge](https://img.shields.io/badge/Open%20on%20GitHub-black?logo=github)](https://github.com/danforthcenter/plantcv-tutorial-machine-learning.git)


The naive Bayes multiclass approach is an extension of the naive Bayes approach. It can be trained to output binary images given an input color image. Unlike the naive Bayes method, the naive Bayes multiclass approach can be trained to classify two or more classes, defined by the user. Additionally, the naive Bayes multiclass method is trained using colors sparsely sampled from images rather than the need to label all pixels in a given image.

Expand Down
43 changes: 38 additions & 5 deletions index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
"collapsed": true,
"jupyter": {
"outputs_hidden": true
}
},
"source": [
"# Machine Learning Tutorial \n",
Expand Down Expand Up @@ -43,6 +46,36 @@
"Once we have the `plantcv-train` output file, we can classify pixels in a color image in PlantCV. In the example image for this tutorial we have already collected pixels and created the probability density functions for each class. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"# Detect notebook environment\n",
"def detect_notebook_environment():\n",
" if 'COLAB_GPU' in os.environ:\n",
" print('Google Colaboratory detected.')\n",
" %pip install \"altair>=5\" ipympl plantcv\n",
" \n",
" # Give access and mount your Google Drive (need a Google Account)\n",
" from google.colab import drive\n",
" drive.mount('/content/gdrive')\n",
" \n",
" # Enable widget feature with matplotlib\n",
" from google.colab import output\n",
" output.enable_custom_widget_manager()\n",
" \n",
" #View working directory, may need to change\n",
" %pwd\n",
" else:\n",
" print('Binder detected.')\n",
"\n",
"environment = detect_notebook_environment()"
]
},
{
"cell_type": "code",
"execution_count": 11,
Expand Down Expand Up @@ -539,9 +572,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python (PlantCV 4)",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "plantcv4"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -553,9 +586,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}

0 comments on commit a88f67e

Please sign in to comment.