package scipy

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `ClusterNode
]
type t = [ `ClusterNode | `Object ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val create : ?left:Py.Object.t -> ?right:Py.Object.t -> ?dist:float -> ?count:int -> id:int -> unit -> t

A tree node class for representing a cluster.

Leaf nodes correspond to original observations, while non-leaf nodes correspond to non-singleton clusters.

The `to_tree` function converts a matrix returned by the linkage function into an easy-to-use tree representation.

All parameter names are also attributes.

Parameters ---------- id : int The node id. left : ClusterNode instance, optional The left child tree node. right : ClusterNode instance, optional The right child tree node. dist : float, optional Distance for this cluster in the linkage matrix. count : int, optional The number of samples in this cluster.

See Also -------- to_tree : for converting a linkage matrix ``Z`` into a tree object.

val get_count : [> tag ] Obj.t -> int

The number of leaf nodes (original observations) belonging to the cluster node nd. If the target node is a leaf, 1 is returned.

Returns ------- get_count : int The number of leaf nodes below the target node.

val get_id : [> tag ] Obj.t -> int

The identifier of the target node.

For ``0 <= i < n``, `i` corresponds to original observation i. For ``n <= i < 2n-1``, `i` corresponds to non-singleton cluster formed at iteration ``i-n``.

Returns ------- id : int The identifier of the target node.

val get_left : [> tag ] Obj.t -> Py.Object.t

Return a reference to the left child tree object.

Returns ------- left : ClusterNode The left child of the target node. If the node is a leaf, None is returned.

val get_right : [> tag ] Obj.t -> Py.Object.t

Return a reference to the right child tree object.

Returns ------- right : ClusterNode The left child of the target node. If the node is a leaf, None is returned.

val is_leaf : [> tag ] Obj.t -> bool

Return True if the target node is a leaf.

Returns ------- leafness : bool True if the target node is a leaf node.

val pre_order : ?func:Py.Object.t -> [> tag ] Obj.t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Perform pre-order traversal without recursive function calls.

When a leaf node is first encountered, ``func`` is called with the leaf node as its argument, and its result is appended to the list.

For example, the statement::

ids = root.pre_order(lambda x: x.id)

returns a list of the node ids corresponding to the leaf nodes of the tree as they appear from left to right.

Parameters ---------- func : function Applied to each leaf ClusterNode object in the pre-order traversal. Given the ``i``-th leaf node in the pre-order traversal ``ni``, the result of ``func(ni)`` is stored in ``Li``. If not provided, the index of the original observation to which the node corresponds is used.

Returns ------- L : list The pre-order traversal.

val to_string : t -> string

Print the object to a human-readable representation.

val show : t -> string

Print the object to a human-readable representation.

val pp : Format.formatter -> t -> unit

Pretty-print the object to a formatter.

OCaml

Innovation. Community. Security.