-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
74 lines (63 loc) · 3.23 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
__author__ = 'Elnaz Azmi'
__email__ = '[email protected]'
__status__ = 'Development'
import os
import preprocessing.dim_reduction as predim
import clustering.clustering as clusclus
import visualization.visualization as visvis
INPUTFILE = os.path.join(os.path.dirname(__file__), 'data/total_storage.csv')
INPUTCOMPTIME = os.path.join(os.path.dirname(__file__), 'data/hillslopes_computation_time.csv')
OUTPUTPATH = os.path.join(os.path.dirname(__file__), 'data/')
if __name__ == '__main__':
print('Reading the input data ...')
data = predim.read_data(INPUTFILE)
vis_indata = input('Visualize input data (y/n)? ')
if vis_indata == 'y':
visvis.plot_timeseries(data, 'total_storage')
else:
print('Processing ...')
df_AS, AS, TtE = predim.calc_active_storage(data)
vis_ac = input('Visualize active storage data (y/n)? ')
if vis_ac == 'y':
visvis.plot_timeseries(df_AS, 'active_storage')
else:
print('Processing ...')
df_Feature = predim.extr_features(df_AS, AS, TtE)
df_Feat_Norm = predim.norm_features(df_Feature)
df_Corr_pearson = predim.calc_correlation(df_Feat_Norm)
vis_corr = input('Visualize correlation coefficient of the features (y/n)? ')
if vis_corr == 'y':
visvis.plot_correlations(df_Corr_pearson, 'features_correlation')
else:
print('Processing ...')
df_Feat_Norm = predim.filt_features(df_Feat_Norm, df_Corr_pearson)
vis_elbow = input('Process elbow method and visualize (y/n)? ')
if vis_elbow == 'y':
distortions = clusclus.apply_elbow(df_Feat_Norm)
visvis.plot_elbow(distortions, 'elbow_kmeans')
else:
print('Processing ...')
df_HS_runtime = clusclus.read_data(INPUTCOMPTIME)
clust_method = input('Select one of the clustering methods from [kmeans, dbscan, kmedoids]: ')
if clust_method == 'kmeans':
df_RmseSum_Kmeans = clusclus.apply_kmeans(df_AS, df_Feat_Norm, df_HS_runtime)
df_Norm_Clust = clusclus.norm_rmse_ctime(df_RmseSum_Kmeans, df_HS_runtime)
visvis.plot_rmse_ctime(df_Norm_Clust, 'rmse_ctime_Kmeans')
elif clust_method == 'dbscan':
df_RmseSum_DBSCAN = clusclus.apply_DBSCAN(df_AS, df_Feat_Norm, df_HS_runtime)
df_Norm_Clust = clusclus.norm_rmse_ctime(df_RmseSum_DBSCAN, df_HS_runtime)
visvis.plot_rmse_ctime(df_Norm_Clust, 'rmse_ctime_dbscan')
elif clust_method == 'kmedoids':
df_RmseSum_Kmedoids = clusclus.apply_kmedoids(df_AS, df_Feat_Norm, df_HS_runtime)
df_Norm_Clust = clusclus.norm_rmse_ctime(df_RmseSum_Kmedoids, df_HS_runtime)
visvis.plot_rmse_ctime(df_Norm_Clust, 'rmse_ctime_Kmedoids')
else:
print('Enter a valid clustering method!')
vis_methods = input('Visualize the clustering methods in one plot (y/n)? ')
if vis_methods == 'y':
df_RmseSum_Kmeans = clusclus.apply_kmeans(df_AS, df_Feat_Norm, df_HS_runtime)
df_RmseSum_DBSCAN = clusclus.apply_DBSCAN(df_AS, df_Feat_Norm, df_HS_runtime)
df_RmseSum_Kmedoids = clusclus.apply_kmedoids(df_AS, df_Feat_Norm, df_HS_runtime)
visvis.plot_methods(df_RmseSum_Kmeans, df_RmseSum_DBSCAN, df_RmseSum_Kmedoids, 'rmse_ctime_all')
else:
print('The program is completed!')