class_docstr: ShapeDTW classifier.
  
  ShapeDTW[1] works by initially extracting a set of subsequences
  describing local neighbourhoods around each data point in a time series.
  These subsequences are then passed into a shape descriptor function that
  transforms these local neighbourhoods into a new representation. This
  new representation is then sent into DTW with 1-NN.
  
  Parameters
  ----------
  n_neighbours                : int, int, set k for knn (default =1).
  subsequence_length          : int, defines the length of the
                                subsequences(default=sqrt(n_timepoints)).
  
  shape_descriptor_function   : string, defines the function to describe
                                the set of subsequences
                                (default = 'raw').
  
  
  The possible shape descriptor functions are as follows:
  
      - 'raw'                 : use the raw subsequence as the
                                shape descriptor function.
                              - params = None
  
      - 'paa'                 : use PAA as the shape descriptor function.
                              - params = num_intervals_paa (default=8)
  
      - 'dwt'                 : use DWT (Discrete Wavelet Transform)
                                as the shape descriptor function.
                              - params = num_levels_dwt (default=3)
  
      - 'slope'               : use the gradient of each subsequence
                                fitted by a total least squares
                                regression as the shape descriptor
                                function.
                              - params = num_intervals_slope (default=8)
  
      - 'derivative'          : use the derivative of each subsequence
                                as the shape descriptor function.
                              - params = None
  
      - 'hog1d'               : use a histogram of gradients in one
                                dimension as the shape descriptor
                                function.
                              - params = num_intervals_hog1d
                                                  (default=2)
                                       = num_bins_hod1d
                                                  (default=8)
                                       = scaling_factor_hog1d
                                                  (default=0.1)
  
      - 'compound'            : use a combination of two shape
                                descriptors simultaneously.
                              - params = weighting_factor
                                        (default=None)
                                         Defines how to scale
                                         values of a shape
                                         descriptor.
                                         If a value is not given,
                                         this value is tuned
                                         by 10-fold cross-validation
                                         on the training data.
  
  
  shape_descriptor_functions  : string list, only applicable when the
                                shape_descriptor_function is
                                set to 'compound'.
                                Use a list of shape descriptor
                                functions at the same time.
                                (default = ['raw','derivative'])
  
  metric_params               : dictionary for metric parameters
                                (default = None).
  
  Notes
  -----
  .. [1] Jiaping Zhao and Laurent Itti, "shapeDTW: Shape Dynamic Time Warping",
      Pattern Recognition, 74, pp 171-184, 2018
      http://www.sciencedirect.com/science/article/pii/S0031320317303710,
class_docstr_tok: ["ShapeDTW","classifier",".","ShapeDTW","[","1","]","works","by","initially","extracting","a","set","of","subsequences","describing","local","neighbourhoods","around","each","data","point","in","a","time","series",".","These","subsequences","are","then","passed","into","a","shape","descriptor","function","that","transforms","these","local","neighbourhoods","into","a","new","representation",".","This","new","representation","is","then","sent","into","DTW","with","1-NN",".","Parameters","--","--","--","--","--","n_neighbours",":","int",",","int",",","set","k","for","knn","(","default","=1",")",".","subsequence_length",":","int",",","defines","the","length","of","the","subsequences","(","default=sqrt","(","n_timepoints",")",")",".","shape_descriptor_function",":","string",",","defines","the","function","to","describe","the","set","of","subsequences","(","default","=","'raw","'",")",".","The","possible","shape","descriptor","functions","are","as","follows",":","-","'raw","'",":","use","the","raw","subsequence","as","the","shape","descriptor","function",".","-","params","=","None","-","'paa","'",":","use","PAA","as","the","shape","descriptor","function",".","-","params","=","num_intervals_paa","(","default=8",")","-","'dwt","'",":","use","DWT","(","Discrete","Wavelet","Transform",")","as","the","shape","descriptor","function",".","-","params","=","num_levels_dwt","(","default=3",")","-","'slope","'",":","use","the","gradient","of","each","subsequence","fitted","by","a","total","least","squares","regression","as","the","shape","descriptor","function",".","-","params","=","num_intervals_slope","(","default=8",")","-","'derivative","'",":","use","the","derivative","of","each","subsequence","as","the","shape","descriptor","function",".","-","params","=","None","-","'hog1d","'",":","use","a","histogram","of","gradients","in","one","dimension","as","the","shape","descriptor","function",".","-","params","=","num_intervals_hog1d","(","default=2",")","=","num_bins_hod1d","(","default=8",")","=","scaling_factor_hog1d","(","default=0.1",")","-","'compound","'",":","use","a","combination","of","two","shape","descriptors","simultaneously",".","-","params","=","weighting_factor","(","default=None",")","Defines","how","to","scale","values","of","a","shape","descriptor",".","If","a","value","is","not","given",",","this","value","is","tuned","by","10-fold","cross-validation","on","the","training","data",".","shape_descriptor_functions",":","string","list",",","only","applicable","when","the","shape_descriptor_function","is","set","to","'compound","'",".","Use","a","list","of","shape","descriptor","functions","at","the","same","time",".","(","default","=","[","'raw","'",",","'derivative","'","]",")","metric_params",":","dictionary","for","metric","parameters","(","default","=","None",")",".","Notes","--","--","-","..","[","1","]","Jiaping","Zhao","and","Laurent","Itti",",","``","shapeDTW",":","Shape","Dynamic","Time","Warping","''",",","Pattern","Recognition",",","74",",","pp","171-184",",","2018","http",":","\/\/www.sciencedirect.com\/science\/article\/pii\/S0031320317303710",","]
docstr: Calculate the appropriate weighting_factor.
  
  Check for the compound shape descriptor.
  If a value is given, the weighting_factor is set
  as the given value. If not, its tuned via
  a 10-fold cross-validation on the training data.
  
  Parameters
  ----------
  X - training data in a dataframe of shape [n_instances,1]
  y - training data classes of shape [n_instances].
