Example #1
0
 def algorytm(self):
     try:
         response = self.client.chat_postMessage(channel=channel_id, text="Zaczynamy, LECYMY DuRRrrR")
     except Exception as e:
         print(e)
     self.koniec = 2002
     self.skip = 0
     self.czaaas = time.time()
     CzyIstnieje("")
     self.sheet = wb.active
     self.n = 2
     while self.sheet.cell(row=self.n, column=1).value != None:
         self.n += 1
     self.zapisywacz = 0
     while self.ilosc != self.koniec:
         #self.pruba4Z() vs
         self.pruba4ALGTEST()
     print(time.time() - self.czaaas)
     sandesh.send("KONIEC",
                  webhook=)
     print("PROLOGJEJOJ")
     mp3File = "JD.mp3"
     playsound(mp3File)
     keyboard.wait("HOME")
     print("KONEIC")
Example #2
0
    def __init__(self, monitor, patience=5, mode="min", delta=0.001, webhook=None, initial_msg="Hello, this is sandesh! Your model is training...", es_notifications=False):
        self.monitor = monitor
        self.patience = patience

        # sends early stopping notifications if es_notifications = True
        self.es_notifications = es_notifications

        self.counter = 0
        self.mode = mode
        self.best_score = None
        self.early_stop = False
        self.delta = delta
        if self.mode == "min":
            self.val_score = np.Inf
        else:
            self.val_score = -np.Inf

        if self.monitor.startswith("train_"):
            self.model_state = "train"
            self.monitor_value = self.monitor[len("train_") :]
        elif self.monitor.startswith("valid_"):
            self.model_state = "valid"
            self.monitor_value = self.monitor[len("valid_") :]
        else:
            raise Exception("monitor must start with train_ or valid_")

        # webhook required to send messages to slack
        self.webhook = webhook

        # welcome message
        try:
            sandesh.send(initial_msg, webhook=self.webhook)
        except:
            raise Exception("please follow the correct syntax: sandesh.send(msg, webhook='XXXX')")
Example #3
0
 def send_log(self, **kwargs):
     log = {'model': self.name}
     log.update(kwargs)
     try:
         sandesh.send(log)
     except:
         print(log)
 def send_log(self, **kwargs):
     log = {'model': self.name}
     log.update(kwargs)
     if 'sandesh' in sys.modules:
         sandesh.send(log)
     else:
         print('log not sent - no sandesh module')
    def on_epoch_end(self, epoch, logs={}):

        loss = logs.get('loss')
        acc = logs.get('acc')
        msg = f"Training accuracy was {acc} Training loss was {loss}"
        sandesh.send(
            msg,
            webhook=
            "https://hooks.slack.com/services/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"
        )
Example #6
0
    def on_epoch_end(self, model):
        epoch_score = model.metrics[self.model_state][self.monitor_value]
        if self.mode == "min":
            score = -1.0 * epoch_score
        else:
            score = np.copy(epoch_score)

        if self.best_score is None:
            self.best_score = score

            # send initial score
            msg = f"Epoch score: {self.best_score}"
            sandesh.send(msg, webhook=self.webhook)
            self.save_checkpoint(epoch_score, model)

        # early stopping notifications
        elif score < self.best_score + self.delta and self.es_notifications == True:
            self.counter += 1
            msg = "EarlyStopping counter: {} out of {}".format(self.counter, self.patience)
            sandesh.send(msg, webhook=self.webhook)
        else:
            self.best_score = score
            msg = f"Epoch score: {self.best_score}"
            sandesh.send(msg, webhook=self.webhook)
            self.save_checkpoint(epoch_score, model)
            self.counter = 0
Example #7
0
    if save:
        utils.dump_pickle(tmp, utils.FEATURE_DIR / 'price_feature.pkl')
    ret_df = pd.concat([ret_df, tmp], axis=1)
    tmp = date_feature(data)
    if save:
        utils.dump_pickle(tmp, utils.FEATURE_DIR / 'date_feature.pkl')
    ret_df = pd.concat([ret_df, tmp], axis=1)
    return ret_df


