Exemple #1
0
def main():
    try:
        validate_config(Config)
    except ConfigurationError as e:
        sys.stdout.write(str(e))
        sys.exit(1)

    setup_logging()

    parser = create_parser()
    args = parser.parse_args()

    if args.command == 'init':
        initialize_dialogflow_intents()
    elif args.command == 'run':
        if args.platform == 'telegram':
            run_telegram_bot()
        elif args.platform == 'vk':
            run_vk_bot()
        else:
            sys.stdout.write('Unknown command. Please refer for help.')
            sys.exit(1)
    else:
        sys.stdout.write('Unknown command. Please refer for help.')
        sys.exit(1)
Exemple #2
0
def create_app(name=None):
    setup_logging()
    app = Flask(name or __name__)
    setup_routes(app)
    app.debug = False
    init_db()
    init_data()
    schedule_job()
    return app
Exemple #3
0
def create_app(name=None):
    setup_logging()
    app = Flask(name or 'App',
                template_folder=os.path.join(SOURCE_ROOT, 'templates'))
    app.config.root_path = os.path.dirname(os.path.abspath(__file__))
    app.config.from_pyfile('settings.py')
    load_api(app)
    load_moudle(app)
    #CORS(apps)
    return app
Exemple #4
0
def main():
    parser = ArgumentParser(description="Train and evaluate resnet model.")
    parser.add_argument("--params",
                        help="Path to file to save params",
                        default="./data/cdiscount/model_params.torch")
    parser.add_argument("--train",
                        action='store_true',
                        help="Train model? Otherwise, will test")

    args = parser.parse_args()

    setup_logging()

    if args.train:
        train(args.params)
    else:
        accuracy = test(args.params)
        print("Accuracy: {:.2f}%".format(accuracy * 100))
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# import os,sys,inspect
# currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
# parentdir = os.path.dirname(currentdir)
# sys.path.insert(0,parentdir)

# Setup Logging
from settings import setup_logging
from logging import getLogger

setup_logging()
logger = getLogger('dataset')

from analyzer import TweetPreprocessor, TweetTokenizer
from feature_extraction import make_text_extractor, Bunch
from csv import reader

from collections import namedtuple

import numpy as np
import scipy as sp
import csv
import yaml


class SMS(namedtuple('SMS', ['sms_id_str', 'user_id_str', 'label', 'text'])):
    def _asdict(self):
        'Return a new OrderedDict which maps field names to their values'
        return dict(zip(self._fields, self))
Exemple #6
0
"""
FUNCTIONS TO PLOT OUT LIGHT CURVES/APERTURE OF STAR
"""

from utils import get_sub_kwargs, clip_array, build_arr_n_names, format_arr, is_n_bools
from aperture import run_photometry, improve_aperture, get_aperture_center, \
    calculate_better_aperture, model_background, make_background_mask
from settings import setup_logging, mpl_setup

logger = setup_logging()

import os
import csv
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import gridspec as gs
from matplotlib.backends.backend_pdf import PdfPages


def plot_data(target, count=0):
    """
    creates plot of light curve and aperture for one target
    assumes already have right data before from target

    :return: matplotlib figure generated
    """
    fig = plt.figure(figsize=(11, 8))
    gs.GridSpec(3, 3)

    plt.subplot2grid((3, 3), (1, 2))
    plt.title(target.kic, fontsize=20)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Setup Logging
from settings import setup_logging
from logging import getLogger

setup_logging()
logger = getLogger('eval')

logger.info('importing packages...')

# Import standard packages
from time import time, sleep
from pprint import pprint, pformat

# Import 3rd-party packages
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt

from sklearn.metrics import confusion_matrix
from sklearn.metrics.metrics import _check_clf_targets
from sklearn.utils.multiclass import unique_labels
from sklearn.cross_validation import KFold, StratifiedKFold, cross_val_score
from sklearn.learning_curve import learning_curve

from sklearn.linear_model import LogisticRegression, SGDClassifier
from sklearn.naive_bayes import MultinomialNB
from sklearn.svm import SVC, LinearSVC
from sklearn.neighbors import KNeighborsClassifier
def main():
    settings.setup_logging()
    scrape_toysrus()
    scrape_well()
Exemple #9
0
import settings
from utils import get_nth_col
from parse import table_api
from mast import mast_api
logger = settings.setup_logging()

import kplr
import numpy as np
import ast


class api(object):
    """
    api to get necessary parameters from combined databases
    """
    def __init__(self):
        self.sources = ["q1-17", "mast", "mast_table", "periodic", "nonperiodic", \
                        "lc_img", "lc_new", "lc_old"]
        self.updated_dir = settings.filename_stellar_params
        self.nonperiodic_dir = settings.filename_nonperiods
        self.periodic_dir = settings.filename_periods
        self.mast_table_dir = settings.filename_mast_table
        self.gaia_dir = settings.filename_gaia_table
        self.kic10_dir = settings.filename_kic10_table
        self.lc_img_dir = settings.filename_lc_img
        self.lc_new_dir = settings.filename_lc_new
        self.lc_old_dir = settings.filename_lc_old
        self.lc_obs_dir = settings.filename_lc_obs
        self.lc_var_dir = settings.filename_lc_var

    def get_params(self, kics, params, **neighbour_filters):