def predict(self, input_data, n_times=None):
        self.discrete_validation(input_data)
        input_data = format_data(bin2sign(input_data), row1d=True)

        if self.mode == 'async':
            if n_times is None:
                n_times = self.n_times

            _, n_features = input_data.shape
            output_data = input_data

            for _ in range(n_times):
                position = random.randint(0, n_features - 1)
                raw_new_value = output_data.dot(self.weight[:, position])
                output_data[:, position] = sign(raw_new_value)
        else:
            output_data = input_data.dot(self.weight)

        return step(output_data).astype(int)
Exemple #2
0
    def predict(self, input_data, n_times=None):
        self.discrete_validation(input_data)
        input_data = format_data(bin2sign(input_data), row1d=True)

        if self.mode == 'async':
            if n_times is None:
                n_times = self.n_times

            _, n_features = input_data.shape
            output_data = input_data

            for _ in range(n_times):
                position = random.randint(0, n_features - 1)
                raw_new_value = output_data.dot(self.weight[:, position])
                output_data[:, position] = sign(raw_new_value)
        else:
            output_data = input_data.dot(self.weight)

        return step(output_data).astype(int)
Exemple #3
0
 def format_predict(self, predicted_result):
     return step(predicted_result).astype(int)