예제 #1
0
    def cluster_label(self, cluster_label):
        if not isinstance(cluster_label, int):
            raise e.TypeError('`cluster_label` should be an integer')
        if cluster_label < 0:
            raise e.ValueError('`cluster_label` should be >= 0')

        self._cluster_label = cluster_label
예제 #2
0
    def predicted_label(self, predicted_label):
        if not isinstance(predicted_label, int):
            raise e.TypeError('`predicted_label` should be an integer')
        if predicted_label < 0:
            raise e.ValueError('`predicted_label` should be >= 0')

        self._predicted_label = predicted_label
예제 #3
0
    def label(self, label):
        if not isinstance(label, int):
            raise e.TypeError('`label` should be an integer')
        if label < 1:
            raise e.ValueError('`label` should be >= 1')

        self._label = label
예제 #4
0
    def min_k(self, min_k):
        if not isinstance(min_k, int):
            raise e.TypeError('`min_k` should be an integer')
        if min_k < 1:
            raise e.ValueError('`min_k` should be >= 1')

        self._min_k = min_k
예제 #5
0
    def pred(self, pred):
        if not isinstance(pred, int):
            raise e.TypeError('`pred` should be an integer')
        if pred < c.NIL:
            raise e.ValueError(
                '`pred` should have a value larger than `NIL`, e.g., -1')

        self._pred = pred
예제 #6
0
    def _read_distances(self, file_path):
        """Reads the distance between nodes from a pre-defined file.

        Args:
            file_path (str): File to be loaded.

        Returns:
            A matrix with pre-computed distances.

        """

        logger.debug('Running private method: read_distances().')

        # Getting file extension
        extension = file_path.split('.')[-1]

        # Check if extension is .csv
        if extension == 'csv':
            # If yes, call the method that actually loads csv
            distances = loader.load_csv(file_path)

        # Check if extension is .txt
        elif extension == 'txt':
            # If yes, call the method that actually loads txt
            distances = loader.load_txt(file_path)

        # If extension is not recognized
        else:
            # Raises an ArgumentError exception
            raise e.ArgumentError(
                'File extension not recognized. It should be either `.csv` or .txt`')

        # Check if distances have been properly loaded
        if distances is None:
            # If not, raises a ValueError
            raise e.ValueError(
                'Pre-computed distances could not been properly loaded')

        return distances
예제 #7
0
    def policy(self, policy):
        if policy not in ['min', 'max']:
            raise e.ValueError('`policy` should be `min` or `max`')

        self._policy = policy