Пример #1
0
def exct_mtf_autoencoder_hierarchy(n_clicks, mtf_data, ae_data, hrc_data):
    print("MTF Autoencoder & Hierarchy")
    # init
    result, result_norm = initialize_data()

    result_resample = exec_ts_resampler(result_norm, mtf_data[0]['image_size'])
    #(242,28,1)
    result_ = result_resample.reshape(result_resample.shape[0], 1,
                                      result_resample.shape[1])
    #(242,28,28)
    X = toMTFdata(tsdatas=result_,
                  image_size=mtf_data[0]['image_size'],
                  n_bins=mtf_data[0]['n_bins'],
                  strategy=mtf_data[0]['mtf_strategy'])
    X_expand = np.expand_dims(X, axis=3)

    all_feature = fit_autoencoder(
        X_expand, mtf_data[0]['image_size'], ae_data[0]['dimension_feature'],
        ae_data[0]['optimizer'], (3e-7) * (10**ae_data[0]['learning_rate']),
        ae_data[0]['activation_function'], ae_data[0]['loss_function'],
        ae_data[0]['batch_size'], ae_data[0]['epoch'])
    print(f'feature shape{all_feature.shape}')
    cluster = hierarchicalClustering(all_feature,
                                     hrc_data[0]['number_of_cluster'],
                                     hrc_data[0]['linkage'])

    send_result_data(result, hrc_data[0]['number_of_cluster'],
                     "MTF Autoencoder & Hierarchy", cluster.labels_,
                     all_feature)
    return []
Пример #2
0
def exct_gaf_autoencoder_kmeans(n_clicks, gaf_data, ae_data, km_data):
    print("GAF Autoencoder & Kmeans 실행중입니다...")

    # init
    result, result_norm = initialize_data()

    result_resample = exec_ts_resampler(result_norm, gaf_data[0]['image_size'])
    #(242,28,1)
    result_ = result_resample.reshape(result_resample.shape[0], 1,
                                      result_resample.shape[1])
    #(242,28,28)
    X = toGAFdata(tsdatas=result_,
                  image_size=gaf_data[0]['image_size'],
                  method=gaf_data[0]['gaf_method'])
    X_expand = np.expand_dims(X, axis=3)

    all_feature = fit_autoencoder(
        X_expand, gaf_data[0]['image_size'], ae_data[0]['dimension_feature'],
        ae_data[0]['optimizer'], (3e-7) * (10**ae_data[0]['learning_rate']),
        ae_data[0]['activation_function'], ae_data[0]['loss_function'],
        ae_data[0]['batch_size'], ae_data[0]['epoch'])
    print(f'feature shape{all_feature.shape}')
    cluster = kmeans(all_feature, km_data[0]['number_of_cluster'],
                     km_data[0]['tolerance'], km_data[0]['try_n_init'],
                     km_data[0]['try_n_kmeans'])

    send_result_data(result, km_data[0]['number_of_cluster'],
                     "GAF Autoencoder & Kmeans", cluster.labels_, all_feature)
    return []
Пример #3
0
def exct_gaf_autoencoder_dbscan(n_clicks, gaf_data, ae_data, dbs_data):
    print("GAF Autoencoder & DBSCAN 실행중입니다...")

    # init
    result, result_norm = initialize_data()

    result_resample = exec_ts_resampler(result_norm, gaf_data[0]['image_size'])
    #(242,28,1)
    result_ = result_resample.reshape(result_resample.shape[0], 1,
                                      result_resample.shape[1])
    #(242,28,28)
    X = toGAFdata(tsdatas=result_,
                  image_size=gaf_data[0]['image_size'],
                  method=gaf_data[0]['gaf_method'])
    X_expand = np.expand_dims(X, axis=3)

    all_feature = fit_autoencoder(
        X_expand, gaf_data[0]['image_size'], ae_data[0]['dimension_feature'],
        ae_data[0]['optimizer'], (3e-7) * (10**ae_data[0]['learning_rate']),
        ae_data[0]['activation_function'], ae_data[0]['loss_function'],
        ae_data[0]['batch_size'], ae_data[0]['epoch'])

    cluster = dbscan(all_feature,
                     eps=dbs_data[0]['epsilon'],
                     min_samples=dbs_data[0]['min_sample'])

    cluster_num = max(cluster.labels_) + 1

    send_result_data(result, cluster_num, "GAF Autoencoder & DBSCAN",
                     cluster.labels_, all_feature)

    # init
    result, result_norm = initialize_data()
    return []
