Final Project for CAPP 30255 Advanced Machine Learning for Public Policy
Lauren Dyson & Alden Golab, Winter 2017
You can find the final summary for this project in the main directory.
We have included a conda environment yaml. To install, run:
conda env create -f environment.yml
This project is using a dataset published by Signal Media in conjunction with the Recent Trends in News Information Retrieval 2016 conference to facilitate conducting research on news articles. We use OpenSources.co to distinguish between 'legitimate' and 'fake' news sources.
From the raw article text, we generate the following features:
The pipeline contains four sets of python code:
model.py: a class for models
model_loop.py: a class for running a loop of classifiers; takes test-train data splits and various run params
run.py: this code implements the model_loop class; it also implements our re-sampling of the data
transform_features.py: this file executes all feature generation
Running the code is done through
run.py with the following options:
--models: models to run
--iterations: number of tuning parameter iterations to run per model
--output_dir: a directory name to store the output; system will create the directory
--dedupe: whether to look for and remove duplicate content
--features: which feature set to run with, options include:
both_only: runs both PCFG and TFIDF
grammar_only: runs only PCFG
tfidf_only: runs only TFIDF
all: runs all the above
To execute the pipeline with Logistic Regression and Stochastic Gradient Descent, navigate to the pipeline directory, run:
source activate amlpp python run.py /path/to/data --models LR SGD --iterations 50 --output_dir run_name --dedupe --reduce 500 --features both_only
This is encapsulated in the
The first argument is the path to the input datafile. The pipeline assumes that the text of each article is unique. If your texts are not unique, use the flag --dedupe to automatically remove duplicated articles during preprocessing. To see a description of all arguments, run:
python run.py --h
A simple report on the models run with basic evaluation metrics will be output to the output/ directory (unless another output directory is specified).
Copyright (c) 2017
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.