File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,23 @@ def standardize(X, flag_1d = False):
200200 X_std = (X - m ) / std
201201 return X_std
202202
203+ def min_max_standardize (X , target_max , target_min ):
204+ '''
205+ Parameters
206+ ----------
207+ X : numpy array of size (N, D)
208+ target_max : target max value after transformation
209+ target_min : target min value after transformation
210+
211+ Returns
212+ -------
213+ Transformed X with value range from (target_min, target_max)
214+
215+ '''
216+ X_std = (X - X .min (axis = 0 )) / (X .max (axis = 0 ) - X .min (axis = 0 ))
217+ X_scaled = X_std * (target_max - target_min ) + target_min
218+ return X_scaled
219+
203220def get_vector_norm (X , k ):
204221 '''
205222 Parameters
@@ -217,3 +234,7 @@ def get_vector_norm(X, k):
217234 return np .sum (np .power (X_abs , k )) ** (1 / k )
218235 #return np.linalg.norm(X, k)
219236
237+ def get_covariance_matrix (X ):
238+ N = X .shape [0 ]
239+ return (1 / (N - 1 )) * (X - X .mean (axis = 0 )).T .dot (X - X .mean (axis = 0 ))
240+ #return np.cov(X.T, ddof=1)
You can’t perform that action at this time.
0 commit comments