if __name__ == '__main__':
    output_path = utils.FEATURE_DIR / 'baseline_features.pkl'
    encoder_path = utils.FEATURE_DIR / 'encoder.pkl'
    melted_path = utils.FEATURE_DIR / 'melted.pkl'
    fold_indices_path = utils.FEATURE_DIR / 'fold_indices.pkl'
    sandesh.send(f'start generating feature')
    try:
        print('generating features...')
        # dataset = M5Dataset()
        # data = preprocessing.melt_and_merge(
        #     dataset.calendar, dataset.sell_prices, dataset.main_df, dataset.submission,
        #     merge=True)
        # data = preprocessing.add_separated_item_id(data)
        # utils.dump_pickle(data, melted_path)
        data = utils.load_pickle(melted_path)
        data['date'] = pd.to_datetime(data['date'])
        data['all_id'] = 'all'
        # label encoding
        cat = [
            'item_id', 'item_id_1', 'item_id_2', 'item_id_3', 'dept_id',
            'cat_id', 'store_id', 'state_id', 'event_name_1', 'event_type_1',
Example #8
0
args = parser.parse_args()

utils.seed_everything()

print(f'on kaggle: {utils.ON_KAGGLE}')
print(utils.DATA_DIR)
print(utils.RESULTS_BASE_DIR)
TARGET_COL = 'demand'

try:
    exp_name = utils.make_experiment_name(args.debug)
    result_dir = utils.RESULTS_BASE_DIR / exp_name
    os.mkdir(result_dir)

    logger = mylogger.get_mylogger(filename=result_dir / 'log')
    sandesh.send(f'start: {exp_name}')
    logger.debug(f'created: {result_dir}')
    logger.debug('loading data ...')

    train_feat_path = utils.FEATURE_DIR / 'baseline_features.pkl'
    X = utils.load_pickle(train_feat_path)
    print(X.columns)

    features_list = utils.load_yaml(args.feature)
    utils.dump_yaml(features_list, result_dir / 'features_list.yml')
    all_features = features_list['features']['original'] + \
        features_list['features']['generated']
    categorical_feat = features_list['categorical_features']

    logger.debug(all_features)
    logger.debug(f'features num: {len(all_features)}')
Example #9
0
#formato de fecha para bases oga
diasOGA = [
    dia.strftime("%Y") + '-' + dia.strftime("%m") + '-' + dia.strftime("%d")
    for dia in dias
]
#formato de fecha para el resto de las bases
dias = [
    dia.strftime("%Y") + dia.strftime("%m") + dia.strftime("%d")
    for dia in dias
]

#print(dfOGA)
#print(dfs)
msg = ''

for i in range(dfOGA.shape[0]):
    if ((str(dfOGA.created_at.iloc[1].date()) in diasOGA) == False):
        msg += f"La base {dfOGA.base.iloc[i]} no está actualizada, último movimiento:  {dfOGA.created_at.iloc[i]} "
for i in range(dfs.shape[0]):
    if ((dfs.febo.iloc[i] in dias or dfs.fepf.iloc[i] in dias
         or dfs.fefi.iloc[i] in dias) == False):
        msg += f"La base {dfs.base.iloc[i]} no está actualizada, último movimiento: febo: {dfs.febo.iloc[i]} ,fepf: {dfs.fepf.iloc[i]}, fefi: {dfs.fefi.iloc[i]} "
if msg == '':
    msg = 'Todas las bases estan actualizadas'
sandesh.send(
    msg,
    webhook=
    "https://hooks.slack.com/services/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"
)
#print(msg)
Example #10
0
 def save_checkpoint(self, epoch_score, model):
     if epoch_score not in [-np.inf, np.inf, -np.nan, np.nan]:
         msg = "Validation score improved ({} --> {}). Saving model!".format(self.val_score, epoch_score)
         sandesh.send(msg, webhook=self.webhook)
     self.val_score = epoch_score