diff --git a/.gitignore b/.gitignore index 1fe62cb..14e6d03 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,62 @@ -bin/ -local/ -include/ -share/ -lib/ -*~ -*.pyc -classification-hourlyResultsAll.txt -*.csv -*.msg -datasets/ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python env/ -.ipynb_checkpoints -MANIFEST build/ +develop-eggs/ dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Project development +.idea/ +ignore/ +venv/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f3b493a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,28 @@ +language: python +sudo: false + +cache: + directories: + - "~/.cache/pip" + +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - libfreetype6-dev + - libatlas-dev + - gfortran + +python: + - 2.7 + +install: + - pip install pip setuptools wheel --upgrade + - pip install -e .\[dev\] + +script: + - python -c "import vessel_scoring" + +after_success: + - coveralls || echo "!! intermittent coveralls failure" diff --git a/README.md b/README.md index 482c860..9fe305f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +[![Build Status](https://travis-ci.org/GlobalFishingWatch/vessel-scoring.svg?branch=master)](https://travis-ci.org/GlobalFishingWatch/vessel-scoring) + +[![Coverage Status](https://coveralls.io/repos/github/GlobalFishingWatch/vessel-scoring/badge.svg?branch=master)](https://coveralls.io/github/GlobalFishingWatch/vessel-scoring?branch=master) + # About This repository contains fishing scoring heuristics and evaluation of their effectiveness, as well as development of supervised-ML scoring algorithms. diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 5ef7a86..0000000 --- a/requirements.txt +++ /dev/null @@ -1,40 +0,0 @@ -Jinja2==2.8 -MarkupSafe==0.23 -Pygments==2.0.2 -backports-abc==0.4 -backports.ssl-match-hostname==3.5.0.1 -certifi==2015.11.20.1 -cycler==0.9.0 -decorator==4.0.6 -functools32==3.2.3-2 -ipykernel==4.2.2 -ipython==4.0.1 -ipython-genutils==0.1.0 -ipywidgets==4.1.1 -jsonschema==2.5.1 -jupyter==1.0.0 -jupyter-client==4.1.1 -jupyter-console==4.0.3 -jupyter-core==4.0.6 -matplotlib==1.5.0 -mistune==0.7.1 -nbconvert==4.1.0 -nbformat==4.0.1 -notebook==4.0.6 -numpy==1.10.2 -path.py==8.1.2 -pexpect==4.0.1 -pickleshare==0.5 -ptyprocess==0.5 -pyparsing==2.0.7 -python-dateutil==2.4.2 -pytz==2015.7 -pyzmq==15.1.0 -qtconsole==4.1.1 -simplegeneric==0.8.1 -singledispatch==3.4.0.3 -six==1.10.0 -terminado==0.6 -tornado==4.3 -traitlets==4.0.0 -gpsdio==0.0.7 diff --git a/setup.py b/setup.py index 9f25e40..916c69b 100644 --- a/setup.py +++ b/setup.py @@ -42,8 +42,11 @@ def run(self): packages=[ 'vessel_scoring', ], - package_data={'vessel_scoring': ['models/*']}, - install_requires=["numpy", "scikit_learn", "scipy", "matplotlib", "ipython"], + package_data={ + 'vessel_scoring': ['models/*']}, + install_requires=["numpy", "scikit-learn", "scipy", "rolling_measures"], + extras_require={ + 'dev': ['matplotlib', 'ipython', 'coveralls']}, version='1.0', author='Egil Moeller, Timothy Hochberg', author_email='egil@skytruth.org, tim@skytruth.org', diff --git a/vessel_scoring/evaluate_model.py b/vessel_scoring/evaluate_model.py index 86ff37c..cfbef1f 100644 --- a/vessel_scoring/evaluate_model.py +++ b/vessel_scoring/evaluate_model.py @@ -1,9 +1,5 @@ -import matplotlib.pyplot as plt from vessel_scoring import utils -import numpy as np from sklearn import metrics -from IPython.core.display import display, HTML - def train_model(model, train_data): @@ -22,12 +18,17 @@ def train_model(model, train_data): # TODO break this into a plotting and a text part def evaluate_model(model, test_data, name=None): - """Plot some graphs and compute some metrics on a model + """Plot some graphs and compute some metrics on a model. Requires + matplotlib and IPython. model - a trained model test_data - data to use on the evalutions """ + + import matplotlib.pyplot as plt + from IPython.core.display import display, HTML + is_fishy = utils.is_fishy(test_data) score = model.predict_proba(test_data)[:,1] @@ -91,6 +92,7 @@ def convert_range(ax_f): overlap = total - non_overlap error = overlap / total + def compare_models(models, test_data): is_fishy = utils.is_fishy(test_data)