class_docstr: TopicModel objects can be used to predict the underlying topic of a
  document.
  
  This model cannot be constructed directly.  Instead, use
  :func:`turicreate.topic_model.create` to create an instance
  of this model. A detailed list of parameter options and code samples
  are available in the documentation for the create function.
class_docstr_tok: ["TopicModel","objects","can","be","used","to","predict","the","underlying","topic","of","a","document",".","This","model","can","not","be","constructed","directly",".","Instead",",","use",":","func",":","`","turicreate.topic_model.create","`","to","create","an","instance","of","this","model",".","A","detailed","list","of","parameter","options","and","code","samples","are","available","in","the","documentation","for","the","create","function","."]
docstr: Get the words associated with a given topic. The score column is the
  probability of choosing that word given that you have chosen a
  particular topic.
  
  Parameters
  ----------
  topic_ids : list of int, optional
      The topics to retrieve words. Topic ids are zero-based.
      Throws an error if greater than or equal to m['num_topics'], or
      if the requested topic name is not present.
  
  num_words : int, optional
      The number of words to show.
  
  cdf_cutoff : float, optional
      Allows one to only show the most probable words whose cumulative
      probability is below this cutoff. For example if there exist
      three words where
  
      .. math::
         p(word_1 | topic_k) = .1
  
         p(word_2 | topic_k) = .2
  
         p(word_3 | topic_k) = .05
  
      then setting :math:`cdf_{cutoff}=.3` would return only
      :math:`word_1` and :math:`word_2` since
      :math:`p(word_1 | topic_k) + p(word_2 | topic_k) <= cdf_{cutoff}`
  
  output_type : {'topic_probabilities' | 'topic_words'}, optional
      Determine the type of desired output. See below.
  
  Returns
  -------
  out : SFrame
      If output_type is 'topic_probabilities', then the returned value is
      an SFrame with a column of words ranked by a column of scores for
      each topic. Otherwise, the returned value is a SArray where
      each element is a list of the most probable words for each topic.
  
  Examples
  --------
  Get the highest ranked words for all topics.
  
  >>> docs = turicreate.SArray('https://static.turi.com/datasets/nips-text')
  >>> m = turicreate.topic_model.create(docs,
                                      num_iterations=50)
  >>> m.get_topics()
  +-------+----------+-----------------+
  | topic |   word   |      score      |
  +-------+----------+-----------------+
  |   0   |   cell   |  0.028974400831 |
  |   0   |  input   | 0.0259470208503 |
  |   0   |  image   | 0.0215721599763 |
  |   0   |  visual  | 0.0173635081992 |
  |   0   |  object  | 0.0172447874156 |
  |   1   | function | 0.0482834508265 |
  |   1   |  input   | 0.0456270024091 |
  |   1   |  point   | 0.0302662839454 |
  |   1   |  result  | 0.0239474934631 |
  |   1   | problem  | 0.0231750116011 |
  |  ...  |   ...    |       ...       |
  +-------+----------+-----------------+
  
  Get the highest ranked words for topics 0 and 1 and show 15 words per
  topic.
  
  >>> m.get_topics([0, 1], num_words=15)
  +-------+----------+------------------+
  | topic |   word   |      score       |
  +-------+----------+------------------+
  |   0   |   cell   |  0.028974400831  |
  |   0   |  input   | 0.0259470208503  |
  |   0   |  image   | 0.0215721599763  |
  |   0   |  visual  | 0.0173635081992  |
  |   0   |  object  | 0.0172447874156  |
  |   0   | response | 0.0139740298286  |
  |   0   |  layer   | 0.0122585145062  |
  |   0   | features | 0.0115343177265  |
  |   0   | feature  | 0.0103530459301  |
  |   0   | spatial  | 0.00823387994361 |
  |  ...  |   ...    |       ...        |
  +-------+----------+------------------+
  
  If one wants to instead just get the top words per topic, one may
  change the format of the output as follows.
  
  >>> topics = m.get_topics(output_type='topic_words')
  dtype: list
  Rows: 10
  [['cell', 'image', 'input', 'object', 'visual'],
   ['algorithm', 'data', 'learning', 'method', 'set'],
   ['function', 'input', 'point', 'problem', 'result'],
   ['model', 'output', 'pattern', 'set', 'unit'],
   ['action', 'learning', 'net', 'problem', 'system'],
   ['error', 'function', 'network', 'parameter', 'weight'],
   ['information', 'level', 'neural', 'threshold', 'weight'],
   ['control', 'field', 'model', 'network', 'neuron'],
   ['hidden', 'layer', 'system', 'training', 'vector'],
   ['component', 'distribution', 'local', 'model', 'optimal']]
