class_docstr: Wraps an hyperparameter nested dict or flat dict, and offer a few more functions to process
  all contained HyperparameterDistribution.
  
  This can be set on a Pipeline with the method ``set_hyperparams_space``.
  
  Calling ``.rvs()`` on an ``HyperparameterSpace`` results in ``HyperparameterSamples``.
class_docstr_tok: ["Wraps","an","hyperparameter","nested","dict","or","flat","dict",",","and","offer","a","few","more","functions","to","process","all","contained","HyperparameterDistribution",".","This","can","be","set","on","a","Pipeline","with","the","method","``","set_hyperparams_space","``",".","Calling","``",".rvs","(",")","``","on","an","``","HyperparameterSpace","``","results","in","``","HyperparameterSamples","``","."]
docstr: Takes samples estimated to be the best ones of the space as of yet, and restrict the whole space towards that.
  
  :param best_guesses: sampled HyperparameterSpace (the result of rvs on each parameter, but still stored as a HyperparameterSpace).
  :param kept_space_ratio: what proportion of the space is kept. Should be between 0.0 and 1.0. Default is 0.5.
  :return: a new HyperparameterSpace containing the narrowed HyperparameterDistribution objects.
docstr_tok: ["Takes","samples","estimated","to","be","the","best","ones","of","the","space","as","of","yet",",","and","restrict","the","whole","space","towards","that",".",":","param","best_guesses",":","sampled","HyperparameterSpace","(","the","result","of","rvs","on","each","parameter",",","but","still","stored","as","a","HyperparameterSpace",")",".",":","param","kept_space_ratio",":","what","proportion","of","the","space","is","kept",".","Should","be","between","0.0","and","1.0",".","Default","is","0.5.",":","return",":","a","new","HyperparameterSpace","containing","the","narrowed","HyperparameterDistribution","objects","."]
code: def narrow_space_from_best_guess(
      self,
      best_guesses: "HyperparameterSpace",
      kept_space_ratio: float = 0.5,
  ) -> "HyperparameterSpace":
      """
      Takes samples estimated to be the best ones of the space as of yet, and restrict the whole space towards that.
  
      :param best_guesses: sampled HyperparameterSpace (the result of rvs on each parameter, but still stored as a HyperparameterSpace).
      :param kept_space_ratio: what proportion of the space is kept. Should be between 0.0 and 1.0. Default is 0.5.
      :return: a new HyperparameterSpace containing the narrowed HyperparameterDistribution objects.
      """
      new_items = []
      for k, v in self.iter_flat():
          if isinstance(v, HyperparameterDistribution) or isinstance(
              v, HyperparameterSpace
          ):
              best_guess_v = best_guesses[k]
              v = v.narrow_space_from_best_guess(
                  best_guess_v, kept_space_ratio
              )
          new_items.append((k, v))
      return HyperparameterSpace(new_items)
  
imports: import typing
  from collections import Counter, OrderedDict, defaultdict
  from copy import copy
  from typing import Any, Dict, Iterable, List, Set, Union
  from neuraxle.hyperparams.distributions import FixedHyperparameter, HPSampledValue, HyperparameterDistribution
  from neuraxle.hyperparams.scipy_distributions import ScipyContinuousDistributionWrapper, ScipyDiscreteDistributionWrapper
  from scipy.stats import rv_continuous, rv_discrete
  from scipy.stats._distn_infrastructure import rv_generic
label_desc: Use image node_id 5 for calling the HyperparameterSpace obj's underlying member method code with example usage: obj.narrow_space_from_best_guess(best_guesses, kept_space_ratio) and returns: HyperparameterSpace