def predict(self, X): y_scores = logistic_sigmoid(self._decision_scores(X)) y_scores[y_scores >= 0.5] = 1 y_scores[y_scores < 0.5] = -1 return y_scores
def predict(self, X): """Predict using the multi-layer perceptron model Parameters ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) Returns ------- array, shape (n_samples) Predicted target values per element in X. """ X = atleast2d_or_csr(X) scores = self.decision_function(X) if len(scores.shape) == 1 or self.multi_label is True: scores = logistic_sigmoid(scores) results = (scores > 0.5).astype(np.int) if self.multi_label: return self._lbin.inverse_transform(results) else: scores = _softmax(scores) results = scores.argmax(axis=1) return self.classes_[results]
def predict(self, X): y_scores = logistic_sigmoid(self._decision_scores(X)) y_scores[y_scores >= 0.5] = self.pos_class y_scores[y_scores < 0.5] = self.neg_class return y_scores
def logistic(X): """Compute the logistic function inplace. Parameters ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) The input data. Returns ------- X_new : {array-like, sparse matrix}, shape (n_samples, n_features) The transformed data. """ return logistic_sigmoid(X, out=X)
def predict_proba(self, X): """Probability estimates. Parameters ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) Returns ------- array, shape (n_samples, n_outputs) Returns the probability of the sample for each class in the model, where classes are ordered as they are in `self.classes_`. """ scores = self.decision_function(X) if len(scores.shape) == 1: scores = logistic_sigmoid(scores) return np.vstack([1 - scores, scores]).T else: return _softmax(scores)