def fit(self, data_instance): # local data = self._select_columns(data_instance) n, normed = self._standardized(data) self.local_corr = table_dot(normed, normed) self.local_corr /= n if self.model_param.cross_parties: with SPDZ("pearson", local_party=self.local_party, all_parties=self.parties, use_mix_rand=self.model_param.use_mix_rand) as spdz: source = [normed, self.other_party] if self.local_party.role == "guest": x, y = FixedPointTensor.from_source( "x", source[0]), FixedPointTensor.from_source( "y", source[1]) else: y, x = FixedPointTensor.from_source( "y", source[0]), FixedPointTensor.from_source( "x", source[1]) m1 = len(x.value.first()[1]) m2 = len(y.value.first()[1]) self.shapes.append(m1) self.shapes.append(m2) self.corr = spdz.dot(x, y, "corr").get() / n else: self.shapes.append(self.local_corr.shape[0]) self.parties = [self.local_party] self._callback()
def fit(self, data_instance): # local data = self._select_columns(data_instance) n, normed = self._standardized(data) self.local_corr = table_dot(normed, normed) self.local_corr /= n self._summary["local_corr"] = self.local_corr.tolist() self._summary["num_local_features"] = n self.shapes.append(self.local_corr.shape[0]) return self._summary
def fit(self, data_instance): # local data = self._select_columns(data_instance) n, normed = self._standardized(data) self.local_corr = table_dot(normed, normed) self.local_corr /= n if self.model_param.calc_local_vif: self.local_vif = self._vif_from_pearson_matrix(self.local_corr) self._summary["local_corr"] = self.local_corr.tolist() self._summary["num_local_features"] = n if self.model_param.cross_parties: with SPDZ( "pearson", local_party=self.local_party, all_parties=self.parties, use_mix_rand=self.model_param.use_mix_rand, ) as spdz: source = [normed, self.other_party] if self.local_party.role == "guest": x, y = ( FixedPointTensor.from_source("x", source[0]), FixedPointTensor.from_source("y", source[1]), ) else: y, x = ( FixedPointTensor.from_source("y", source[0]), FixedPointTensor.from_source("x", source[1]), ) m1 = len(x.value.first()[1]) m2 = len(y.value.first()[1]) self.shapes.append(m1) self.shapes.append(m2) self.corr = spdz.dot(x, y, "corr").get() / n self._summary["corr"] = self.corr.tolist() self._summary["num_remote_features"] = ( m2 if self.local_party.role == "guest" else m1) else: self.shapes.append(self.local_corr.shape[0]) self.parties = [self.local_party] self._callback() self.set_summary(self._summary)
def fit(self, data_instance): data = self._select_columns(data_instance) n, normed = self._standardized(data) self.local_corr = table_dot(normed, normed) with SPDZ("pearson") as spdz: source = [normed, self._other_party] if self._local_party.role == "guest": x, y = FixedPointTensor.from_source( "x", source[0]), FixedPointTensor.from_source("y", source[1]) else: y, x = FixedPointTensor.from_source( "y", source[0]), FixedPointTensor.from_source("x", source[1]) m1 = len(x.value.first()[1]) m2 = len(y.value.first()[1]) self.shapes.append(m1) self.shapes.append(m2) self.corr = spdz.dot(x, y, "corr").get() / n self.local_corr /= n self._callback()