예제 #1
0
def data_load(signal_size, filename, label, InputType, task):
    '''
    This function is mainly used to generate test data and training data.
    filename:Data location
    '''
    if label == 0:
        fl = (loadmat(filename)["bearing"][0][0][1])  # Take out the data
    else:
        fl = (loadmat(filename)["bearing"][0][0][2])  # Take out the data
    fl = (fl - fl.min()) / (fl.max() - fl.min())
    fl = fl.reshape(-1, )
    data = []
    start, end = 0, signal_size
    while end <= fl[:signal_size * 1000].shape[0]:
        if InputType == "TD":
            x = fl[start:end]
        elif InputType == "FD":
            x = fl[start:end]
            x = FFT(x)
        else:
            print("The InputType is wrong!!")

        data.append(x)
        start += signal_size
        end += signal_size

    graphset = RadiusGraph(10, data, label, task)

    return graphset
예제 #2
0
def data_load(signal_size, filename, label, InputType, task):
    '''
    This function is mainly used to generate test data and training data.
    filename:Data location
    axisname:Select which channel's data,---->"_DE_time","_FE_time","_BA_time"
    '''
    fl = pd.read_csv(filename, skiprows=range(14), header=None)
    fl = (fl - fl.min()) / (fl.max() - fl.min())
    fl = fl.values
    fl = fl.reshape(-1, )
    data = []
    start, end = 0, signal_size
    while end <= fl[:signal_size * 1000].shape[0]:
        if InputType == "TD":
            x = fl[start:end]
        elif InputType == "FD":
            x = fl[start:end]
            x = FFT(x)
        else:
            print("The InputType is wrong!!")

        data.append(x)
        start += signal_size
        end += signal_size

    graphset = KNNGraph(10, data, label, task)
    return graphset
예제 #3
0
def data_load(signal_size, root, label, InputType, task):
    '''
    This function is mainly used to generate test data and training data.
    root:Data location
    '''

    fl = pd.read_csv(
        root,
        sep='\t',
        usecols=[1],
        header=None,
    )
    fl = fl.values
    fl = (fl - fl.min()) / (fl.max() - fl.min())
    fl = fl.reshape(-1, )
    data = []
    start, end = 0, signal_size
    while end <= fl[:signal_size * 1000].shape[0]:
        if InputType == "TD":
            x = fl[start:end]
        elif InputType == "FD":
            x = fl[start:end]
            x = FFT(x)
        else:
            print("The InputType is wrong!!")

        data.append(x)
        start += signal_size
        end += signal_size

    graphset = PathGraph(10, data, label, task)
    return graphset
예제 #4
0
def data_load(signal_size, filename, axisname, label, InputType, task):
    '''
    This function is mainly used to generate test data and training data.
    filename:Data location
    axisname:Select which channel's data,---->"_DE_time","_FE_time","_BA_time"
    '''
    datanumber = axisname.split(".")
    if eval(datanumber[0]) < 100:
        realaxis = "X0" + datanumber[0] + axis[0]
    else:
        realaxis = "X" + datanumber[0] + axis[0]
    fl = loadmat(filename)[realaxis]
    fl = (fl - fl.min()) / (fl.max() - fl.min())
    fl = fl.reshape(-1, )
    data = []
    start, end = 0, signal_size
    while end <= fl[:signal_size * 1000].shape[0]:
        if InputType == "TD":
            x = fl[start:end]
        elif InputType == "FD":
            x = fl[start:end]
            x = FFT(x)
        else:
            print("The InputType is wrong!!")

        data.append(x)
        start += signal_size
        end += signal_size

    graphset = PathGraph(10, data, label, task)

    return graphset
예제 #5
0
def data_load(signal_size, filename, dataname, label, InputType, task):
    '''
    This function is mainly used to generate test data and training data.
    filename:Data location
    '''
    f = open(filename, "r", encoding='gb18030', errors='ignore')
    fl = []
    if dataname == "ball_20_0.csv":
        for line in islice(f, 16, None):  #Skip the first 16 lines
            line = line.rstrip()
            word = line.split(",", 8)  #Separated by commas
            fl.append(eval(word[1])
                      )  # Take a vibration signal in the x direction as input
    else:
        for line in islice(f, 16, None):  #Skip the first 16 lines
            line = line.rstrip()
            word = line.split("\t", 8)  #Separated by \t
            fl.append(eval(word[1])
                      )  # Take a vibration signal in the x direction as input
    fl = np.array(fl)
    fl = (fl - fl.min()) / (fl.max() - fl.min())
    fl = fl.reshape(-1, )
    data = []
    start, end = 0, signal_size
    while end <= fl[:signal_size * 1000].shape[0]:
        if InputType == "TD":
            x = fl[start:end]
        elif InputType == "FD":
            x = fl[start:end]
            x = FFT(x)
        else:
            print("The InputType is wrong!!")

        data.append(x)
        start += signal_size
        end += signal_size

    graphset = RadiusGraph(10, data, label, task)

    return graphset