| DayF core 1.2.1.2 DayF (Decision at your Fingertips) is an AutoML freeware development framework that let developers works with Machine Learning models without any idea of AI, simply taking a csv dataset and the objective column

h2oclusteringmetricmetadata.py
1
4
5 '''
6 Copyright (C) e2its - All Rights Reserved
7 * Unauthorized copying of this file, via any medium is strictly prohibited
8 * Proprietary and confidential
9 *
10 * This file is part of gDayF project.
11 *
12 * Written by Jose L. Sanchez <e2its.es@gmail.com>, 2016-2019
13 '''
14
15 '''
16 The basic ones
17 $betweenss: is the between clusters sum of squares. In fact it is the mean of distances between cluster centers.
18 One expects, this ratio, to be as higher as possible, since we would like to have heterogenous clusters.
19 2 · ( ∑m ∑n | CmP - CnP |2 ) / p · p - 1
20
21 $withinss: is the within cluster sum of squares. So it results in a vector with a number for each cluster.
22 One expects, this ratio, to be as lower as possible for each cluster,
23 since we would like to have homogeneity within the clusters.
24 ( ∑m | Xm - C |2 ) / p
25
26 Some equalities may help to understand:
27 $tot.withinss = sum ( $withinss )
28 $totss = $tot.withinss + $betweenss
29 '''
30 from gdayf.metrics.clusteringmetricmetadata import ClusteringMetricMetadata
31 from collections import OrderedDict
32 import json
33
34
35 # Class Base for Regression metricts as OrderedDict
36 #
37 # Base Metrics for Clustering
38 # [No expanded metrics]
39 class H2OClusteringMetricMetadata(ClusteringMetricMetadata):
40
41
43 def __init__(self):
44 ClusteringMetricMetadata.__init__(self)
45
46
47
50 def set_metrics(self, perf_metrics):
51 for parameter, _ in self.items():
52 try:
53 if perf_metrics is not None:
54 if parameter == 'centroid_stats':
55 self[parameter] = perf_metrics._metric_json[parameter].as_data_frame()
56 self['k'] = int(self[parameter]['centroid'].max())
57 self[parameter] = json.loads(self[parameter].to_json(orient='split'),
58 object_pairs_hook=OrderedDict)
59 else:
60 self[parameter] = perf_metrics._metric_json[parameter]
61 except KeyError as kexecution_error:
62 pass
63 #print('Trace: ' + repr(kexecution_error))
64 except AttributeError as aexecution_error:
65 print('Trace: ' + repr(aexecution_error))
66 except TypeError as texecution_error:
67 print('Trace: ' + repr(texecution_error))
68
gdayf.handler_metrics.h2oclusteringmetricmetadata.H2OClusteringMetricMetadata
Definition: h2oclusteringmetricmetadata.py:39
gdayf.metrics.clusteringmetricmetadata
Define Clustering Metric object as OrderedDict() of common measures for all frameworks on an unified ...
Definition: clusteringmetricmetadata.py:1
gdayf.metrics.clusteringmetricmetadata.ClusteringMetricMetadata
Definition: clusteringmetricmetadata.py:41
gdayf.handler_metrics.h2oclusteringmetricmetadata.H2OClusteringMetricMetadata.__init__
def __init__(self)
Method constructor.
Definition: h2oclusteringmetricmetadata.py:43
gdayf.handler_metrics.h2oclusteringmetricmetadata.H2OClusteringMetricMetadata.set_metrics
def set_metrics(self, perf_metrics)
Method to load Clustering metrics from H2OClusteringModelMetrics class.
Definition: h2oclusteringmetricmetadata.py:50