code: def evaluate_model(
      model,
      model_type,
      x_test,
      y_pred,
      y_true,
      get_score_only,
      **kwargs,
  ):
      if get_score_only:
          logger.info(f"calculating {model_type} score...")
          return {f"{model_type} score": model.score(x_test, y_true)}
  
      if y_pred.ndim > 1:
          if y_true.shape[1] > 1 or y_pred.shape[1] > 1:
              logger.info(
                  f"Multitarget {model_type} Evaluation: calculating {model_type} score"
              )
              return {
                  f"{model_type} score": model.score(x_test, y_true)
              }
  
      if model_type not in metrics_dict.keys():
          raise Exception(
              "model type needs to be regression or classification"
          )
      metrics = metrics_dict.get(model_type, None)
      eval_res = {}
      if metrics:
          for metric in metrics:
              logger.info(f"Calculating {metric.__name__} .....")
              logger.info(f"type of target: {type_of_target(y_true)}")
              if type_of_target(y_true) in (
                  "multiclass-multioutput",
                  "multilabel-indicator",
                  "multiclass",
              ) and metric.__name__ in (
                  "precision_score",
                  "accuracy_score",
                  "recall_score",
                  "f1_score",
              ):
                  if metric.__name__ == "accuracy_score":
                      eval_res[metric.__name__] = metric(
                          y_pred=y_pred, y_true=y_true
                      )
                  else:
                      eval_res[metric.__name__] = metric(
                          y_pred=y_pred, y_true=y_true, average="micro"
                      )
  
              else:
                  eval_res[metric.__name__] = metric(
                      y_pred=y_pred, y_true=y_true, **kwargs
                  )
  
      return eval_res
  
file_path: igel/igel/data.py
imports: from sklearn.linear_model import LinearRegression, LogisticRegression, Ridge, RANSACRegressor, RidgeClassifier, RidgeClassifierCV, RidgeCV, BayesianRidge, SGDRegressor, GammaRegressor, LogisticRegressionCV, TheilSenRegressor, PoissonRegressor, TweedieRegressor, ARDRegression, SGDClassifier, HuberRegressor, Lasso, LassoCV, LassoLars, LassoLarsCV, PassiveAggressiveClassifier, ElasticNet, ElasticNetCV, Perceptron
  from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor, ExtraTreesRegressor, ExtraTreesClassifier, AdaBoostClassifier, AdaBoostRegressor, BaggingClassifier, BaggingRegressor, GradientBoostingClassifier, GradientBoostingRegressor, StackingClassifier, StackingRegressor, VotingClassifier, VotingRegressor
  from sklearn.naive_bayes import BernoulliNB, CategoricalNB, ComplementNB, GaussianNB, MultinomialNB
  from sklearn.cluster import KMeans, AffinityPropagation, AgglomerativeClustering, Birch, DBSCAN, FeatureAgglomeration, MiniBatchKMeans, MeanShift, OPTICS, SpectralBiclustering, SpectralClustering, SpectralCoclustering
  from sklearn.calibration import CalibratedClassifierCV
  from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor, ExtraTreeClassifier, ExtraTreeRegressor
  from sklearn.svm import SVC, SVR, LinearSVC, LinearSVR, NuSVC, NuSVR
  from sklearn.neighbors import KNeighborsClassifier, KNeighborsRegressor
  from sklearn.neural_network import MLPRegressor, MLPClassifier, BernoulliRBM
  from sklearn.metrics import mean_squared_error, mean_absolute_error, mean_squared_log_error, median_absolute_error, accuracy_score, f1_score, r2_score, precision_score, recall_score
  from sklearn.utils.multiclass import type_of_target
  from igel.extras.kmedoids import KMedoids
  from igel.extras.kmedians import KMedians
  import logging
label_desc: Use image node_id 1 for calling a global function with example usage: evaluate_model(model, model_type, x_test, y_pred, y_true, get_score_only) and returns: eval_res, dict, dict