Source code for qumin.clustering

# -*- coding: utf-8 -*-
# !/usr/bin/env python3

import numpy as np
import pandas as pd


[docs] def find_min_attribute(tree, attr): """Find the minimum value for an attribute in a tree. Arguments: tree (node.Node): The tree in which to find the minimum attribute. attr (str): the attribute's key.""" agenda = [tree] mini = np.inf while agenda: node = agenda.pop(0) if node.children: agenda.extend(node.children) if attr in node.attributes and float(node.attributes[attr]) < mini: mini = node.attributes[attr] return mini