def cluster_DBSCAN(data, eps=None, min_samples=None,<EOL>n_clusters=None, maxiter=<NUM_LIT:200>, **kwargs):
if n_clusters is None:<EOL><INDENT>if eps is None:<EOL><INDENT>eps = <NUM_LIT><EOL><DEDENT>db = cl.DBSCAN(eps=eps, min_samples=min_samples, **kwargs).fit(data)<EOL><DEDENT>else:<EOL><INDENT>clusters = <NUM_LIT:0><EOL>eps_temp = <NUM_LIT:1> / <NUM_LIT><EOL>niter = <NUM_LIT:0><EOL>while clusters < n_clusters:<EOL><INDENT>clusters_last = clusters<EOL>eps_temp *= <NUM_LIT><EOL>db = cl.DBSCAN(eps=eps_temp, min_samples=min_samples, **kwargs).fit(data)<EOL>clusters = (len(set(db.labels_)) -<EOL>(<NUM_LIT:1> if -<NUM_LIT:1> in db.labels_ else <NUM_LIT:0>))<EOL>if clusters < clusters_last:<EOL><INDENT>eps_temp *= <NUM_LIT:1> / <NUM_LIT><EOL>db = cl.DBSCAN(eps=eps_temp, min_samples=min_samples, **kwargs).fit(data)<EOL>clusters = (len(set(db.labels_)) -<EOL>(<NUM_LIT:1> if -<NUM_LIT:1> in db.labels_ else <NUM_LIT:0>))<EOL>warnings.warn(('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>').format(n_clusters, clusters, eps_temp))<EOL>break<EOL><DEDENT>niter += <NUM_LIT:1><EOL>if niter == maxiter:<EOL><INDENT>warnings.warn(('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>').format(maxiter, n_clusters))<EOL>break<EOL><DEDENT><DEDENT><DEDENT>labels = db.labels_<EOL>core_samples_mask = np.zeros_like(labels)<EOL>core_samples_mask[db.core_sample_indices_] = True<EOL>return labels, core_samples_mask<EOL>
Identify clusters using DBSCAN algorithm.

Parameters
----------
data : array_like
    array of size [n_samples, n_features].
eps : float
    The minimum 'distance' points must be apart for them to be in the
    same cluster. Defaults to 0.3. Note: If the data are normalised
    (they should be for DBSCAN) this is in terms of total sample
    variance.  Normalised data have a mean of 0 and a variance of 1.
min_samples : int
    The minimum number of samples within distance `eps` required
    to be considered as an independent cluster.
n_clusters : int
    The number of clusters expected. If specified, `eps` will be
    incrementally reduced until the expected number of clusters is
    found.
maxiter : int
    The maximum number of iterations DBSCAN will run.

Returns
-------
dict
    boolean array for each identified cluster and core samples.