docstr_tok: ["Calculate","the","appropriate","weighting_factor",".","Check","for","the","compound","shape","descriptor",".","If","a","value","is","given",",","the","weighting_factor","is","set","as","the","given","value",".","If","not",",","its","tuned","via","a","10-fold","cross-validation","on","the","training","data",".","Parameters","--","--","--","--","--","X","-","training","data","in","a","dataframe","of","shape","[","n_instances,1","]","y","-","training","data","classes","of","shape","[","n_instances","]","."]
code: def _calculate_weighting_factor_value(self, X, y):
      """Calculate the appropriate weighting_factor.
  
      Check for the compound shape descriptor.
      If a value is given, the weighting_factor is set
      as the given value. If not, its tuned via
      a 10-fold cross-validation on the training data.
  
      Parameters
      ----------
      X - training data in a dataframe of shape [n_instances,1]
      y - training data classes of shape [n_instances].
      """
      self.metric_params = {
          k.lower(): v for k, v in self.metric_params.items()
      }
  
      # Get the weighting_factor if one is provided
      if self.metric_params.get("weighting_factor") is not None:
          self.weighting_factor = self.metric_params.get(
              "weighting_factor"
          )
      else:
          # Tune it otherwise
          self._param_matrix = {
              "metric_params": [
                  {"weighting_factor": 0.1},
                  {"weighting_factor": 0.125},
                  {"weighting_factor": (1 / 6)},
                  {"weighting_factor": 0.25},
                  {"weighting_factor": 0.5},
                  {"weighting_factor": 1},
                  {"weighting_factor": 2},
                  {"weighting_factor": 4},
                  {"weighting_factor": 6},
                  {"weighting_factor": 8},
                  {"weighting_factor": 10},
              ]
          }
  
          n = self.n_neighbors
          sl = self.subsequence_length
          sdf = self.shape_descriptor_function
          sdfs = self._shape_descriptor_functions
          if sdfs is None or not (len(sdfs) == 2):
              raise ValueError(
                  "When using 'compound', "
                  + "shape_descriptor_functions must be a "
                  + "string array of length 2."
              )
          mp = self.metric_params
  
          grid = GridSearchCV(
              estimator=ShapeDTW(
                  n_neighbours=n,
                  subsequence_length=sl,
                  shape_descriptor_function=sdf,
                  shape_descriptor_functions=sdfs,
                  metric_params=mp,
              ),
              param_grid=self._param_matrix,
              cv=KFold(n_splits=10, shuffle=True),
              scoring="accuracy",
          )
          grid.fit(X, y)
          self.weighting_factor = grid.best_params_["metric_params"][
              "weighting_factor"
          ]
  
imports: import numpy
  import pandas
  from sklearn.model_selection import GridSearchCV, KFold
  from sktime.classification.base import BaseClassifier
  from sktime.classification.distance_based._time_series_neighbors import KNeighborsTimeSeriesClassifier
  from sktime.datatypes import convert
  from sktime.transformations.panel.dictionary_based._paa import PAA
  from sktime.transformations.panel.dwt import DWTTransformer
  from sktime.transformations.panel.hog1d import HOG1DTransformer
  from sktime.transformations.panel.segment import SlidingWindowSegmenter
  from sktime.transformations.panel.slope import SlopeTransformer
  from sktime.transformations.panel.summarize._extract import DerivativeSlopeTransformer
label_desc: Use image node_id 3 for calling the ShapeDTW obj's underlying member method code with example usage: obj._calculate_weighting_factor_value(X, y) without return types