Пример #4
0
def exct_rp_autoencoder_hierarchy(n_clicks, rp_data, ae_data, hrc_data):
    print("RP Autoencoder & hierarchy 실행중입니다...")
    threshold = rp_data[0]['threshold']
    if threshold == 'None':
        threshold = None

    # init
    result, result_norm = initialize_data()

    result_resample = exec_ts_resampler(result_norm, rp_data[0]['image_size'])
    #(242,28,1)
    result_ = result_resample.reshape(result_resample.shape[0], 1,
                                      result_resample.shape[1])
    #(242,28,28)
    X = toRPdata(result_, rp_data[0]['dimension'], rp_data[0]['time_delay'],
                 threshold, rp_data[0]['percentage'] / 100)
    X_expand = np.expand_dims(X, axis=3)

    all_feature = fit_autoencoder(
        X_expand, rp_data[0]['image_size'], ae_data[0]['dimension_feature'],
        ae_data[0]['optimizer'], (3e-7) * (10**ae_data[0]['learning_rate']),
        ae_data[0]['activation_function'], ae_data[0]['loss_function'],
        ae_data[0]['batch_size'], ae_data[0]['epoch'])

    cluster = hierarchicalClustering(all_feature,
                                     hrc_data[0]['number_of_cluster'],
                                     hrc_data[0]['linkage'])

    send_result_data(result, hrc_data[0]['number_of_cluster'],
                     "RP Autoencoder & Hierarchy", cluster.labels_,
                     all_feature)
    return 0
Пример #5
0
def exct_rp_autoencoder_dbscan(n_clicks, rp_data, ae_data, dbs_data):
    print("RP Autoencoder & DBSCAN 실행중 입니다...")

    threshold = rp_data[0]['threshold']
    if threshold == 'None':
        threshold = None
    # init
    result, result_norm = initialize_data()

    result_resample = exec_ts_resampler(result_norm, rp_data[0]['image_size'])
    #(242,28,1)
    result_ = result_resample.reshape(result_resample.shape[0], 1,
                                      result_resample.shape[1])
    #(242,28,28)
    X = toRPdata(result_, rp_data[0]['dimension'], rp_data[0]['time_delay'],
                 threshold, rp_data[0]['percentage'] / 100)
    X_expand = np.expand_dims(X, axis=3)

    all_feature = fit_autoencoder(
        X_expand, rp_data[0]['image_size'], ae_data[0]['dimension_feature'],
        ae_data[0]['optimizer'], (3e-7) * (10**ae_data[0]['learning_rate']),
        ae_data[0]['activation_function'], ae_data[0]['loss_function'],
        ae_data[0]['batch_size'], ae_data[0]['epoch'])

    cluster = dbscan(all_feature,
                     eps=dbs_data[0]['epsilon'],
                     min_samples=dbs_data[0]['min_sample'])
    cluster_num = max(cluster.labels_) + 1
    send_result_data(result, cluster_num, "RP Autoencoder & DBSCAN",
                     cluster.labels_, all_feature)
    return []
Пример #6
0
def exct_ts_sample_tskmeans(n_clikcs, tsk_data, tsre_data):
    print("TimeSeriesResampler & TimeSeriesKMeans 실행중 입니다...")
    # init
    result, result_norm = initialize_data()

    min = result.dropna(axis='columns')
    min_len = len(
        min.columns
    ) if tsre_data[0]['dimension'] is None else tsre_data[0]['dimension']
    result_ = exec_ts_resampler(result_norm, min_len)
    cluster = ts_kmeans_clustering(result_, tsk_data[0]['number_of_cluster'],
                                   tsk_data[0]['try_n_init'],
                                   tsk_data[0]['distance_algorithm'])
    send_result_data(result, tsk_data[0]['number_of_cluster'],
                     "TimeSeriesResampler & TimeSeriesKMeans ",
                     cluster.labels_, result_.reshape(result_.shape[0],
                                                      min_len))
Пример #7
0
def exct_wavelet_hierarchy(n_clicks, wav_data, hrc_data):

    print("DWT & Hierarchy 중 입니다...")

    # init
    result, result_norm = initialize_data()

    min = result.dropna(axis='columns')
    min_len = len(min.columns)
    result_ = exec_ts_resampler(result_norm, min_len)
    result_ = result_.reshape(result_.shape[0], min_len)
    result_ = exec_wavelet(result_, wav_data[0]['wavelet_func'],
                           wav_data[0]['iter_to_half'])

    cluster = hierarchicalClustering(result_, hrc_data[0]['number_of_cluster'],
                                     hrc_data[0]['linkage'])
    send_result_data(result, hrc_data[0]['number_of_cluster'],
                     "DWT & Hierarchy", cluster.labels_, result_)
    return []
