Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions configs/experiments/dbscan_metrics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"INCLUDE": ["../common/sklearn.json"],
"PARAMETERS_SETS": {
"dbscan metrics": {
"algorithm": {
"estimator": "DBSCAN",
"estimator_params": [
{ "metric": "euclidean" },
{ "metric": "manhattan" },
{ "metric": "chebyshev" },
{ "metric": "cosine" },
{ "metric": "minkowski", "p": 3 }
]
}
},
"dbscan eps and jobs": {
"algorithm": {
"estimator_params": {
"eps": "[SPECIAL_VALUE]distances_quantile:0.01",
"min_samples": 5,
"n_jobs": "[SPECIAL_VALUE]physical_cpus"
}
},
"bench": { "n_runs": 5, "time_limit": 900 }
},
"sklearn brute and tree": [
{ "algorithm": { "library": "sklearn", "device": "cpu", "estimator_params": { "algorithm": "brute" } } },
{ "algorithm": { "library": "sklearn", "device": "cpu", "estimator_params": { "algorithm": "auto" } } }
],
"sklearnex cpu": {
"algorithm": { "library": "sklearnex", "device": "cpu", "estimator_params": { "algorithm": "brute" } }
},
"sklearnex gpu": {
"algorithm": {
"library": "sklearnex",
"device": "gpu",
"estimator_params": { "algorithm": "brute" },
"sklearn_context": { "array_api_dispatch": true }
},
"data": { "format": "dpnp", "order": "C" }
},
"dbscan datasets": {
"data": [
{
"source": "make_blobs",
"generation_kwargs": [
{ "centers": 20, "n_samples": 50000, "n_features": 8, "cluster_std": 1.0 },
{ "centers": 20, "n_samples": 200000, "n_features": 8, "cluster_std": 1.0 },
{ "centers": 20, "n_samples": 100000, "n_features": 32, "cluster_std": 1.0 },
{ "centers": 20, "n_samples": 50000, "n_features": 256, "cluster_std": 1.0 },
{ "centers": 100, "n_samples": 500000, "n_features": 2, "cluster_std": 1.0 }
],
Comment thread
david-cortes-intel marked this conversation as resolved.
Resolved
"split_kwargs": { "ignore": true }
},
{
"dataset": "cifar",
"split_kwargs": { "ignore": true },
"preprocessing_kwargs": { "normalize": "mean" }
},
{
"dataset": "covtype",
"split_kwargs": { "train_size": 100000, "test_size": null },
"preprocessing_kwargs": { "normalize": "standard" }
}
]
}
},
"TEMPLATES": {
"sklearn dbscan": {
"SETS": ["sklearn brute and tree", "dbscan metrics", "dbscan eps and jobs", "dbscan datasets"]
},
"sklearnex cpu dbscan": {
"SETS": ["sklearnex cpu", "dbscan metrics", "dbscan eps and jobs", "dbscan datasets"]
},
"sklearnex gpu dbscan": {
"SETS": ["sklearnex gpu", "dbscan metrics", "dbscan eps and jobs", "dbscan datasets"]
}
}
}
2 changes: 1 addition & 1 deletion sklbench/benchmarks/sklearn_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def get_subset_metrics_of_estimator(
)
}
)
if len(np.unique(y)) < 128:
if len(np.unique(y_compat)) < 128:
metrics.update(
{
"homogeneity": (
Expand Down
15 changes: 13 additions & 2 deletions sklbench/utils/special_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import numpy as np
import pandas as pd
from psutil import cpu_count
from sklearn.metrics import euclidean_distances
from sklearn.metrics import pairwise_distances

from ..datasets import dataset_loading_functions
from .bench_case import get_bench_case_value, set_bench_case_value
Expand Down Expand Up @@ -288,7 +288,18 @@ def assign_case_special_values_on_run(
# conversion to lower precision is required
# to produce same distances quantile for different dtypes of x
x_sample = x_sample.astype("float32")
dist = np.tril(euclidean_distances(x_sample, x_sample)).reshape(-1)
# the quantile is taken in the estimator's own metric, so eps has the right scale
metric = get_bench_case_value(
bench_case, "algorithm:estimator_params:metric", "euclidean"
)
metric_kwargs = {}
if metric == "minkowski":
metric_kwargs["p"] = get_bench_case_value(
bench_case, "algorithm:estimator_params:p", 2
)
dist = np.tril(
pairwise_distances(x_sample, x_sample, metric=metric, **metric_kwargs)
).reshape(-1)
dist = dist[dist != 0]
quantile = float(np.quantile(dist, quantile))
set_bench_case_value(bench_case, "algorithm:estimator_params:eps", quantile)