docstr_tok: ["Get","the","words","associated","with","a","given","topic",".","The","score","column","is","the","probability","of","choosing","that","word","given","that","you","have","chosen","a","particular","topic",".","Parameters","--","--","--","--","--","topic_ids",":","list","of","int",",","optional","The","topics","to","retrieve","words",".","Topic","ids","are","zero-based",".","Throws","an","error","if","greater","than","or","equal","to","m","[","'num_topics","'","]",",","or","if","the","requested","topic","name","is","not","present",".","num_words",":","int",",","optional","The","number","of","words","to","show",".","cdf_cutoff",":","float",",","optional","Allows","one","to","only","show","the","most","probable","words","whose","cumulative","probability","is","below","this","cutoff",".","For","example","if","there","exist","three","words","where","..","math",":",":","p","(","word_1","|","topic_k",")","=",".1","p","(","word_2","|","topic_k",")","=",".2","p","(","word_3","|","topic_k",")","=",".05","then","setting",":","math",":","`","cdf_","{","cutoff","}","=.3","`","would","return","only",":","math",":","`","word_1","`","and",":","math",":","`","word_2","`","since",":","math",":","`","p","(","word_1","|","topic_k",")","+","p","(","word_2","|","topic_k",")","<","=","cdf_","{","cutoff","}","`","output_type",":","{","'topic_probabilities","'","|","'topic_words","'","}",",","optional","Determine","the","type","of","desired","output",".","See","below",".","Returns","--","--","--","-","out",":","SFrame","If","output_type","is","'topic_probabilities","'",",","then","the","returned","value","is","an","SFrame","with","a","column","of","words","ranked","by","a","column","of","scores","for","each","topic",".","Otherwise",",","the","returned","value","is","a","SArray","where","each","element","is","a","list","of","the","most","probable","words","for","each","topic",".","Examples","--","--","--","--","Get","the","highest","ranked","words","for","all","topics",".",">",">",">","docs","=","turicreate.SArray","(","'https",":","\/\/static.turi.com\/datasets\/nips-text","'",")",">",">",">","m","=","turicreate.topic_model.create","(","docs",",","num_iterations=50",")",">",">",">","m.get_topics","(",")","+","--","--","--","-+","--","--","--","--","--","+","--","--","--","--","--","--","--","--","-+","|","topic","|","word","|","score","|","+","--","--","--","-+","--","--","--","--","--","+","--","--","--","--","--","--","--","--","-+","|","0","|","cell","|","0.028974400831","|","|","0","|","input","|","0.0259470208503","|","|","0","|","image","|","0.0215721599763","|","|","0","|","visual","|","0.0173635081992","|","|","0","|","object","|","0.0172447874156","|","|","1","|","function","|","0.0482834508265","|","|","1","|","input","|","0.0456270024091","|","|","1","|","point","|","0.0302662839454","|","|","1","|","result","|","0.0239474934631","|","|","1","|","problem","|","0.0231750116011","|","|","...","|","...","|","...","|","+","--","--","--","-+","--","--","--","--","--","+","--","--","--","--","--","--","--","--","-+","Get","the","highest","ranked","words","for","topics","0","and","1","and","show","15","words","per","topic",".",">",">",">","m.get_topics","(","[","0",",","1","]",",","num_words=15",")","+","--","--","--","-+","--","--","--","--","--","+","--","--","--","--","--","--","--","--","--","+","|","topic","|","word","|","score","|","+","--","--","--","-+","--","--","--","--","--","+","--","--","--","--","--","--","--","--","--","+","|","0","|","cell","|","0.028974400831","|","|","0","|","input","|","0.0259470208503","|","|","0","|","image","|","0.0215721599763","|","|","0","|","visual","|","0.0173635081992","|","|","0","|","object","|","0.0172447874156","|","|","0","|","response","|","0.0139740298286","|","|","0","|","layer","|","0.0122585145062","|","|","0","|","features","|","0.0115343177265","|","|","0","|","feature","|","0.0103530459301","|","|","0","|","spatial","|","0.00823387994361","|","|","...","|","...","|","...","|","+","--","--","--","-+","--","--","--","--","--","+","--","--","--","--","--","--","--","--","--","+","If","one","wants","to","instead","just","get","the","top","words","per","topic",",","one","may","change","the","format","of","the","output","as","follows",".",">",">",">","topics","=","m.get_topics","(","output_type='topic_words","'",")","dtype",":","list","Rows",":","10","[","[","'cell","'",",","'image","'",",","'input","'",",","'object","'",",","'visual","'","]",",","[","'algorithm","'",",","'data","'",",","'learning","'",",","'method","'",",","'set","'","]",",","[","'function","'",",","'input","'",",","'point","'",",","'problem","'",",","'result","'","]",",","[","'model","'",",","'output","'",",","'pattern","'",",","'set","'",",","'unit","'","]",",","[","'action","'",",","'learning","'",",","'net","'",",","'problem","'",",","'system","'","]",",","[","'error","'",",","'function","'",",","'network","'",",","'parameter","'",",","'weight","'","]",",","[","'information","'",",","'level","'",",","'neural","'",",","'threshold","'",",","'weight","'","]",",","[","'control","'",",","'field","'",",","'model","'",",","'network","'",",","'neuron","'","]",",","[","'hidden","'",",","'layer","'",",","'system","'",",","'training","'",",","'vector","'","]",",","[","'component","'",",","'distribution","'",",","'local","'",",","'model","'",",","'optimal","'","]","]"]
code: def get_topics(
      self,
      topic_ids=None,
      num_words=5,
      cdf_cutoff=1.0,
      output_type="topic_probabilities",
  ):
      """
      Get the words associated with a given topic. The score column is the
      probability of choosing that word given that you have chosen a
      particular topic.
  
      Parameters
      ----------
      topic_ids : list of int, optional
          The topics to retrieve words. Topic ids are zero-based.
          Throws an error if greater than or equal to m['num_topics'], or
          if the requested topic name is not present.
  
      num_words : int, optional
          The number of words to show.
  
      cdf_cutoff : float, optional
          Allows one to only show the most probable words whose cumulative
          probability is below this cutoff. For example if there exist
          three words where
  
          .. math::
             p(word_1 | topic_k) = .1
  
             p(word_2 | topic_k) = .2
  
             p(word_3 | topic_k) = .05
  
          then setting :math:`cdf_{cutoff}=.3` would return only
          :math:`word_1` and :math:`word_2` since
          :math:`p(word_1 | topic_k) + p(word_2 | topic_k) <= cdf_{cutoff}`
  
      output_type : {'topic_probabilities' | 'topic_words'}, optional
          Determine the type of desired output. See below.
  
      Returns
      -------
      out : SFrame
          If output_type is 'topic_probabilities', then the returned value is
          an SFrame with a column of words ranked by a column of scores for
          each topic. Otherwise, the returned value is a SArray where
          each element is a list of the most probable words for each topic.
  
      Examples
      --------
      Get the highest ranked words for all topics.
  
      >>> docs = turicreate.SArray('https://static.turi.com/datasets/nips-text')
      >>> m = turicreate.topic_model.create(docs,
                                          num_iterations=50)
      >>> m.get_topics()
      +-------+----------+-----------------+
      | topic |   word   |      score      |
      +-------+----------+-----------------+
      |   0   |   cell   |  0.028974400831 |
      |   0   |  input   | 0.0259470208503 |
      |   0   |  image   | 0.0215721599763 |
      |   0   |  visual  | 0.0173635081992 |
      |   0   |  object  | 0.0172447874156 |
      |   1   | function | 0.0482834508265 |
      |   1   |  input   | 0.0456270024091 |
      |   1   |  point   | 0.0302662839454 |
      |   1   |  result  | 0.0239474934631 |
      |   1   | problem  | 0.0231750116011 |
      |  ...  |   ...    |       ...       |
      +-------+----------+-----------------+
  
      Get the highest ranked words for topics 0 and 1 and show 15 words per
      topic.
  
      >>> m.get_topics([0, 1], num_words=15)
      +-------+----------+------------------+
      | topic |   word   |      score       |
      +-------+----------+------------------+
      |   0   |   cell   |  0.028974400831  |
      |   0   |  input   | 0.0259470208503  |
      |   0   |  image   | 0.0215721599763  |
      |   0   |  visual  | 0.0173635081992  |
      |   0   |  object  | 0.0172447874156  |
      |   0   | response | 0.0139740298286  |
      |   0   |  layer   | 0.0122585145062  |
      |   0   | features | 0.0115343177265  |
      |   0   | feature  | 0.0103530459301  |
      |   0   | spatial  | 0.00823387994361 |
      |  ...  |   ...    |       ...        |
      +-------+----------+------------------+
  
      If one wants to instead just get the top words per topic, one may
      change the format of the output as follows.
  
      >>> topics = m.get_topics(output_type='topic_words')
      dtype: list
      Rows: 10
      [['cell', 'image', 'input', 'object', 'visual'],
       ['algorithm', 'data', 'learning', 'method', 'set'],
       ['function', 'input', 'point', 'problem', 'result'],
       ['model', 'output', 'pattern', 'set', 'unit'],
       ['action', 'learning', 'net', 'problem', 'system'],
       ['error', 'function', 'network', 'parameter', 'weight'],
       ['information', 'level', 'neural', 'threshold', 'weight'],
       ['control', 'field', 'model', 'network', 'neuron'],
       ['hidden', 'layer', 'system', 'training', 'vector'],
       ['component', 'distribution', 'local', 'model', 'optimal']]
      """
      _check_categorical_option_type(
          "output_type",
          output_type,
          ["topic_probabilities", "topic_words"],
      )
  
      if topic_ids is None:
          topic_ids = list(range(self._get("num_topics")))
  
      assert isinstance(
          topic_ids, list
      ), "The provided topic_ids is not a list."
  
      if any([type(x) == str for x in topic_ids]):
          raise ValueError(
              "Only integer topic_ids can be used at this point in time."
          )
      if not all([x >= 0 and x < self.num_topics for x in topic_ids]):
          raise ValueError(
              "Topic id values must be non-negative and less than the "
              + "number of topics used to fit the model."
          )
  
      opts = {
          "model": self.__proxy__,
          "topic_ids": topic_ids,
          "num_words": num_words,
          "cdf_cutoff": cdf_cutoff,
      }
      response = _turicreate.extensions._text.topicmodel_get_topic(opts)
      ret = response["top_words"]
  
      def sort_wordlist_by_prob(z):
          words = sorted(
              z.items(), key=_operator.itemgetter(1), reverse=True
          )
          return [word for (word, prob) in words]
  
      if output_type != "topic_probabilities":
          ret = ret.groupby(
              "topic",
              {"word": _turicreate.aggregate.CONCAT("word", "score")},
          )
          words = ret.sort("topic")["word"].apply(sort_wordlist_by_prob)
          ret = _SFrame({"words": words})
  
      return ret
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import turicreate
  from turicreate.toolkits._model import Model
  from turicreate.data_structures.sframe import SFrame
  from turicreate.data_structures.sarray import SArray
  from turicreate.toolkits.text_analytics._util import _check_input
  from turicreate.toolkits.text_analytics._util import random_split
  from turicreate.toolkits._internal_utils import _check_categorical_option_type, _precomputed_field, _toolkit_repr_print
  import sys
  import operator
  import array
label_desc: Use image node_id 8 for calling the TopicModel obj's underlying member method code with example usage: obj.get_topics(topic_ids, num_words, cdf_cutoff, output_type) and returns: ret, unknown