docstr: Parameters
  ----------
  method
      Method for sampling. Supported methods: ``'knn'`` | ``'grid'``.
  epsilon
      Size of the sampling region around the central instance as a percentage of the features range.
  nb_samples
      Number of samples to generate.
  res
      Resolution of the grid. Number of intervals in which the feature range is discretized.
  alphas
      Coefficients in the superposition.
  agg
      Aggregation method. Supported values: ``'global'`` | ``'pairwise'``.
  model_type
      Type of task. Supported values: ``'regressor'`` | ``'classifier'``.
docstr_tok: ["Parameters","--","--","--","--","--","method","Method","for","sampling",".","Supported","methods",":","``","'knn","'","``","|","``","'grid","'","``",".","epsilon","Size","of","the","sampling","region","around","the","central","instance","as","a","percentage","of","the","features","range",".","nb_samples","Number","of","samples","to","generate",".","res","Resolution","of","the","grid",".","Number","of","intervals","in","which","the","feature","range","is","discretized",".","alphas","Coefficients","in","the","superposition",".","agg","Aggregation","method",".","Supported","values",":","``","'global","'","``","|","``","'pairwise","'","``",".","model_type","Type","of","task",".","Supported","values",":","``","'regressor","'","``","|","``","'classifier","'","``","."]
code: def __init__(
      self,
      method: str = "grid",
      epsilon: float = 0.04,
      nb_samples: int = 10,
      res: int = 100,
      alphas: Optional[np.ndarray] = None,
      model_type: str = "classifier",
      agg: str = "pairwise",
      verbose: bool = False,
  ) -> None:
      """
  
      Parameters
      ----------
      method
          Method for sampling. Supported methods: ``'knn'`` | ``'grid'``.
      epsilon
          Size of the sampling region around the central instance as a percentage of the features range.
      nb_samples
          Number of samples to generate.
      res
          Resolution of the grid. Number of intervals in which the feature range is discretized.
      alphas
          Coefficients in the superposition.
      agg
          Aggregation method. Supported values: ``'global'`` | ``'pairwise'``.
      model_type
          Type of task. Supported values: ``'regressor'`` | ``'classifier'``.
      """
      self.method = method
      self.epsilon = epsilon
      self.nb_samples = nb_samples
      self.res = res
      self.alphas = alphas
      self.model_type = model_type
      self.agg = agg
      self.verbose = verbose
      self.is_fit = False
  
file_path: alibi/alibi/confidence/model_linearity.py
imports: import logging
  import string
  from time import time
  from typing import Callable, List, Optional, Tuple, Union
  import numpy
  from numpy.linalg import norm
  from sklearn.neighbors import NearestNeighbors
label_desc: Use image node_id 1 to create a new LinearityMeasure object  with example: obj = LinearityMeasure(method, epsilon, nb_samples, res, alphas, model_type, agg, verbose)