class_docstr: Assigns weights to each type in the column type tree and attempts to traverse it using a weight percentage threshold.
class_docstr_tok: ["Assigns","weights","to","each","type","in","the","column","type","tree","and","attempts","to","traverse","it","using","a","weight","percentage","threshold","."]
docstr: Initialize the solver.
  
  weight_percent_threshold: a number in (0.5, 1]. If a node's weight corresponds to a percentage
      above this threshold with respect to its siblings' total weight sum, the solver will progress deeper
      into the type tree, entering that node. If not, it stops at the parent.
  weighter_function: a function that returns a weight given a confidence score. It will be used
      to assign integer weights to each node in the type tree based on its input signals.
docstr_tok: ["Initialize","the","solver",".","weight_percent_threshold",":","a","number","in","(","0.5",",","1","]",".","If","a","node","'s","weight","corresponds","to","a","percentage","above","this","threshold","with","respect","to","its","siblings","'","total","weight","sum",",","the","solver","will","progress","deeper","into","the","type","tree",",","entering","that","node",".","If","not",",","it","stops","at","the","parent",".","weighter_function",":","a","function","that","returns","a","weight","given","a","confidence","score",".","It","will","be","used","to","assign","integer","weights","to","each","node","in","the","type","tree","based","on","its","input","signals","."]
code: def __init__(
      self,
      weight_percent_threshold: float = 0.6,
      weighter_function: Optional[NodeWeighterFunction] = None,
  ) -> None:
      """Initialize the solver.
  
      weight_percent_threshold: a number in (0.5, 1]. If a node's weight corresponds to a percentage
          above this threshold with respect to its siblings' total weight sum, the solver will progress deeper
          into the type tree, entering that node. If not, it stops at the parent.
      weighter_function: a function that returns a weight given a confidence score. It will be used
          to assign integer weights to each node in the type tree based on its input signals.
      """
      assert (
          weight_percent_threshold > 0.5
          and weight_percent_threshold <= 1
      ), f"weight_percent_threshold is {weight_percent_threshold}, but it must be > 0.5 and <= 1!"
      self._weight_percent_threshold = weight_percent_threshold
  
      self._weighter_function = (
          weighter_function
          if weighter_function is not None
          else WeightedTypeTreeInferenceSolver.default_weighter_function
      )
  
file_path: metricflow/metricflow/inference/solver/weighted_tree.py
imports: from __future__ import annotations
  from collections import defaultdict
  from typing import Callable, Dict, List, Optional
  from metricflow.dataflow.sql_column import SqlColumn
  from metricflow.inference.models import InferenceResult, InferenceSignal, InferenceSignalConfidence, InferenceSignalNode, InferenceSignalType
  from metricflow.inference.solver.base import InferenceSolver
label_desc: Use image node_id 2 to create a new WeightedTypeTreeInferenceSolver object from inherited base classes: InferenceSolver with example: obj = WeightedTypeTreeInferenceSolver(weight_percent_threshold, weighter_function)