docstr: Test that we can retrieve the topic probabilities from the model.
docstr_tok: ["Test","that","we","can","retrieve","the","topic","probabilities","from","the","model","."]
code: def test_get_topics(self):
      """
      Test that we can retrieve the topic probabilities from the model.
      """
  
      for m in self.models:
          topics = m.topics
          self.assertTrue(isinstance(topics, turicreate.SFrame))
          self.assertEqual(topics.num_rows(), 25)
          self.assertEqual(topics.num_columns(), 2)
          z = m.topics["topic_probabilities"]
          for k in range(m.num_topics):
              self.assertTrue(
                  abs(sum(z.vector_slice(k)) - 1) < DELTA,
                  "Returned probabilities do not sum to 1.",
              )
  
          # Make sure returned object is an SFrame of the right size
          topics = m.get_topics()
          self.assertTrue(isinstance(topics, turicreate.SFrame))
          self.assertTrue(
              topics.num_columns() == 3,
              "Returned SFrame should have a topic, word, and probs.",
          )
  
          # Make sure that requesting a single topic returns only that topic
          num_words = 8
          topics = m.get_topics([5], num_words=num_words)
          self.assertTrue(
              all(topics["topic"] == 5),
              "Returned topics do not have the right id.",
          )
          self.assertEqual(topics.num_rows(), num_words)
          topics = m.get_topics([2, 4], num_words=num_words)
          self.assertEqual(set(list(topics["topic"])), set([2, 4]))
          self.assertEqual(topics.num_rows(), num_words + num_words)
  
          # Make sure the cumulative probability of the returned words is
          # is less than the cutoff we provided.
          # A cutoff of 1.0 should return num_words for every topic.
          cutoff = 1.0
          topics = m.get_topics(
              cdf_cutoff=cutoff, num_words=len(m.vocabulary)
          )
          totals = topics.groupby(
              "topic",
              {"total_score": turicreate.aggregate.SUM("score")},
          )
          self.assertTrue(
              all(totals["total_score"] <= (cutoff + DELTA)),
              "More words were returned than expected for this cutoff.",
          )
  
          # Make sure we raise errors for bad input
          with self.assertRaises(ValueError):
              m.get_topics([-1])
          with self.assertRaises(ValueError):
              m.get_topics([10000])
          with self.assertRaises(ToolkitError):
              topics = m.get_topics(output_type="other")
  
          # Test getting topic_words
          topic_words = m.get_topics(
              output_type="topic_words", num_words=5
          )
          self.assertEqual(type(topic_words), turicreate.SFrame)
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import os
  import tempfile
  import shutil
  import unittest
  import turicreate
  from turicreate.toolkits._main import ToolkitError
  from turicreate.toolkits.topic_model import topic_model
  from turicreate.toolkits.text_analytics import parse_sparse
  from turicreate.toolkits.text_analytics import parse_docword
  from turicreate.toolkits.topic_model import perplexity
  from .None import util
  import time
  import random
  import numpy
  import itertools
label_desc: Use image node_id 7 for calling the BasicTest obj's underlying member method code with example usage: obj.test_get_topics() without return types