Skip to main content
Use the Python Interpreter tool to go beyond SQL and perform advanced data science operations such as forecasting, regression, clustering, and mathematical calculations directly from natural language in Chat. When you ask a question that requires computation beyond what SQL can answer, WisdomAI automatically generates Python code, executes it securely, and visualizes the result. This guide explains how to enable the tool, what types of analysis it supports, and how to get the best results.

How It Works

When you ask a question that requires advanced computation, WisdomAI follows this process:
  1. Retrieves data: If the analysis needs data from your database, WisdomAI first queries it using SQL.
  2. Generates Python code: WisdomAI translates your natural-language instruction into Python code.
  3. Visualizes the result: The result is automatically visualized as a chart or table—you do not need to write any plotting code.

Enable or Disable the Tool

Before asking a question, make sure the Python Interpreter tool is enabled in the chat interface.
  1. Open a Chat in WisdomAI.
  2. Locate the experimental tools selector in the chat input area.
  3. Toggle Python Interpreter on or off.
Image
Your preference is saved and persists across sessions. When enabled, WisdomAI will use the tool automatically when your question requires Python-level analysis. When disabled, only SQL-based analysis is available.

What You Can Do

Perform the following data science tasks and advanced transformations directly within your chat sessions:

Mathematical Calculations

Ask any arithmetic or mathematical question, and WisdomAI will compute it with Python rather than relying on approximations.
  • What is the compound annual growth rate of revenue from 2020 to 2024?
  • Calculate the standard deviation of deal sizes across all closed-won opportunities.

Time-Series Forecasting

Forecast future values using statistical models. WisdomAI selects the appropriate method based on your data. Example questions:
  • Forecast monthly revenue for the next 12 months.
  • Predict weekly active users for Q3 based on historical trends.
Image
The result automatically includes both original and forecasted values in a single visualization, so you can compare them side by side.

Regression Analysis

Fit regression models to understand relationships between variables or extrapolate trends. Example questions:
  • What is the relationship between marketing spend and revenue?
  • If we increase headcount from 50 to 100 in steps of 5, what is the projected output?
Image

Clustering

Group data points into clusters to discover natural segments in your data.
Image
Image

Data Manipulation and Transformation

Perform pandas-style operations that SQL cannot express, such as pivoting, rolling windows, or custom row-level logic. Example questions:
  • Calculate the 7-day rolling average of daily signups.
  • Merge the sales and returns tables on order_id and compute net revenue per product.
  • Pivot the data so each region becomes a column with total sales as values.

Available Python Libraries

Code generated by WisdomAI runs in a secure, sandboxed environment. Only a curated set of Python libraries is available for import. Any attempt to import a module outside of this list will be blocked. The following libraries are allowed: collections csv datetime functools itertools json math numpy pandas prophet random re scipy sklearn statsmodels string If you need a module that is not listed above, contact the WisdomAI support team for assistance.

Tips for Best Results

  • Be specific about the analysis you want. Instead of “analyze sales,” ask “forecast monthly sales for the next 6 months using the last 2 years of data.” Specificity helps WisdomAI choose the right method and parameters.
  • Fetch data first, then analyze. For data science tasks, WisdomAI follows a two-step process: first, query data via SQL, then analyze it with Python. If you notice missing data, ask for a follow-up to retrieve the full dataset before re-running the analysis.
  • Ask to adjust parameters. After a forecasting or regression result, you can ask WisdomAI to change the method or tune parameters. For example: “Redo the forecast using ETS with multiplicative seasonality” or “Try Ridge regression with alpha=0.5.”
  • Use follow-up questions. The result persists in your conversation. You can ask follow-up questions like “Now filter this to only show Q4” or “Add a trend line to the existing data.”

Use Case Examples

Forecasting Revenue

  • Scenario: You need to forecast next quarter’s revenue using historical monthly data.
  • Question: Forecast monthly revenue for the next 3 months based on the last 2 years of data.
  • Outcome: WisdomAI first queries your revenue data, then runs a SARIMAX or ETS forecast, and presents both the historical and forecasted values in a single line chart.

Segmenting Customers

  • Scenario: You want to identify natural customer segments for a marketing campaign.
  • Question: Cluster our customers into groups based on total spend and order frequency. Suggest the best number of clusters.
  • Outcome: WisdomAI queries customer metrics, runs K-Means with silhouette scoring to determine the optimal number of groups, and presents a scatter plot with color-coded clusters.

What-If Analysis

  • Scenario: You want to understand how increasing ad spend might affect conversions.
  • Question: Based on historical data, if we increase ad spend from $10K to $50K in $5K steps, what are the projected conversions?
  • Outcome: WisdomAI fits a linear regression on historical ad spend vs. conversions, extrapolates over the specified range, and shows both the original data and projected values.

Next Steps