Skip to content

Commit 22949e8

Browse files
committed
Only time DBSCAN.fit
1 parent 97ecf0c commit 22949e8

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

sklearn/dbscan.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
parser = argparse.ArgumentParser(description='scikit-learn DBSCAN benchmark')
1111
parser.add_argument('-x', '--filex', '--fileX', '--input', required=True,
1212
type=str, help='Points to cluster')
13-
parser.add_argument('-e', '--eps', '--epsilon', type=float, default=0.5,
13+
parser.add_argument('-e', '--eps', '--epsilon', type=float, default=10,
1414
help='Radius of neighborhood of a point')
1515
parser.add_argument('-m', '--data-multiplier', default=100,
1616
type=int, help='Data multiplier')
1717
parser.add_argument('-M', '--min-samples', default=5, type=int,
1818
help='The minimum number of samples required in a '
1919
'neighborhood to consider a point a core point')
20-
params = parse_args(parser, loop_types=('fit', 'predict'), n_jobs_supported=True)
20+
params = parse_args(parser, n_jobs_supported=True)
2121

2222
# Load generated data
2323
X = np.load(params.filex)
@@ -38,20 +38,12 @@
3838
print_header(columns, params)
3939

4040
# Time fit
41-
fit_time, _ = time_mean_min(dbscan.fit, X,
42-
outer_loops=params.fit_outer_loops,
43-
inner_loops=params.fit_inner_loops,
44-
goal_outer_loops=params.fit_goal,
45-
time_limit=params.fit_time_limit,
46-
verbose=params.verbose)
47-
params.n_clusters = len(dbscan.core_sample_indices_)
48-
print_row(columns, params, function='DBSCAN.fit', time=fit_time)
49-
50-
# Time predict
51-
predict_time, _ = time_mean_min(dbscan.fit_predict, X,
52-
outer_loops=params.predict_outer_loops,
53-
inner_loops=params.predict_inner_loops,
54-
goal_outer_loops=params.predict_goal,
55-
time_limit=params.predict_time_limit,
56-
verbose=params.verbose)
57-
print_row(columns, params, function='DBSCAN.fit_predict', time=predict_time)
41+
time, _ = time_mean_min(dbscan.fit, X,
42+
outer_loops=params.outer_loops,
43+
inner_loops=params.inner_loops,
44+
goal_outer_loops=params.goal,
45+
time_limit=params.time_limit,
46+
verbose=params.verbose)
47+
labels = dbscan.labels_
48+
params.n_clusters = len(set(labels)) - (1 if -1 in labels else 0)
49+
print_row(columns, params, function='DBSCAN', time=time)

0 commit comments

Comments
 (0)