Phrazor SDK
Get API KeyPhrazor API
  • 👋Welcome
  • Docs
    • ⚡Quick Start
    • 🔑Get your API Key
    • Documentation
      • 📥Download and Import
      • 🔗Connect your Data
      • 🛠️Setup your Analysis
        • Descriptor
        • Change
        • Trend
        • Compare
        • Target vs Achievement
        • Budget vs Expense
        • Others
          • Filter your Data
      • 📋Generate your Insights
      • 📝Generate your Summary
      • 🔌Integrations
      • 💣Rate Limits
Powered by GitBook
On this page
  • Show Topics
  • Output Response
  • Get Insights
  • Output Response
  • Examples
  1. Docs
  2. Documentation

Generate your Insights

Details the process of generating insights from the input data.

Show Topics

The show_topics method allows you to retrieve a list of available analysis topics or subtopics. These topics represent specific questions or areas of interest that can be explored using the library's analysis capabilities. It returns a dict.

topics = phrzr.show_topics()

Output Response

[
  {
    "analysis": "Descriptor",
    "name": "best_performing",
    "description": "Best Performing Sales Person"
  },
  {
    "analysis": "Trend",
    "name": "declining_trend",
    "description": "Sales Person having a declining trend"
  }
]
Key
Type
Description

analysis

str

Name of the analysis for the topic. Possible Values: "Descriptor","Change","Trend","Compare", "Target","Budget"

name

str

Name of the topic.

description

str

Description of the topic.

Get Insights

The get_insights method allows you to transform data into actionable knowledge. It enables you to uncover insights about specific topics or provides in-depth information on your data based on selected analysis type. It identifies hidden patterns, trends, and key information within your dataset.

Method Signature:

get_insights(
    on: Union[list, str], focus_on_value: Union[list, str] = None, 
    compare_value_1: str = None,compare_value_2: str = None, 
    formatted_sentence: bool = False,
    forecast_meta: dict = None
) -> dict

Parameter
Type
Description

on

list/str

Analysis Name/Topics that are to be used to create a summary. This is the most important parameter of the function. Analysis Name Accepted Values : "descriptor","change","trend", "compare_measure",compare_dimension, "target","budget"

It should be passed as a string.

focus_on_value

list/str

Narrow down the analysis to a specific value/values within the chosen dimension. Enables you to target a particular data point. For Example, If dimension is set as "Region", specifying focus_on_value as "South" will direct the function to specifically analyze and summarize feedback related to South Region. It can be either a string or list of values. It is an optional parameter.

compare_value_1

str

Used to contrast or compare against the value provided in compare_value_2. To be used with compare_dimension analysis and topics like compare_by_contribution, compare_by_performance and compare_by_rank. Should be kept blank for other analyses and topics.

compare_value_2

str

Used to contrast or compare against the value provided in compare_value_1. To be used with compare_dimension analysis and topics like compare_by_contribution, compare_by_performance and compare_by_rank. Should be kept blank for other analyses and topics.

formatted_sentence

bool

Add formatted_sentence key which has html text styling applied to important text and numbers in the output sentence.

Default: False

It is an optional parameter.

forecast_meta

dict

To generate insights using topics please select all topics belonging to the same analysis (Eg. Descriptor, Trend, Change,etc.)

Output Response

{
  "sections": [
    {
      "name": "<Name of the Metric>",
      "insights": [
        {
          "title": "<Title 1>",
          "sentence": "<Sentence 1>",
          "formatted_sentence": "<Formatted Sentence 1>",
          "type": "generated"
        },
        {
          "title": "<Title 2>",
          "sentence": "<Sentence 2>",
          "formatted_sentence": "<Formatted Sentence 2>",
          "type": "generated"
        },
        {
          "title": "<Title 3>",
          "sentence": "<Sentence 3>",
          "formatted_sentence": "<Formatted Sentence 3>",
          "type": "failed"
        }
      ]
    }
  ],
  "time_taken": <Time in Seconds>
}

Keys
Type
Description

sections

list

Contains multiple dictionaries for each metric that is passed.

name

str

Name of the metric for which the insights are generated.

insights

list

Contains multiple dictionaries where each dictionary has one insight and title.

title

str

Title for the generated insight.

sentence

str

Generated insight in plain text.

formatted_sentence

str

Generated insight with HTML tags applied around important text and numbers. Can be directly rendered in HTML.

type

str

Specifies whether the insight generation process was successful or encountered an error during execution.

Possible Values: "generated", "error"

time_taken

float

Time taken for generation(in seconds).

Examples

Get Insights using Analysis

The following snippets shows how can you generate insights for Trend Analysis

import phrazor

phrazor.API_KEY = 'YOUR API KEY'
phrzr = phrazor.Phrazor()

# You can set data using a CSV file or using a JSON. 
# Refer Connect your Data section for more information.
phrzr.set_data(<YOUR DATA>)

phrzr.set_column_meta(
    date_column="<DATE COLUMN>", 
    metric_column="<METRIC COLUMN>"
)

insights = phrzr.get_insights(on="trend")

print(insights)

To get insights on Trend of particular value/values in your data you can specify the value/values using focus_on_value. Let's consider that we want to get trend of Sales for West Region, we can achieve that using following snippet:

phrzr.set_column_meta(
    date_column="Date", 
    metric_column="Sales",
    dimension_column="Region"
)

insights = phrzr.get_insights(on="trend", focus_on_value="West")

print(insights)

Get Insight using Topics

The following snippet shows how can you generate insights for specific topics of Change analysis:

import phrazor

phrazor.API_KEY = 'YOUR API KEY'
phrzr = phrazor.Phrazor()


# You can set data using a CSV file or using a JSON. 
# Refer Connect your Data section for more information.
phrzr.set_data(<YOUR DATA>)

phrzr.set_column_meta(
    date_column="<DATE COLUMN>", 
    metric_column="<METRIC COLUMN>", 
    dimension_column="<DIMENSION COLUMN>"
)

insights = phrzr.get_insights(
    on=["growth_primary","dim_growth_primary","dim_decline_primary"]
)

print(insights)

We can get insights on a particular value/values of data by passing them to focus_on_value parameter.

insights = phrzr.get_insights(
    on=["growth_primary","dim_growth_primary","dim_decline_primary"],
    focus_on_value=["<Val 1>","<Val 2>"]
)

print(insights)

PreviousFilter your DataNextGenerate your Summary

Last updated 1 year ago

Topics can take the values that are fetched from methods. All topics should belong to same analysis. It should be pass as a list.

It is to be set when you want to generate insights related to forecast and tweak the parameter for the model. To get more details visit .

📋
here
show_topics