Skip to content

Commit 641da7b

Browse files
committed
experiments
1 parent a08353f commit 641da7b

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ cmake_minimum_required(VERSION 3.0)
88

99
#preferred compiler. TODO, make this optional
1010
# (see https://cmake.org/Wiki/CMake_FAQ#How_do_I_use_a_different_compiler.3F).
11-
SET (CMAKE_CXX_COMPILER "clang++")
11+
12+
#SET (CMAKE_CXX_COMPILER "clang++")
13+
#SET (CMAKE_CXX_COMPILER "g++")
1214

1315
project(zentas)
1416

python/experiments/experiments.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def go(X, K):
4545
C_init = X[indices_init]
4646

4747

48-
withskl = False
48+
withskl = True
4949
witheak = True
5050

5151
if withskl == True:
@@ -61,15 +61,15 @@ def go(X, K):
6161
sys.path.append("/home/james/clustering/idiap/eakmeans/lib")
6262
import kmeans
6363
teak0 = time.time()
64-
bla = kmeans.get_clustering(X, K, verbose = 1, init = indices_init, n_threads = 1)
64+
bla = kmeans.get_clustering(X, K, verbose = 1, init = indices_init, n_threads = 1)#, algorithm = "syin-ns")
6565
teak1 = time.time()
6666

6767

6868

69-
z = pyzentas.pyzen(K = K, metric = 'l2', energy = 'quadratic', max_itok = 0.0, max_time = .0, max_rounds = 0, seed = npr.randint(1000), patient = True, nthreads = 1, init = indices_init, with_tests = False, capture_output = False)
69+
z = pyzentas.pyzen(K = K, metric = 'l2', energy = 'quadratic', max_itok = 0.0, max_time = .0, max_rounds = 0, seed = npr.randint(1000), patient = True, nthreads = 1, init = indices_init, with_tests = True, capture_output = True)
7070
tzen0 = time.time()
7171
print X.shape
72-
tangerine = z.den(X, do_vdimap = False, do_refinement = True, rf_max_rounds = 10000000)#8, rf_alg = "yinyang")
72+
tangerine = z.den(X, do_vdimap = False, do_refinement = True, rf_max_rounds = 10000000, rf_alg = "exponion")
7373
tzen1 = time.time()
7474
print tangerine["output"].split("\n")[-2::]
7575

@@ -83,9 +83,12 @@ def go(X, K):
8383

8484

8585

86-
K = 500
86+
K = 50
8787
npr.seed(1000)
88-
X = npr.randn(50000, 8)
88+
#X = npr.randn(50000, 8)
89+
X = rna.get_rna()[0:5000, 2::]
90+
X += 0.01*npr.randn(X.shape[0], X.shape[1])
91+
8992
go(X, K)
9093

9194
def sklearn_elkan():

zentas/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include(EnableCompilerWarnings)
1+
include(EnableCompilerWarnings)
22
add_definitions(-std=c++11)
33

44
include_directories("include")

zentas/include/zentas/baseclusterer.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,10 @@ class Clusterer<LpMetric<typename TData::DataIn>, TData, TOpt>
424424
virtual void set_center_sample_distance(
425425
size_t k, size_t k1, size_t j1, double threshold, double& distance) override final
426426
{
427+
427428
metric.set_distance(
428-
centers_data.at_for_metric(k), cluster_datas[k1].at_for_metric(j1), threshold, distance);
429+
centers_data.at_for_metric(k), cluster_datas[k1].at_for_metric(j1), threshold, distance);
430+
429431
}
430432

431433
virtual void set_rf_center_sample_distance(

zentas/include/zentas/lpmetric.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ class TLpDistance : public BaseLpDistance<TNumber>
316316
double threshold,
317317
double& a_distance) override final
318318
{
319+
319320
++ncalcs;
320321
a_distance = 0;
321322
TNumber diff;
@@ -333,7 +334,12 @@ class TLpDistance : public BaseLpDistance<TNumber>
333334
}
334335
}
335336
calccosts += dimension;
337+
338+
339+
340+
//checked, not very slow.
336341
correct_distance(a_distance);
342+
337343
}
338344

339345
void set_distance(const SparseVectorSample<TNumber>& a,
@@ -613,7 +619,10 @@ class LpMetric
613619
* about 2% when dimension = 2. 2%
614620
* slowdown is negligible, I'm going
615621
* for this clean code. */
616-
uptr_lpdistance->set_distance(a, b, threshold, distance);
622+
623+
624+
uptr_lpdistance->set_distance(a, b, threshold, distance);
625+
617626
}
618627

619628
size_t get_ncalcs() const { return uptr_lpdistance->ncalcs; }

0 commit comments

Comments
 (0)