class_docstr: Probability Threshold Early Classifier.
  
  An early classifier which uses a threshold of prediction probability to determine
  whether an early prediction is safe or not.
  
  Overview:
      Build n classifiers, where n is the number of classification_points.
      While a prediction is still deemed unsafe:
          Make a prediction using the series length at classification point i.
          Decide whether the predcition is safe or not using decide_prediction_safety.
  
  Parameters
  ----------
  probability_threshold : float, default=0.85
      The class prediction probability required to deem a prediction as safe.
  consecutive_predictions : int, default=1
      The number of consecutive predictions for a class above the threshold required
      to deem a prediction as safe.
  estimator: sktime classifier, default=None
      An sktime estimator to be built using the transformed data. Defaults to a
      CanonicalIntervalForest.
  classification_points : List or None, default=None
      List of integer time series time stamps to build classifiers and allow
      predictions at. Early predictions must have a series length that matches a value
      in the _classification_points List. Duplicate values will be removed, and the
      full series length will be appended if not present.
      If None, will use 20 thresholds linearly spaces from 0 to the series length.
  n_jobs : int, default=1
      The number of jobs to run in parallel for both `fit` and `predict`.
      ``-1`` means using all processors.
  random_state : int or None, default=None
      Seed for random number generation.
  
  Attributes
  ----------
  n_classes_ : int
      The number of classes.
  classes_ : list
      The unique class labels.
  
  Examples
  --------
  >>> from sktime.classification.early_classification import (
  ...     ProbabilityThresholdEarlyClassifier
  ... )
  >>> from sktime.classification.interval_based import TimeSeriesForestClassifier
  >>> from sktime.datasets import load_unit_test
  >>> X_train, y_train = load_unit_test(split="train", return_X_y=True)
  >>> X_test, y_test = load_unit_test(split="test", return_X_y=True)
  >>> clf = ProbabilityThresholdEarlyClassifier(
  ...     classification_points=[6, 16, 24],
  ...     estimator=TimeSeriesForestClassifier(n_estimators=10)
  ... )
  >>> clf.fit(X_train, y_train)
  ProbabilityThresholdEarlyClassifier(...)
  >>> y_pred = clf.predict(X_test)
class_docstr_tok: ["Probability","Threshold","Early","Classifier",".","An","early","classifier","which","uses","a","threshold","of","prediction","probability","to","determine","whether","an","early","prediction","is","safe","or","not",".","Overview",":","Build","n","classifiers",",","where","n","is","the","number","of","classification_points",".","While","a","prediction","is","still","deemed","unsafe",":","Make","a","prediction","using","the","series","length","at","classification","point","i",".","Decide","whether","the","predcition","is","safe","or","not","using","decide_prediction_safety",".","Parameters","--","--","--","--","--","probability_threshold",":","float",",","default=0.85","The","class","prediction","probability","required","to","deem","a","prediction","as","safe",".","consecutive_predictions",":","int",",","default=1","The","number","of","consecutive","predictions","for","a","class","above","the","threshold","required","to","deem","a","prediction","as","safe",".","estimator",":","sktime","classifier",",","default=None","An","sktime","estimator","to","be","built","using","the","transformed","data",".","Defaults","to","a","CanonicalIntervalForest",".","classification_points",":","List","or","None",",","default=None","List","of","integer","time","series","time","stamps","to","build","classifiers","and","allow","predictions","at",".","Early","predictions","must","have","a","series","length","that","matches","a","value","in","the","_classification_points","List",".","Duplicate","values","will","be","removed",",","and","the","full","series","length","will","be","appended","if","not","present",".","If","None",",","will","use","20","thresholds","linearly","spaces","from","0","to","the","series","length",".","n_jobs",":","int",",","default=1","The","number","of","jobs","to","run","in","parallel","for","both","`","fit","`","and","`","predict","`",".","``","-1","``","means","using","all","processors",".","random_state",":","int","or","None",",","default=None","Seed","for","random","number","generation",".","Attributes","--","--","--","--","--","n_classes_",":","int","The","number","of","classes",".","classes_",":","list","The","unique","class","labels",".","Examples","--","--","--","--",">",">",">","from","sktime.classification.early_classification","import","(","...","ProbabilityThresholdEarlyClassifier","...",")",">",">",">","from","sktime.classification.interval_based","import","TimeSeriesForestClassifier",">",">",">","from","sktime.datasets","import","load_unit_test",">",">",">","X_train",",","y_train","=","load_unit_test","(","split=","''","train","''",",","return_X_y=True",")",">",">",">","X_test",",","y_test","=","load_unit_test","(","split=","''","test","''",",","return_X_y=True",")",">",">",">","clf","=","ProbabilityThresholdEarlyClassifier","(","...","classification_points=","[","6",",","16",",","24","]",",","...","estimator=TimeSeriesForestClassifier","(","n_estimators=10",")","...",")",">",">",">","clf.fit","(","X_train",",","y_train",")","ProbabilityThresholdEarlyClassifier","(","...",")",">",">",">","y_pred","=","clf.predict","(","X_test",")"]
code: def _predict(self, X) -> np.ndarray:
      rng = check_random_state(self.random_state)
      return np.array(
          [
              self.classes_[
                  int(rng.choice(np.flatnonzero(prob == prob.max())))
              ]
              for prob in self._predict_proba(X)
          ]
      )
  
file_path: sktime/sktime/classification/early_classification/_probability_threshold.py
imports: import copy
  import numpy
  from joblib import Parallel, delayed
  from sklearn.ensemble import RandomForestClassifier
  from sklearn.utils import check_random_state
  from sktime.base._base import _clone_estimator
  from sktime.classification.base import BaseClassifier
  from sktime.classification.interval_based import CanonicalIntervalForest
  from sktime.utils.validation.panel import check_X
label_desc: Use image node_id 3 for calling the ProbabilityThresholdEarlyClassifier obj's underlying member method code with example usage: obj._predict(X) and returns: np