Skip to content
This repository was archived by the owner on Mar 6, 2021. It is now read-only.
This repository was archived by the owner on Mar 6, 2021. It is now read-only.

Predicting probabilities instead of classes #4

@srimalj

Description

@srimalj

Hi

I recently needed to predict the class probabilities instead of the class labels.

So I wrote a predict_proba() method, sticking to the convention used in other scikit classifiers.

I added the following which simply take considers the exponential ratios of the decision functions,
to class GenELMClassifier to the module elm.py .

  • def predict_proba(self, X):
  •    """Predict probability values using the model
    
  •    Considers exponent of decision_function values
    
  •    Parameters
    

  •    X : {array-like, sparse matrix} of shape [n_samples, n_features]
    
  •    Returns
    

  •    C : numpy array of shape [n_samples, n_outputs]
    
  •        Predicted values.
    
  •    """
    
  •    raw_predictions = np.exp(self.decision_function(X))
    
  •    probabilities = np.zeros(raw_predictions.shape)
    
  •    rows, cols = raw_predictions.shape
    
  •    for row in range(0, rows):
    
  •        total = sum(raw_predictions[row,:])
    
  •        probabilities[row,:] = raw_predictions[row,:] / total
    
  •    return probabilities
    

(The + signs are from my GIT diffs, please ignore).

I'm not overly familiar with ELMs but if you think the above is correct, feel free to add it up. Alternatively I would be happy to contribute code to the project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions