Built with Flask and Scikit-Learn.
Make sure that you have the following
- Python 3+ and pip (which comes with Python 3+)
- A Unix command line (for windows users, I personally recommend Git Bash). This isn't strictly necessary to complete the workshop, but if you don't want the packages installed globally, this is required.
If you're going to be participating in the workshop, then download the starter code from the hoohacks-starter
branch either by running git clone https://github.com/dylankfernandes/spam-classifier.git -b hoohacks-starter
or downloading the branch as a zip file.
To run the demo, you first have to understand what each file does.
server.py
- runs the server and loads the user interface.templates/layout.html
- contains the base HTMLtemplates/index.html
- contains the body of the HTMLmodels/saved/
- contains all locally saved models and dataframes for future loadingmodels/save_df.py
- cleans the dataframe and saves the new dataframe to local file structure.models/model.py
- builds and saves the logistic regression model.
To actually run the demo, complete the following steps
- Install the
virtualenv
package usingpip install virtualenv
. - Create a virtual environment using
virtualenv <environment-name>
. Start the virtual environment by executing the following, depending on your operating system.- Windows -
<environment-name>\Scripts\activate
- OS X -
source <environment-name>/bin/activate
- Windows -
- Install the required packages using
pip install -r requirements.txt
. You can manually install them as you come across them if need be, but this will install them all for you. Note that if you add more packages, runpip freeze > requirements.txt
to save them to your requirements file. - Navigate into the
models
directory (cd models
) and create asaved
directory (mkdir saved
or manually creating the folder in your file system). Navigate out of themodels
directory (cd ..
) back into the root directory - Run
python models/save_df.py
. This will save the cleaned dataframe as a csv under themodels/saved
directory. - Run
python models/model.py
. This will build the model and save it as a.joblib
file under themodels/saved
directory. At this point, make sure that themodels/saved/
directory contains both thedataframe.csv
andmodel.joblib
files. - Run the app using
python server.py
. - After you are finished using your app,
deactivate
your virtual environment.