code: def test_LinearityMeasure_class(
      method, epsilon, res, nb_instances, agg
  ):
      iris = load_iris()
      X_train = iris.data
      y_train = iris.target
      x = X_train[0:nb_instances].reshape(nb_instances, -1)
  
      lg = LogisticRegression()
      lg.fit(X_train, y_train)
  
      def predict_fn(x):
          return lg.predict_proba(x)
  
      lm = LinearityMeasure(
          method=method,
          epsilon=epsilon,
          res=res,
          model_type="classifier",
          agg=agg,
      )
      lm.fit(X_train)
      lin = lm.score(predict_fn, x)
      assert lin.shape[0] == nb_instances, "Checking shapes"
      assert (lin >= 0).all(), "Linearity measure must be >= 0"
  
file_path: alibi/alibi/confidence/tests/test_model_linearity.py
imports: import pytest
  import numpy
  from sklearn.datasets import load_iris, load_diabetes
  from sklearn.linear_model import LogisticRegression, LinearRegression
  from sklearn.svm import SVR
  from alibi.confidence.model_linearity import linearity_measure, LinearityMeasure
  from alibi.confidence.model_linearity import _linear_superposition, _sample_grid, _sample_knn
  from functools import reduce
label_desc: Use image node_id 6 for calling a global function with example usage: test_LinearityMeasure_class(method, epsilon, res, nb_instances, agg) and returns: lg