Exemple #1
0
 def build_proxy(self, *, source, trained):
     self.data[("value_predicted", "classes")] = ProxyContainer(
         lambda : trained.data[("value_statistics", "classes")],
         Header,
     )
     self.data[("value_predicted", "probability")] = ProxyContainer(
         lambda: trained.data[("value_statistics", "probability")].reshape(1,-1) * np.ones(source.data["representation"].shape[0], dtype=np.float).reshape(-1,1),
         Table,
     )
Exemple #2
0
 def build_proxy(self, *, source, trained):
     rfc = trained.rfc.fit(
         trained.source.data["representation"],
         trained.source.data["value"],
     )
     self.data[("value_predicted", "classes")] = ProxyContainer(
         lambda: rfc.classes_,
         Header,
     )
     self.data[("value_predicted", "probability")] = ProxyContainer(
         lambda: rfc.predict_proba(source.data["representation"]),
         Table,
     )
Exemple #3
0
 def build_proxy(self, *, source, trained):
     self.data["value_predicted"] = ProxyContainer(
         lambda : np.sum(
             source.data["representation"] * trained.data["w"],
             axis=1,
         ) + trained.data["b"],
         Table,
     )
Exemple #4
0
 def build_proxy(self, *, source, trained):
     etr = trained.etr.fit(
         trained.source.data["representation"],
         trained.source.data["value"],
     )
     self.data["value_predicted"] = ProxyContainer(
         lambda: etr.predict(source.data["representation"]),
         Table,
     )
Exemple #5
0
 def build_proxy(self, *, source, trained):
     self.data["value_predicted"] = ProxyContainer(
         lambda : np.array(
             [np.mean(trained.data["value_original"][_idx]) \
                 for _idx in np.argsort(
                     -source.data["representation"],
                     axis=1,
                 )[:,:trained.data["k"]]]
         ),
         Table,
     )
Exemple #6
0
    def build_proxy(self, *, source, trained):
        self.data[("value_predicted", "classes")] = ProxyContainer(
            lambda: np.array([0, 1], dtype=np.int),
            Header,
        )

        def f():
            x = source.data["representation"]
            w = trained.data["w"]
            b = trained.data["b"]
            # predict value == 1
            result = np.zeros((x.shape[0], 2), dtype=np.float)
            result[:, 1] = expit(np.sum(x * w, axis=1) + b)
            result[:, 0] = 1 - result[:, 1]
            return result

        self.data[("value_predicted", "probability")] = ProxyContainer(
            f,
            Table,
        )
Exemple #7
0
    def build_proxy(self, *, source, trained):
        self.data[("value_predicted", "classes")] = ProxyContainer(
            lambda: np.unique(trained.data["value_original"]),
            Header,
        )

        def f():
            k = trained.data["k"]
            idx = np.argsort(-source.data["representation"], axis=1)[:, :k]
            classes = np.unique(trained.data["value_original"])
            result = np.zeros((len(idx), len(classes)), dtype=np.float)
            for i, _idx in enumerate(idx):
                for j, c in enumerate(classes):
                    result[i, j] = (trained.data["value_original"][_idx]
                                    == c).sum() / k
            result[:, -1] = 1 - result[:, :-1].sum(axis=1)
            return result

        self.data[("value_predicted", "probability")] = ProxyContainer(
            f,
            Table,
        )
Exemple #8
0
 def build_proxy(self, *, source, trained):
     self.data["value_predicted"] = ProxyContainer(
         lambda: trained.data["value_constant"] * np.ones(
             source.data["representation"].shape[0], dtype=np.float32),
         Table,
     )