예제 #1
0
    def predict(self, X, index=None, codes=None):
        n, p = X.shape
        powerset_predictions = SparseModel.predict(self, X)
        example_str = self.powerset_labels[0]
        example = [int(i) for i in example_str[1:-1].split(',')]
        n_codes = len(example)
        predictions = np.zeros([n, n_codes])
        for i in range(n):
            predictions[i, :] = self.powerset_index_to_binary_vec(powerset_predictions[i])

        if index is not None:
            predictions = pd.DataFrame(predictions, index=index, columns=codes)

        return predictions