How to use the sktime.utils.load_data.load_from_tsfile_to_dataframe function in sktime

To help you get started, we’ve selected a few sktime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alan-turing-institute / sktime / sktime / classifiers / interval_based / tsf.py View on Github external
Y: array of shape = [n_samps, interval_size]

        Returns
        ----------
        slope: array of shape = [n_samps]

        """
        x = np.arange(Y.shape[1]) + 1
        slope = (np.mean(x * Y, axis=1) - np.mean(x) * np.mean(Y, axis=1)) / ((x * x).mean() - x.mean() ** 2)
        return slope



if __name__ == "__main__":
    dataset = "Gunpoint"
    train_x, train_y =  ld.load_from_tsfile_to_dataframe(file_path="C:/temp/sktime_temp_data/" + dataset + "/", file_name=dataset + "_TRAIN.ts")

    print(train_x.iloc[0:10])

    tsf = TimeSeriesForest()
    tsf.fit(train_x.iloc[0:10], train_y[0:10])
    preds = tsf.predict(train_x.iloc[10:20])
    print(preds)
github alan-turing-institute / sktime / sktime / datasets / base.py View on Github external
def _load_dataset(name, split, return_X_y):
    """
    Helper function to load datasets.
    """

    if split in ["TRAIN", "TEST"]:
        fname = name + '_' + split + '.ts'
        abspath = os.path.join(MODULE, DIRNAME, name, fname)
        X, y = load_from_tsfile_to_dataframe(abspath)
    elif split == "ALL":
        X = pd.DataFrame()
        y = pd.Series()
        for split in ["TRAIN", "TEST"]:
            fname = name + '_' + split + '.ts'
            abspath = os.path.join(MODULE, DIRNAME, name, fname)
            result = load_from_tsfile_to_dataframe(abspath)
            X = pd.concat([X, pd.DataFrame(result[0])])
            y = pd.concat([y, pd.Series(result[1])])
    else:
        raise ValueError("Invalid split value")

    # Return appropriately
    if return_X_y:
        return X, y
    else:
github alan-turing-institute / sktime / sktime / datasets / base.py View on Github external
def _load_dataset(name, split, return_X_y):
    """
    Helper function to load datasets.
    """

    if split in ["TRAIN", "TEST"]:
        fname = name + '_' + split + '.ts'
        abspath = os.path.join(MODULE, DIRNAME, name, fname)
        X, y = load_from_tsfile_to_dataframe(abspath)
    elif split == "ALL":
        X = pd.DataFrame()
        y = pd.Series()
        for split in ["TRAIN", "TEST"]:
            fname = name + '_' + split + '.ts'
            abspath = os.path.join(MODULE, DIRNAME, name, fname)
            result = load_from_tsfile_to_dataframe(abspath)
            X = pd.concat([X, pd.DataFrame(result[0])])
            y = pd.concat([y, pd.Series(result[1])])
    else:
        raise ValueError("Invalid split value")

    # Return appropriately
    if return_X_y:
        return X, y
    else:
        X['class_val'] = pd.Series(y)
        return X
github alan-turing-institute / sktime / sktime / datasets / base.py View on Github external
def _load_dataset(name, split, return_X_y):
    """
    Helper function to load datasets.
    """

    dname = 'data'
    module_path = path.dirname(__file__)

    if split in ["TRAIN", "TEST"]:
        fname = name+'_'+split+'.ts'
        abspath = path.join(module_path, dname, name, fname)
        X, y = load_from_tsfile_to_dataframe(abspath)
    elif split == "ALL":
        X = pd.DataFrame()
        y = pd.Series()
        for split in ["TRAIN", "TEST"]:
            fname = name+'_'+split+'.ts'
            abspath = path.join(module_path, dname, name, fname)
            result = load_from_tsfile_to_dataframe(abspath)
            X = pd.concat([X, pd.DataFrame(result[0])])
            y = pd.concat([y, pd.Series(result[1])])
    else:
        raise ValueError("Invalid split value")

    # Return appropriately
    if return_X_y:
        return X, y
    else:
github alan-turing-institute / sktime / sktime / datasets / base.py View on Github external
"""

    dname = 'data'
    module_path = path.dirname(__file__)

    if split in ["TRAIN", "TEST"]:
        fname = name+'_'+split+'.ts'
        abspath = path.join(module_path, dname, name, fname)
        X, y = load_from_tsfile_to_dataframe(abspath)
    elif split == "ALL":
        X = pd.DataFrame()
        y = pd.Series()
        for split in ["TRAIN", "TEST"]:
            fname = name+'_'+split+'.ts'
            abspath = path.join(module_path, dname, name, fname)
            result = load_from_tsfile_to_dataframe(abspath)
            X = pd.concat([X, pd.DataFrame(result[0])])
            y = pd.concat([y, pd.Series(result[1])])
    else:
        raise ValueError("Invalid split value")

    # Return appropriately
    if return_X_y:
        return X, y
    else:
        X['class_val'] = pd.Series(y)
        return X