Ejemplo n.º 1
0
def model_files_by_timestamp(dirpath):
    """
    List all available model files by timestamp, most recent first
    """
    models = {}
    model_files = read_dir(dirpath)
    for f in model_files:
        filepath = dirpath + '/' + f
        ts = os.path.getmtime(filepath)
        models[ts] = filepath

    return sorted(
        models.items(), key=lambda x: x[0], reverse=True
    )  # "reverse", because we want the highest timestamps (most recent) first
Ejemplo n.º 2
0
def model_files_by_F1(dirpath):
    """
    List all available model files by loss
    """
    models = {}
    model_dirs = read_dir(dirpath)
    for f in model_dirs:
        fv = re.sub(r'^F', '', f)
        fv = re.sub(r'_E\d+_B\d+$', '', fv)
        F_val = float(fv)
        modelpath = dirpath + '/' + f
        models[modelpath] = F_val

    return sorted(models.items(), key=lambda x: x[1], reverse=True)
Ejemplo n.º 3
0
def model_files_by_loss(dirpath):
    """
    List all available model files by loss
    """
    models = {}
    model_dirs = read_dir(dirpath)
    for f in model_dirs:
        lv = re.sub(r'^F', '', f)
        lv = re.sub(r'_E\d+_B\d+$', '', lv)
        loss_val = float(lv)
        modelpath = dirpath + '/' + f
        models[modelpath] = loss_val

    return sorted(models.items(), key=lambda x: x[1])
Ejemplo n.º 4
0
    def model_files_by_loss(self):
        """
        List all available model files by loss
        """
        models = {}
        model_files = read_dir(self.get('model_dir'))
        for f in model_files:
            if re.search('^loss_', f):
                lv = re.sub(r'^loss_', '', f)
                lv = re.sub(r'\.json\.gz$', '', lv)
                loss_val = float(lv)
                models[loss_val] = self.get('model_dir') + '/' + f

        return sorted(models.items(), key=lambda x: x[0])
Ejemplo n.º 5
0
    def model_files_by_timestamp(self):
        """
        List all available model files by timestamp, most recent first
        """
        models = {}
        model_files = read_dir(self.get('model_dir'))
        for f in model_files:
            if re.search('^loss_', f):
                filepath = self.get('model_dir') + '/' + f
                ts = os.path.getmtime(filepath)
                models[ts] = filepath

        return sorted(
            models.items(), key=lambda x: x[0], reverse=True
        )  # "reverse", because we want the highest timestamps (most recent) first
Ejemplo n.º 6
0
def default_read_data_dir(input_dir):
    """
    Default function for reading data from a directory into a Dataset

    Parameters
    ----------
    input_dir : str
        Directory where each file will be read

    Returns
    -------
    array of DataFrame (4 of them: x_train, x_test, y_train, y_test)

    """
    files = read_dir(input_dir, {'fullpath': True})
    return default_read_data_files(files)
Ejemplo n.º 7
0
def model_files_by_pcc(dirpath):
    """
    List all available model files by PCC
    """
    models = {}
    model_dirs = read_dir(dirpath)
    for f in model_dirs:
        if re.search(r'^PCC', f):
            lv = re.sub(r'^PCC', '', f)
            lv = re.sub(r'_E\d+_B\d+$', '', lv)
            try:
                loss_val = float(lv)
                modelpath = dirpath + '/' + f
                models[modelpath] = loss_val
            except:
                pass

    return sorted(models.items(), key=lambda x: x[1], reverse=True)