예제 #1
0
    def __init__(self, config, keys):
        self.__keys = keys
        dictNginxRTConf = config[self._type]

        if int(dictNginxRTConf['entityNum']) == 0:
            sys.exit(0)

        Collector.__init__(self, self._type, config, keys)
예제 #2
0
    def __init__(self, config, keys):
        self.__keys = keys
        dictNginxRTConf = config[self._type]

        if int(dictNginxRTConf['entityNum']) == 0:
            sys.exit(0)

        Collector.__init__(self, self._type, config, keys)
예제 #3
0
class ProductLearning():
    def __init__(self):
        self.collector = Collector()
        self.normalize = Normalizer()

    def load_linear(self, company, product, period):
        repository = LinearModelRepository()
        model = repository.load_valid(product, company, period.value)
        if len(model.params) > 0:
            model = model
            product = model.product
            company = model.company
        else:
            model = self.fit_linear_product(product, company)
            model.company = {"cod": company}
            model.product = {"cod": product}
            repository.save(model)

        return model

    def fit_linear_product(self,
                           codigoProduto,
                           codigoFilial,
                           features=[],
                           target=None,
                           training_date_from=datetime.now().timestamp(),
                           training_date_to=datetime.now().timestamp(),
                           period=Period.MONTHLY):
        company = {"cod": codigoFilial}
        df = self.collector.colector_mes(codigoProduto, codigoFilial)
        df = self.normalize.normalizar(df)
        model = LinearModel()
        if df.size > 0:
            product = {"cod": df.loc[0, "KEY:PRODUTO:CODIGO"]}
        real_params = []
        for col in df.columns:
            column = col.split(":")
            if len(column) > 0:
                if column[0] == 'PARAMS':
                    real_params.append(col)
                if column[0] == 'CALENDAR' and column[1] != 'DATE':
                    real_params.append(col)
                if column[0] == 'EVENT':
                    real_params.append(col)
        X = df[real_params].values
        y = df['METRIC:QTD'].values
        if df.size != 0:
            model.fit(X, y)
            model.params = real_params
            model.training_date_from = training_date_from
            model.training_date_to = training_date_to
            model.period = period
            #self.model = self.regression#pickle.dumps(self.regression)

        return model
예제 #4
0
def main(username, password, output):
    if username == None:
        username = input('Github Username: '******'Github Password: '******'message'])
    except Exception:
        print('An error occured while generating report.')
예제 #5
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2019/1/14 5:26 PM
# @Author  : w8ay
# @File    : data.py
from lib.collector import Collector
from lib.log import LOGGER

logger = LOGGER()


class PATHS:
    ROOT_PATH = ''
    PLUGIN_PATH = ''
    OUTPUT_PATH = ''
    DATA_PATH = ''


collector = Collector()
예제 #6
0
 def __init__(self, config, keys):
     Collector.__init__(self, self._type, config, keys)
예제 #7
0
    action = sys.argv[1].lower()

    if action == 'help':
        sys.stderr.write('''
available commands:
    collect [notebook-name] - retrieve and organize the latest notes
    rebuild                 - rebuild static site

usage: {0} [action] [additional parameters?]
'''.format(sys.argv[0]))

    elif action == 'collect':
        if len(sys.argv) < 3:
            sys.stderr.write(
                'error: missing required parameter: notebook-name\n')
            sys.exit(ERR_MISSING_REQUIRED_PARAM)

        myNotebook = sys.argv[2]
        Collector(myNotebook).run()

    elif action == 'rebuild':
        generator = HtmlGenerator()
        generator.generate()

    else:
        sys.stderr.write(
            'error: unrecognized action: "{0}", view help by running `{1} help`\n'
            .format(action, sys.argv[0]))
        sys.exit(1)
예제 #8
0
 def __init__(self, config, keys):
     Collector.__init__(self, self._type, config, keys)
예제 #9
0
 def __init__(self):
     self.collector = Collector()
     self.normalize = Normalizer()
예제 #10
0
from lib.linearmodel import LinearModel
from lib.repository.dbconnection import DBConnection
from lib.collector import Collector
linear = LinearModel()

db = DBConnection()

collector = Collector()
print(collector.colector_mes('0100102000', '020101'))

print(linear.to_dict())