├── docs └── .gitkeep ├── mlviz ├── test │ ├── __init__.py │ └── test_mlviz.py ├── sample.py └── __init__.py ├── requirements.txt ├── MANIFEST.in ├── CHANGES.md ├── CONTRIBUTING.md ├── setup.py ├── LICENSE.txt ├── mlviz.sublime-project ├── README.md └── Makefile /docs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mlviz/test/__init__.py: -------------------------------------------------------------------------------- 1 | """Tests for the `mlviz` package.""" 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | testpackage==2.26 2 | newrelic-plugin-agent==1.3.0 3 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include *.rst *.txt *.md 2 | recursive-include docs *.rst *.txt *.md 3 | graft */files 4 | graft */*/files 5 | -------------------------------------------------------------------------------- /CHANGES.md: -------------------------------------------------------------------------------- 1 | Changelog 2 | ========= 3 | 4 | 0.0.0 (2013/10/09) 5 | ------------------ 6 | 7 | - 8 | -------------------------------------------------------------------------------- /mlviz/sample.py: -------------------------------------------------------------------------------- 1 | """A sample module.""" 2 | 3 | 4 | def function(value): 5 | """A function with branches to demonstrate branch coverage reporting.""" 6 | if value is True: 7 | return 'True' 8 | elif value is False: 9 | return 'False' 10 | else: 11 | return 'None' 12 | -------------------------------------------------------------------------------- /mlviz/__init__.py: -------------------------------------------------------------------------------- 1 | """Package for mlviz.""" 2 | 3 | import sys 4 | 5 | __project__ = 'mlviz' 6 | __version__ = '0.0.0' 7 | 8 | VERSION = __project__ + '-' + __version__ 9 | 10 | PYTHON_VERSION = 2, 7 11 | 12 | if not sys.version_info >= PYTHON_VERSION: # pragma: no cover (manual test) 13 | exit("Python {}.{}+ is required.".format(*PYTHON_VERSION)) 14 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | For Contributors 2 | ================ 3 | 4 | Requirements 5 | ------------ 6 | 7 | * Make: 8 | * Windows: http://cygwin.com/install.html 9 | * Mac: https://developer.apple.com/xcode 10 | * Linux: http://www.gnu.org/software/make (likely already installed) 11 | * virtualenv: https://pypi.python.org/pypi/virtualenv#installation 12 | * Pandoc: http://johnmacfarlane.net/pandoc/installing.html 13 | * Graphviz: http://www.graphviz.org/Download.php 14 | 15 | Installation 16 | ------------ 17 | 18 | Create a virtualenv: 19 | 20 | ``` 21 | $ make env 22 | ``` 23 | 24 | Run the tests: 25 | 26 | ``` 27 | $ make test 28 | $ make tests # includes integration tests 29 | ``` 30 | 31 | Build the documentation: 32 | 33 | ``` 34 | $ make doc 35 | ``` 36 | 37 | Run static analysis: 38 | 39 | ``` 40 | $ make pep8 41 | $ make pep257 42 | $ make pylint 43 | $ make check # includes all checks 44 | ``` 45 | 46 | Release to PyPI: 47 | 48 | ``` 49 | $ make upload-test # dry run upload to a test server 50 | $ make upload 51 | ``` 52 | -------------------------------------------------------------------------------- /mlviz/test/test_mlviz.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Sample test module.""" 4 | 5 | import unittest 6 | 7 | from mlviz import sample 8 | 9 | 10 | class TestMlviz(unittest.TestCase): 11 | 12 | """Sample test class.""" 13 | 14 | def test_dependency_import(self): 15 | """Sample test method for dependencies.""" 16 | try: 17 | import testpackage # pylint: disable=W0612 18 | assert True 19 | except ImportError: 20 | self.fail("depenency not installed") 21 | 22 | def test_dependency_import_special(self): 23 | """Sample test method for special dependencies.""" 24 | try: 25 | import newrelic_plugin_agent # pylint: disable=W0612 26 | assert True 27 | except ImportError: 28 | self.fail("depenency not installed") 29 | 30 | def test_branch_coverage(self): 31 | """Sample test method for branch coverage.""" 32 | self.assertEquals(sample.function(True), 'True') 33 | self.assertEquals(sample.function(False), 'False') 34 | self.assertEquals(sample.function(None), 'None') 35 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Setup script for mlviz.""" 4 | 5 | import setuptools 6 | 7 | from mlviz import __project__, __version__ 8 | 9 | import os 10 | if os.path.exists('README.rst'): 11 | README = open('README.rst').read() 12 | else: 13 | README = "" # a placeholder, readme is generated on release 14 | CHANGES = open('CHANGES.md').read() 15 | 16 | 17 | setuptools.setup( 18 | name=__project__, 19 | version=__version__, 20 | 21 | description="mlviz is a Python 3 package template.", 22 | url='https://github.com/mattharrison/mlviz', 23 | author='Matt Harrison', 24 | author_email='matthewharrison@gmail.com', 25 | 26 | packages=setuptools.find_packages(), 27 | 28 | entry_points={'console_scripts': []}, 29 | 30 | long_description=(README + '\n' + CHANGES), 31 | license='MIT', 32 | classifiers=[ 33 | 'Development Status :: 1 - Planning', 34 | 'Natural Language :: English', 35 | 'Operating System :: OS Independent', 36 | 'Programming Language :: Python :: 3.3', 37 | ], 38 | 39 | install_requires=open('requirements.txt').readlines(), 40 | ) 41 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Matt Harrison 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /mlviz.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "folders": 3 | [ 4 | { 5 | "path": ".", 6 | "file_exclude_patterns": [".coverage", "*.sublime-workspace"], 7 | "folder_exclude_patterns": [".*", "__pycache__", "build", "dist", "env", "*.egg-info"] 8 | } 9 | ], 10 | "settings": 11 | { 12 | "tab_size": 4, 13 | "translate_tabs_to_spaces": true 14 | }, 15 | "SublimeLinter": 16 | { 17 | "linters": 18 | { 19 | "pep257": { 20 | "@disable": false, 21 | "args": [], 22 | "excludes": [] 23 | }, 24 | "pep8": { 25 | "@disable": false, 26 | "args": [], 27 | "excludes": [], 28 | "ignore": "E501", 29 | "max-line-length": 79, 30 | "select": "" 31 | }, 32 | "pylint": { 33 | "@disable": false, 34 | "args": ["--max-line-length=79"], 35 | "disable": "I0011,W0142,W0511,R0801", 36 | "enable": "", 37 | "excludes": [], 38 | "rcfile": "" 39 | } 40 | } 41 | }, 42 | } 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | mlviz 2 | ====== 3 | Visualize scikit learn models 4 | 5 | [![Build Status](http://img.shields.io/travis/mattharrison/mlviz/master.svg)](https://travis-ci.org/mattharrison/mlviz) 6 | [![Coverage Status](http://img.shields.io/coveralls/mattharrison/mlviz/master.svg)](https://coveralls.io/r/mattharrison/mlviz) 7 | [![Scrutinizer Code Quality](http://img.shields.io/scrutinizer/g/mattharrison/mlviz.svg)](https://scrutinizer-ci.com/g/mattharrison/mlviz/?branch=master) 8 | [![PyPI Version](http://img.shields.io/pypi/v/mlviz.svg)](https://pypi.python.org/pypi/mlviz) 9 | [![PyPI Downloads](http://img.shields.io/pypi/dm/mlviz.svg)](https://pypi.python.org/pypi/mlviz) 10 | 11 | 12 | Getting Started 13 | =============== 14 | 15 | Requirements 16 | ------------ 17 | 18 | * Python 2.7+ or Python 3.3+ 19 | 20 | Installation 21 | ------------ 22 | 23 | mlviz can be installed with pip: 24 | 25 | ``` 26 | $ pip install mlviz 27 | ``` 28 | 29 | or directly from the source code: 30 | 31 | ``` 32 | $ git clone https://github.com/mattharrison/mlviz.git 33 | $ cd mlviz 34 | $ python setup.py install 35 | ``` 36 | 37 | Basic Usage 38 | =========== 39 | 40 | After installation, the package can imported: 41 | 42 | ``` 43 | $ python 44 | >>> import mlviz 45 | >>> mlviz.__version__ 46 | ``` 47 | 48 | mlviz doesn't do anything, it's a template. 49 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Project settings 2 | PROJECT := mlviz 3 | PACKAGE := mlviz 4 | SOURCES := Makefile setup.py $(shell find $(PACKAGE) -name '*.py') 5 | EGG_INFO := $(subst -,_,$(PROJECT)).egg-info 6 | 7 | # Python settings 8 | ifndef TRAVIS 9 | PYTHON_MAJOR := 2 10 | PYTHON_MINOR := 7 11 | endif 12 | 13 | # Test settings 14 | UNIT_TEST_COVERAGE := 100 15 | INTEGRATION_TEST_COVERAGE := 100 16 | 17 | # System paths 18 | PLATFORM := $(shell python -c 'import sys; print(sys.platform)') 19 | ifneq ($(findstring win32, $(PLATFORM)), ) 20 | SYS_PYTHON_DIR := C:\\Python$(PYTHON_MAJOR)$(PYTHON_MINOR) 21 | SYS_PYTHON := $(SYS_PYTHON_DIR)\\python.exe 22 | SYS_VIRTUALENV := $(SYS_PYTHON_DIR)\\Scripts\\virtualenv.exe 23 | # https://bugs.launchpad.net/virtualenv/+bug/449537 24 | export TCL_LIBRARY=$(SYS_PYTHON_DIR)\\tcl\\tcl8.5 25 | else 26 | SYS_PYTHON := python$(PYTHON_MAJOR) 27 | ifdef PYTHON_MINOR 28 | SYS_PYTHON := $(SYS_PYTHON).$(PYTHON_MINOR) 29 | endif 30 | SYS_VIRTUALENV := virtualenv 31 | endif 32 | 33 | # virtualenv paths 34 | ENV := env 35 | ifneq ($(findstring win32, $(PLATFORM)), ) 36 | BIN := $(ENV)/Scripts 37 | OPEN := cmd /c start 38 | else 39 | BIN := $(ENV)/bin 40 | ifneq ($(findstring cygwin, $(PLATFORM)), ) 41 | OPEN := cygstart 42 | else 43 | OPEN := open 44 | endif 45 | endif 46 | 47 | # virtualenv executables 48 | PYTHON := $(BIN)/python 49 | PIP := $(BIN)/pip 50 | EASY_INSTALL := $(BIN)/easy_install 51 | RST2HTML := $(PYTHON) $(BIN)/rst2html.py 52 | PDOC := $(PYTHON) $(BIN)/pdoc 53 | PEP8 := $(BIN)/pep8 54 | PEP8RADIUS := $(BIN)/pep8radius 55 | PEP257 := $(BIN)/pep257 56 | PYLINT := $(BIN)/pylint 57 | PYREVERSE := $(BIN)/pyreverse 58 | NOSE := $(BIN)/nosetests 59 | PYTEST := $(BIN)/py.test 60 | COVERAGE := $(BIN)/coverage 61 | 62 | # Flags for PHONY targets 63 | DEPENDS_CI := $(ENV)/.depends-ci 64 | DEPENDS_DEV := $(ENV)/.depends-dev 65 | ALL := $(ENV)/.all 66 | 67 | # Main Targets ################################################################# 68 | 69 | .PHONY: all 70 | all: depends doc $(ALL) 71 | $(ALL): $(SOURCES) 72 | $(MAKE) check 73 | touch $(ALL) # flag to indicate all setup steps were successful 74 | 75 | .PHONY: ci 76 | ci: check test tests 77 | 78 | # Development Installation ##################################################### 79 | 80 | .PHONY: env 81 | env: .virtualenv $(EGG_INFO) 82 | $(EGG_INFO): Makefile setup.py requirements.txt 83 | VIRTUAL_ENV=$(ENV) $(PYTHON) setup.py develop 84 | touch $(EGG_INFO) # flag to indicate package is installed 85 | 86 | .PHONY: .virtualenv 87 | .virtualenv: $(PIP) 88 | $(PIP): 89 | $(SYS_VIRTUALENV) --python $(SYS_PYTHON) $(ENV) 90 | $(PIP) install --upgrade pip 91 | 92 | .PHONY: depends 93 | depends: depends-ci depends-dev 94 | 95 | .PHONY: depends-ci 96 | depends-ci: env Makefile $(DEPENDS_CI) 97 | $(DEPENDS_CI): Makefile 98 | $(PIP) install --upgrade pep8 pep257 pylint coverage pytest pytest-cov 99 | touch $(DEPENDS_CI) # flag to indicate dependencies are installed 100 | 101 | .PHONY: depends-dev 102 | depends-dev: env Makefile $(DEPENDS_DEV) 103 | $(DEPENDS_DEV): Makefile 104 | $(PIP) install --upgrade pip pep8radius pygments docutils pdoc wheel readme 105 | touch $(DEPENDS_DEV) # flag to indicate dependencies are installed 106 | 107 | # Documentation ################################################################ 108 | 109 | .PHONY: doc 110 | doc: readme verify-readme apidocs uml 111 | 112 | .PHONY: readme 113 | readme: depends-dev README-github.html README-pypi.html 114 | README-github.html: README.md 115 | pandoc -f markdown_github -t html -o README-github.html README.md 116 | README-pypi.html: README.rst 117 | $(RST2HTML) README.rst README-pypi.html 118 | README.rst: README.md 119 | pandoc -f markdown_github -t rst -o README.rst README.md 120 | 121 | .PHONY: verify-readme 122 | verify-readme: README.rst 123 | $(PYTHON) setup.py check --restructuredtext --strict --metadata 124 | 125 | .PHONY: apidocs 126 | apidocs: depends-dev apidocs/$(PACKAGE)/index.html 127 | apidocs/$(PACKAGE)/index.html: $(SOURCES) 128 | $(PDOC) --html --overwrite $(PACKAGE) --html-dir apidocs 129 | 130 | .PHONY: uml 131 | uml: depends-dev docs/*.png 132 | docs/*.png: $(SOURCES) 133 | $(PYREVERSE) $(PACKAGE) -p $(PACKAGE) -f ALL -o png --ignore test 134 | - mv -f classes_$(PACKAGE).png docs/classes.png 135 | - mv -f packages_$(PACKAGE).png docs/packages.png 136 | 137 | .PHONY: read 138 | read: doc 139 | $(OPEN) apidocs/$(PACKAGE)/index.html 140 | $(OPEN) README-pypi.html 141 | $(OPEN) README-github.html 142 | 143 | # Static Analysis ############################################################## 144 | 145 | .PHONY: check 146 | check: pep8 pep257 pylint 147 | 148 | .PHONY: pep8 149 | pep8: depends-ci 150 | # E501: line too long (checked by PyLint) 151 | $(PEP8) $(PACKAGE) --ignore=E501 152 | 153 | .PHONY: pep257 154 | pep257: depends-ci 155 | # D102: docstring missing (checked by PyLint) 156 | # D202: No blank lines allowed *after* function docstring 157 | $(PEP257) $(PACKAGE) --ignore=D102,D202 158 | 159 | .PHONY: pylint 160 | pylint: depends-ci 161 | $(PYLINT) $(PACKAGE) --rcfile=.pylintrc 162 | 163 | .PHONY: fix 164 | fix: depends-dev 165 | $(PEP8RADIUS) --docformatter --in-place 166 | 167 | # Testing ###################################################################### 168 | 169 | PYTEST_OPTS := --doctest-modules --cov=$(PACKAGE) --cov-report=term-missing --cov-report=html 170 | 171 | .PHONY: test 172 | test: depends-ci .clean-test 173 | $(PYTEST) $(PYTEST_OPTS) $(PACKAGE) 174 | $(COVERAGE) report --fail-under=$(UNIT_TEST_COVERAGE) > /dev/null 175 | 176 | .PHONY: tests 177 | tests: depends-ci .clean-test 178 | TEST_INTEGRATION=1 $(PYTEST) $(PYTEST_OPTS) $(PACKAGE) 179 | $(COVERAGE) report --fail-under=$(INTEGRATION_TEST_COVERAGE) > /dev/null 180 | 181 | .PHONY: read-coverage 182 | read-coverage: 183 | $(OPEN) htmlcov/index.html 184 | 185 | # Cleanup ###################################################################### 186 | 187 | .PHONY: clean 188 | clean: .clean-dist .clean-test .clean-doc .clean-build 189 | rm -rf $(ALL) 190 | 191 | .PHONY: clean-env 192 | clean-env: clean 193 | rm -rf $(ENV) 194 | 195 | .PHONY: clean-all 196 | clean-all: clean clean-env .clean-workspace 197 | 198 | .PHONY: .clean-build 199 | .clean-build: 200 | find $(PACKAGE) -name '*.pyc' -delete 201 | find $(PACKAGE) -name '__pycache__' -delete 202 | rm -rf $(EGG_INFO) 203 | 204 | .PHONY: .clean-doc 205 | .clean-doc: 206 | rm -rf README.rst apidocs *.html docs/*.png 207 | 208 | .PHONY: .clean-test 209 | .clean-test: 210 | rm -rf .coverage htmlcov 211 | 212 | .PHONY: .clean-dist 213 | .clean-dist: 214 | rm -rf dist build 215 | 216 | .PHONY: .clean-workspace 217 | .clean-workspace: 218 | rm -rf *.sublime-workspace 219 | 220 | # Release ###################################################################### 221 | 222 | .PHONY: register-test 223 | register-test: doc 224 | $(PYTHON) setup.py register --strict --repository https://testpypi.python.org/pypi 225 | 226 | .PHONY: upload-test 227 | upload-test: .git-no-changes register-test 228 | $(PYTHON) setup.py sdist upload --repository https://testpypi.python.org/pypi 229 | $(PYTHON) setup.py bdist_wheel upload --repository https://testpypi.python.org/pypi 230 | $(OPEN) https://testpypi.python.org/pypi/$(PROJECT) 231 | 232 | .PHONY: register 233 | register: doc 234 | $(PYTHON) setup.py register --strict 235 | 236 | .PHONY: upload 237 | upload: .git-no-changes register 238 | $(PYTHON) setup.py sdist upload 239 | $(PYTHON) setup.py bdist_wheel upload 240 | $(OPEN) https://pypi.python.org/pypi/$(PROJECT) 241 | 242 | .PHONY: .git-no-changes 243 | .git-no-changes: 244 | @if git diff --name-only --exit-code; \ 245 | then \ 246 | echo Git working copy is clean...; \ 247 | else \ 248 | echo ERROR: Git working copy is dirty!; \ 249 | echo Commit your changes and try again.; \ 250 | exit -1; \ 251 | fi; 252 | 253 | # System Installation ########################################################## 254 | 255 | .PHONY: develop 256 | develop: 257 | $(SYS_PYTHON) setup.py develop 258 | 259 | .PHONY: install 260 | install: 261 | $(SYS_PYTHON) setup.py install 262 | 263 | .PHONY: download 264 | download: 265 | pip install $(PROJECT) 266 | --------------------------------------------------------------------------------