Skip to content

Commit

Permalink
Start working on tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
ExcaliburZero committed Nov 30, 2016
1 parent b4f3630 commit f85d2d5
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 0 deletions.
Binary file added images/binary_classifier.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 114 additions & 0 deletions tutorials/Binary Classifier.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Binary Classifier\n",
"Binary Classifiers are the most basic part of the framework. Each Binary Classifier represents a single classification function.\n",
"\n",
"<img src=\"../images/binary_classifier.png\" width=\"60%\" />\n",
"\n",
"## Structure\n",
"Binary Classifiers contain a single classifying function and have a unique name. The classifiying function must take in a list of Observation objects and return a probability.\n",
"\n",
"```\n",
"[Observation] -> Float\n",
"```\n",
"\n",
"The classifying function should process the given observations in order to get a probability value. The Binary Classifier class will be able to take the probability value and observation data and construct a Result object based on it.\n",
"\n",
"Additionally, each Binary Classifier should be given a unique name to make it identifiable in the results.\n",
"\n",
"## Examples\n",
"A Binary Classifier can be created by specifying a name and classifying function. This example uses a simple classification function which sums the light values of the given observations, takes the reminder of dividing the sum by 10, and divides that remainer by 10 to get a probability value."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from lsstbroker import binary_classifier\n",
"\n",
"def classifying_function(obs):\n",
" values = [o.light for o in obs]\n",
" avg = sum(values)\n",
" prob = (avg % 10) / 10\n",
" return prob\n",
"\n",
"name = \"C-00001\"\n",
"bc = binary_classifier.BinaryClassifier(name, classifying_function)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Once a Binary Classifier has been created, Observation objects can then be run against it to generate the results of the processing."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"('LSST-00001A', 0.7, 'C-00001', 0)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from lsstbroker import observation\n",
"\n",
"object_name = \"LSST-00001A\"\n",
"observation1 = observation.Observation(object_name, 0.5, 42, 0.005)\n",
"observation2 = observation.Observation(object_name, 0.7, 51, 0.005)\n",
"observations = [observation1, observation2]\n",
"\n",
"bc.run(observations)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
49 changes: 49 additions & 0 deletions tutorials/Introduction.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Introduction\n",
"The LSST Event Broker is a Python framework for developing astronomical data classification systems.\n",
"\n",
"## Tutorials\n",
"* [Binary Classifier](Binary Classifier.ipynb)\n",
"* Classifier\n",
"* Classifier Box\n",
"* Handler\n",
"* Example System"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 1
}

0 comments on commit f85d2d5

Please sign in to comment.