Last active
March 11, 2020 15:26
-
-
Save LouisdeBruijn/fc50c0c8f165a77eaae3608cd35ca552 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import argparse | |
| import logging | |
| from logging import critical, error, info, warning, debug | |
| import numpy as np | |
| import seaborn as sn | |
| import pandas as pd | |
| import random | |
| from sklearn.metrics import accuracy_score, classification_report, confusion_matrix | |
| from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer | |
| from sklearn.naive_bayes import MultinomialNB | |
| from sklearn.pipeline import Pipeline, FeatureUnion | |
| from sklearn.base import BaseEstimator, TransformerMixin | |
| from sklearn.feature_extraction import DictVectorizer | |
| import nltk | |
| from nltk.probability import FreqDist | |
| import matplotlib.pyplot as plt | |
| def parse_arguments(): | |
| """Read arguments from a command line""" | |
| parser = argparse.ArgumentParser(description='Please add arguments') | |
| parser.add_argument('-v', '--verbose', metavar='verbosity', type=int, default=3, | |
| help='Verbosity of logging: 0 -critical, 1 -error, 2 -warning, 3 -info, 4 -debug') | |
| parser.add_argument('--input', metavar='FILE', required=True, | |
| help='txt file containing the data') | |
| parser.add_argument('--binary', action='store_true', | |
| help='Set if you want binary classification') | |
| args = parser.parse_args() | |
| verbose = {0: logging.CRITICAL, 1: logging.ERROR, 2: logging.WARNING, 3: logging.INFO, 4: logging.DEBUG} | |
| logging.basicConfig(format='%(message)s', level=verbose[args.verbose], stream=sys.stdout) | |
| return args | |
| def main(): | |
| """Main function where the pipeline will be put together.""" | |
| if __name__ == '__main__': | |
| args = parse_arguments() | |
| if args.input: | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment