Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Latest commit

 

History

History
72 lines (48 loc) · 2.33 KB

README.md

File metadata and controls

72 lines (48 loc) · 2.33 KB

Musical pancakes

I love autogenerated github repo names

Setup

After cloning, you first need to set up a virtual environment:

# Get virtualenv if you don't have it
pip install virtualenv

virtualenv -p <path to python 2.7> venv

then activate it:

source venv/bin/activate

and install any dependencies:

pip install -r requirements.txt

You can also install depencencies with make init. If you add any dependencies via pip, make sure to save them and commit the new requirements file:

pip freeze > requirements.txt

Or just run make freeze. Finally, before you start work, download the datasets, rename the reviews file to reviews.json, and put it into data/.

When you're finished working, make sure to deactivate.

Notebooks

I (Joel) sometimes use notebooks for working through a problem. You can check them out by running jupyter notebook.

Test Harness

We've setup a test harness that allows one to easily swap out learning models by defining a few short functions. Specifically, we need to define a class that has three short instance methods:

  1. initialize_models() - takes no parameters and initializes a list of five empty learning models of your chosen type
  2. train_model_stochastic(model, example) - takes an existing model and a single example, and stochastically trains the model using the single example, returning the modified model.
  3. model_test(model, example) - takes an existing model and a single example, and returns a boolean of whether or not it expects the example to have >0 usefulness or not.

Once those are defined, run

import main
model = Model() # Or whatever you named the class
main.engage(model, model_test, filename=<filename>)

to kick off the training and testing process and print results.

Tests

Currently have tests in their own package, which makes it pretty straightforward to run them without obnoxious imports. Running

python -m unittest test.test_hello

runs the test/test_hello.py file, but runs from the root directory, so imports are easy. Running

python -m unittest discover

or just make test finds and runs all tests of the format test_*.py. To quickly generate a new test for learn/example_module.py, run

./generate example_module

This will create test/test_example_module.py and fill in testing boilerplate.