-
Notifications
You must be signed in to change notification settings - Fork 0
/
script_template_methods.py
103 lines (83 loc) · 2.97 KB
/
script_template_methods.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
'''
methods file for sypder etc...
'''
'''
File / Package Import
'''
# supress warnings
import warnings
warnings.simplefilter('ignore')
'''
Methods
'''
def def_Methods(list_cluster_results, array_sparse_matrix):
'''
below is an example of a good method comment
-------------------------------------------------------------------------------------------#
this method implements the evauluation criterea for the clusters of each clutering algorithms
criterea:
- 1/2 of the clusters for each result need to be:
- the average silhouette score of the cluster needs to be higher then the silhouette score of all the clusters
combined
- the standard deviation of the clusters need to be lower than the standard deviation of all the clusters
combined
- silhouette value for the dataset must be greater than 0.5
Requirements:
package time
package numpy
package statistics
package sklearn.metrics
Inputs:
list_cluster_results
Type: list
Desc: the list of parameters for the clustering object
list[x][0] -> type: array; of cluster results by sample in the order of the sample row passed as indicated by the sparse
or dense array
list[x][1] -> type: string; the cluster ID with the parameters
array_sparse_matrix
Type: numpy array
Desc: a sparse matrix of the samples used for clustering
Important Info:
None
Return:
object
Type: list
Desc: this of the clusters that meet the evaluation criterea
list[x][0] -> type: array; of cluster results by sample in the order of the sample row passed as indicated by the sparse
or dense array
list[x][1] -> type: string; the cluster ID with the parameters
list[x][2] -> type: float; silhouette average value for the entire set of data
list[x][3] -> type: array; 1 dimensional array of silhouette values for each data sample
list[x][4] -> type: list; list of lists, the cluster and the average silhoutte value for each cluster, the orders is sorted
highest to lowest silhoutte value
list[x][4][x][0] -> int; cluster label
list[x][4][x][1] -> float; cluster silhoutte value
list[x][5] -> type: list; a list that contains the cluster label and the number of samples in each cluster
list[x][5][x][0] -> int; cluster label
list[x][5][x][1] -> int; number of samples in cluster list[x][5][x][0]
'''
'''
objects declarations
'''
'''
sequence declarations (list, set, tuple, counter, dictionary)
'''
'''
variables declarations
'''
'''
Start
'''
'''
sub-section comment
'''
'''
sectional comment
'''
'''
variable / object cleanup
'''
'''
return value
'''
return