Ejemplo n.º 1
0
 def score(self, X, coef=None):
     if coef is None:
         coef = self.coef_
     from info_measures.continuous import kraskov_stoegbauer_grassberger as ksg
     X_lag = form_lag_matrix(X.dot(coef), 2 * self.T)
     mi = ksg.MutualInformation(X_lag[:, :self.T], X_lag[:, self.T:])
     pi = mi.mutual_information()
     return pi
Ejemplo n.º 2
0
 def f(v_flat):
     v = v_flat.reshape(N, d)
     X_lag = form_lag_matrix(X.dot(v), 2 * self.T)
     mi = ksg.MutualInformation(X_lag[:, :self.T], X_lag[:, self.T:])
     pi = mi.mutual_information()
     reg_val = ortho_reg_fn(v, self.ortho_lambda)
     loss = -pi + reg_val
     return loss
Ejemplo n.º 3
0
 def callback(v_flat):
     v = v_flat.reshape(N, d)
     X_lag = form_lag_matrix(X.dot(v), 2 * self.T)
     mi = ksg.MutualInformation(X_lag[:, :self.T * d],
                                X_lag[:, self.T * d:])
     pi = mi.mutual_information()
     reg_val = ortho_reg_fn(v, self.ortho_lambda)
     print("PI: {} bits, reg: {}".format(str(np.round(pi, 4)),
                                         str(np.round(reg_val, 4))))
 def calc_pi_fn_knn(V):
     X_proj = np.dot(X, V)
     X_proj_lags = form_lag_matrix(X_proj, 2 * T_pi)
     mi = ksg.MutualInformation(X_proj_lags[:, :T_pi], X_proj_lags[:, T_pi:], add_noise=True)
     pi = mi.mutual_information(n_jobs=n_jobs)
     return pi