Beispiel #1
0
    def calculate(self, validation_name, cluster_name, source_name='parent'):
        """
		Calls the function titled by validation_name on the data matrix set by source_name (default 'parent') and clustering solution by cluster_name
		Appends to validation with key value equal to the validation_name+source_name+cluster_name

		Returns
		-------
		output_name: str
			The handle name for accessing validation results
		"""

        output_name = "%s_%s_%s" % (validation_name, source_name, cluster_name)

        #check that the validation has not already been calcluated
        if output_name in self.validation:
            warnings.warn(
                'Validation of type requested already exists and will not be added to validation dictionary',
                UserWarning)
            return

        #CHECK that the source exists
        if source_name not in self.dataObj.D:
            raise ValueError(
                "ERROR: the source you requested for validation does not exist by that name %s"
                % (source_name))
        if cluster_name not in self.cObj.labels:
            raise ValueError(
                "ERROR: the clustering solution you requested for validation does not exist by the name %s"
                % (source_name))

        FCN_DICT = self.validation_metrics_available()

        if validation_name not in FCN_DICT:
            raise ValueError(
                "The validation metric you requested does not exist, currently the following are supported %s"
                % (list(FCN_DICT.keys())))

        v = val.validation(self.dataObj.D[source_name],
                           self.cObj.labels[cluster_name])
        func = getattr(v, validation_name)
        func()

        self.validation[output_name] = v.validation
        self.description[output_name] = v.description
        self.source_name[output_name] = source_name
        self.cluster_name[output_name] = cluster_name

        return output_name
Beispiel #2
0
 def validation_metrics_available(self):
     """ Return all available validation metrics """
     validation = val.validation(self.dataObj.D['parent'], [])
     FCN_DICT = validation.validation_metrics_available()
     return FCN_DICT