Пример #8
0
def exct_ts_sample_dbscan(n_clicks, dbs_data, tsre_data):
    print("Time Series Resampler & DBSCAN 중 입니다...")

    # init
    result, result_norm = initialize_data()

    min = result.dropna(axis='columns')
    min_len = len(
        min.columns
    ) if tsre_data[0]['dimension'] is None else tsre_data[0]['dimension']
    result_ = exec_ts_resampler(result_norm, min_len)
    result_ = result_.reshape(result_.shape[0], min_len)

    cluster = dbscan(result_,
                     eps=dbs_data[0]['epsilon'],
                     min_samples=dbs_data[0]['min_sample'])
    cluster_num = max(cluster.labels_) + 1
    send_result_data(result, cluster_num, "Time Series Resampler & DBSCAN ",
                     cluster.labels_, result_)
    return []
Пример #9
0
def exct_ts_sample_hierarchy(n_clicks, hrc_data, tsre_data):
    print("Time Series Resampler & Hierarchy 중 입니다...")
    print(hrc_data[0])
    # init
    result, result_norm = initialize_data()

    min = result.dropna(axis='columns')
    min_len = len(
        min.columns
    ) if tsre_data[0]['dimension'] is None else tsre_data[0]['dimension']
    result_ = exec_ts_resampler(result_norm, min_len)
    result_ = result_.reshape(result_.shape[0], min_len)

    cluster = hierarchicalClustering(result_, hrc_data[0]['number_of_cluster'],
                                     hrc_data[0]['linkage'])
    send_result_data(result, hrc_data[0]['number_of_cluster'],
                     "Time Series Resampler & Hierarchy", cluster.labels_,
                     result_)

    return 0
Пример #10
0
def exct_ts_sample_kmeans(n_clicks, km_data, tsre_data):
    print("Time Series Resampler & Kmeans 중 입니다...")
    # init
    result, result_norm = initialize_data()

    min = result.dropna(axis='columns')
    min_len = len(
        min.columns
    ) if tsre_data[0]['dimension'] is None else tsre_data[0]['dimension']
    result_ = exec_ts_resampler(result_norm, min_len)
    result_ = result_.reshape(result_.shape[0], min_len)

    cluster = kmeans(result_, km_data[0]['number_of_cluster'],
                     km_data[0]['tolerance'], km_data[0]['try_n_init'],
                     km_data[0]['try_n_kmeans'])
    send_result_data(result, km_data[0]['number_of_cluster'],
                     "Time Series Resampler & Kmeans", cluster.labels_,
                     result_)

    return 0
Пример #11
0
def exct_wavelet_dbscan(n_clicks, wav_data, dbs_data):
    print("DWT & Dbscan 중 입니다...")

    # init
    result, result_norm = initialize_data()

    min = result.dropna(axis='columns')
    min_len = len(min.columns)
    result_ = exec_ts_resampler(result_norm, min_len)
    result_ = result_.reshape(result_.shape[0], min_len)
    result_ = exec_wavelet(result_, wav_data[0]['wavelet_func'],
                           wav_data[0]['iter_to_half'])

    cluster = dbscan(result_,
                     eps=dbs_data[0]['epsilon'],
                     min_samples=dbs_data[0]['min_sample'])

    cluster_num = max(cluster.labels_) + 1

    send_result_data(result, cluster_num, "DWT & Dbscan", cluster.labels_,
                     result_)
    return []
Пример #12
0
def exct_wavelet_kmeans(n_clicks, wav_data, km_data):
    print(wav_data)
    print(km_data)
    print("DWT & Kmeans 중 입니다...")

    # init
    result, result_norm = initialize_data()

    min = result.dropna(axis='columns')
    min_len = len(min.columns)
    result_ = exec_ts_resampler(result_norm, min_len)
    result_ = result_.reshape(result_.shape[0], min_len)
    result_ = exec_wavelet(result_, wav_data[0]['wavelet_func'],
                           wav_data[0]['iter_to_half'])

    cluster = kmeans(result_, km_data[0]['number_of_cluster'],
                     km_data[0]['tolerance'], km_data[0]['try_n_init'],
                     km_data[0]['try_n_kmeans'])
    send_result_data(result, km_data[0]['number_of_cluster'], "DWT & Kmeans",
                     cluster.labels_, result_)

    return []