@@ -29,6 +29,7 @@ def harmonize(
29
29
random_state : int = 0 ,
30
30
use_gpu : bool = False ,
31
31
n_jobs : int = - 1 ,
32
+ verbose : bool = True ,
32
33
) -> np .array :
33
34
"""
34
35
Integrate data using Harmony algorithm.
@@ -87,6 +88,9 @@ def harmonize(
87
88
n_jobs: ``int``, optional, default ``-1``
88
89
How many CPU threads to use. By default, use all physical cores. If 'use_gpu' is True, this option only affects the KMeans step.
89
90
91
+ verbose: ``bool``, optional, default ``True``
92
+ If ``True``, print verbose output.
93
+
90
94
Returns
91
95
-------
92
96
``numpy.array``
@@ -114,9 +118,11 @@ def harmonize(
114
118
if use_gpu :
115
119
if torch .cuda .is_available ():
116
120
device_type = "cuda"
117
- print ("Use GPU mode." )
121
+ if verbose :
122
+ print ("Use GPU mode." )
118
123
else :
119
- print ("CUDA is not available on your machine. Use CPU mode instead." )
124
+ if verbose :
125
+ print ("CUDA is not available on your machine. Use CPU mode instead." )
120
126
121
127
(stride_0 , stride_1 ) = X .strides
122
128
if stride_0 < 0 or stride_1 < 0 :
@@ -167,7 +173,8 @@ def harmonize(
167
173
n_jobs ,
168
174
)
169
175
170
- print ("\t Initialization is completed." )
176
+ if verbose :
177
+ print ("\t Initialization is completed." )
171
178
172
179
for i in range (max_iter_harmony ):
173
180
clustering (
@@ -189,15 +196,17 @@ def harmonize(
189
196
Z_hat = correction (Z , R , Phi , O , ridge_lambda , correction_method , device_type )
190
197
Z_norm = normalize (Z_hat , p = 2 , dim = 1 )
191
198
192
- print (
193
- "\t Completed {cur_iter} / {total_iter} iteration(s)." .format (
194
- cur_iter = i + 1 ,
195
- total_iter = max_iter_harmony ,
199
+ if verbose :
200
+ print (
201
+ "\t Completed {cur_iter} / {total_iter} iteration(s)." .format (
202
+ cur_iter = i + 1 ,
203
+ total_iter = max_iter_harmony ,
204
+ )
196
205
)
197
- )
198
206
199
207
if is_convergent_harmony (objectives_harmony , tol = tol_harmony ):
200
- print ("Reach convergence after {} iteration(s)." .format (i + 1 ))
208
+ if verbose :
209
+ print ("Reach convergence after {} iteration(s)." .format (i + 1 ))
201
210
break
202
211
203
212
if device_type == "cpu" :
0 commit comments