Class: OPTICS
Estimate clustering structure from vector array.
OPTICS (Ordering Points To Identify the Clustering Structure), closely related to DBSCAN, finds core sample of high density and expands clusters from them [1]. Unlike DBSCAN, keeps cluster hierarchy for a variable neighborhood radius. Better suited for usage on large datasets than the current sklearn implementation of DBSCAN.
Clusters are then extracted using a DBSCAN-like method (cluster_method = ‘dbscan’) or an automatic technique proposed in [1] (cluster_method = ‘xi’).
This implementation deviates from the original OPTICS by first performing k-nearest-neighborhood searches on all points to identify core sizes, then computing only the distances to unprocessed points when constructing the cluster order. Note that we do not employ a heap to manage the expansion candidates, so the time complexity will be O(n^2).
Read more in the User Guide.
Constructors
new OPTICS()
new OPTICS(
opts
?):OPTICS
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.algorithm ? | "auto" | "ball_tree" | "kd_tree" | "brute" | Algorithm used to compute the nearest neighbors: |
opts.cluster_method ? | string | The extraction method used to extract clusters using the calculated reachability and ordering. Possible values are “xi” and “dbscan”. |
opts.eps ? | number | The maximum distance between two samples for one to be considered as in the neighborhood of the other. By default it assumes the same value as max_eps . Used only when cluster_method='dbscan' . |
opts.leaf_size ? | number | Leaf size passed to BallTree or KDTree . This can affect the speed of the construction and query, as well as the memory required to store the tree. The optimal value depends on the nature of the problem. |
opts.max_eps ? | number | The maximum distance between two samples for one to be considered as in the neighborhood of the other. Default value of np.inf will identify clusters across all scales; reducing max_eps will result in shorter run times. |
opts.memory ? | string | Used to cache the output of the computation of the tree. By default, no caching is done. If a string is given, it is the path to the caching directory. |
opts.metric ? | string | Metric to use for distance computation. Any metric from scikit-learn or scipy.spatial.distance can be used. If metric is a callable function, it is called on each pair of instances (rows) and the resulting value recorded. The callable should take two arrays as input and return one value indicating the distance between them. This works for Scipy’s metrics, but is less efficient than passing the metric name as a string. If metric is “precomputed”, X is assumed to be a distance matrix and must be square. Valid values for metric are: |
opts.metric_params ? | any | Additional keyword arguments for the metric function. |
opts.min_cluster_size ? | any | Minimum number of samples in an OPTICS cluster, expressed as an absolute number or a fraction of the number of samples (rounded to be at least 2). If undefined , the value of min_samples is used instead. Used only when cluster_method='xi' . |
opts.min_samples ? | any | The number of samples in a neighborhood for a point to be considered as a core point. Also, up and down steep regions can’t have more than min_samples consecutive non-steep points. Expressed as an absolute number or a fraction of the number of samples (rounded to be at least 2). |
opts.n_jobs ? | number | The number of parallel jobs to run for neighbors search. undefined means 1 unless in a joblib.parallel_backend context. \-1 means using all processors. See Glossary for more details. |
opts.p ? | number | Parameter for the Minkowski metric from pairwise_distances . When p = 1, this is equivalent to using manhattan_distance (l1), and euclidean_distance (l2) for p = 2. For arbitrary p, minkowski_distance (l_p) is used. |
opts.predecessor_correction ? | boolean | Correct clusters according to the predecessors calculated by OPTICS [2]. This parameter has minimal effect on most datasets. Used only when cluster_method='xi' . |
opts.xi ? | any | Determines the minimum steepness on the reachability plot that constitutes a cluster boundary. For example, an upwards point in the reachability plot is defined by the ratio from one point to its successor being at most 1-xi. Used only when cluster_method='xi' . |
Returns OPTICS
Defined in generated/cluster/OPTICS.ts:29
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/cluster/OPTICS.ts:27 |
_isInitialized | boolean | false | generated/cluster/OPTICS.ts:26 |
_py | PythonBridge | undefined | generated/cluster/OPTICS.ts:25 |
id | string | undefined | generated/cluster/OPTICS.ts:22 |
opts | any | undefined | generated/cluster/OPTICS.ts:23 |
Accessors
cluster_hierarchy_
Get Signature
get cluster_hierarchy_():
Promise
<ArrayLike
[]>
The list of clusters in the form of \[start, end\]
in each row, with all indices inclusive. The clusters are ordered according to (end, \-start)
(ascending) so that larger clusters encompassing smaller clusters come after those smaller ones. Since labels_
does not reflect the hierarchy, usually len(cluster_hierarchy_) > np.unique(optics.labels_)
. Please also note that these indices are of the ordering_
, i.e. X\[ordering_\]\[start:end + 1\]
form a cluster. Only available when cluster_method='xi'
.
Returns Promise
<ArrayLike
[]>
Defined in generated/cluster/OPTICS.ts:423
core_distances_
Get Signature
get core_distances_():
Promise
<ArrayLike
>
Distance at which each sample becomes a core point, indexed by object order. Points which will never be core have a distance of inf. Use clust.core_distances_\[clust.ordering_\]
to access in cluster order.
Returns Promise
<ArrayLike
>
Defined in generated/cluster/OPTICS.ts:375
feature_names_in_
Get Signature
get feature_names_in_():
Promise
<ArrayLike
>
Names of features seen during fit. Defined only when X
has feature names that are all strings.
Returns Promise
<ArrayLike
>
Defined in generated/cluster/OPTICS.ts:471
labels_
Get Signature
get labels_():
Promise
<ArrayLike
>
Cluster labels for each point in the dataset given to fit(). Noisy samples and points which are not included in a leaf cluster of cluster_hierarchy_
are labeled as -1.
Returns Promise
<ArrayLike
>
Defined in generated/cluster/OPTICS.ts:307
n_features_in_
Get Signature
get n_features_in_():
Promise
<number
>
Number of features seen during fit.
Returns Promise
<number
>
Defined in generated/cluster/OPTICS.ts:448
ordering_
Get Signature
get ordering_():
Promise
<ArrayLike
>
The cluster ordered list of sample indices.
Returns Promise
<ArrayLike
>
Defined in generated/cluster/OPTICS.ts:352
predecessor_
Get Signature
get predecessor_():
Promise
<ArrayLike
>
Point that a sample was reached from, indexed by object order. Seed points have a predecessor of -1.
Returns Promise
<ArrayLike
>
Defined in generated/cluster/OPTICS.ts:400
py
Get Signature
get py():
PythonBridge
Returns PythonBridge
Set Signature
set py(
pythonBridge
):void
Parameters
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
Returns void
Defined in generated/cluster/OPTICS.ts:124
reachability_
Get Signature
get reachability_():
Promise
<ArrayLike
>
Reachability distances per sample, indexed by object order. Use clust.reachability_\[clust.ordering_\]
to access in cluster order.
Returns Promise
<ArrayLike
>
Defined in generated/cluster/OPTICS.ts:329
Methods
dispose()
dispose():
Promise
<void
>
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Returns Promise
<void
>
Defined in generated/cluster/OPTICS.ts:175
fit()
fit(
opts
):Promise
<any
>
Perform OPTICS clustering.
Extracts an ordered list of points and reachability distances, and performs initial clustering using max_eps
distance specified at OPTICS object instantiation.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | any | A feature array, or array of distances between samples if metric=’precomputed’. If a sparse matrix is provided, it will be converted into CSR format. |
opts.y ? | any | Not used, present for API consistency by convention. |
Returns Promise
<any
>
Defined in generated/cluster/OPTICS.ts:194
fit_predict()
fit_predict(
opts
):Promise
<ArrayLike
>
Perform clustering on X
and returns cluster labels.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.kwargs ? | any | Arguments to be passed to fit . |
opts.X ? | ArrayLike [] | Input data. |
opts.y ? | any | Not used, present for API consistency by convention. |
Returns Promise
<ArrayLike
>
Defined in generated/cluster/OPTICS.ts:231
get_metadata_routing()
get_metadata_routing(
opts
):Promise
<any
>
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.routing ? | any | A MetadataRequest encapsulating routing information. |
Returns Promise
<any
>
Defined in generated/cluster/OPTICS.ts:275
init()
init(
py
):Promise
<void
>
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Parameters
Parameter | Type |
---|---|
py | PythonBridge |
Returns Promise
<void
>
Defined in generated/cluster/OPTICS.ts:137