Unlocking Data Insights with Pandalyst Cognitive Actions

In the realm of data analysis, the ability to process and interpret large and complex datasets efficiently is crucial. The Pandalyst Cognitive Actions, part of the tomasmcm/pandalyst-13b-v1.0 API, offer developers a powerful toolset to leverage the capabilities of a large language model designed specifically for data analysis. These pre-built actions simplify the integration of sophisticated data processing techniques into your applications, saving time and enhancing performance.
Prerequisites
Before you start using the Pandalyst Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform.
- Basic familiarity with JSON and HTTP requests.
- An environment set up for making HTTP requests (e.g., Python with the
requestslibrary).
To authenticate your requests, you typically need to include your API key in the headers of your HTTP calls.
Cognitive Actions Overview
Perform Data Analysis Using Pandalyst
The Perform Data Analysis Using Pandalyst action allows you to utilize the Pandalyst large language model to analyze complex data tables. This action is categorized under data-extraction and is particularly useful for deriving insights from structured datasets.
Input
The input for this action requires the following fields in JSON format:
- prompt (required): A detailed instruction for the model to complete.
- stop (optional): A string that will stop further generation once encountered.
- topK (optional): An integer specifying the number of top tokens to consider for sampling. Use -1 to consider all tokens.
- topP (optional): A probability value that limits the pool of tokens based on cumulative probability.
- maxTokens (optional): The maximum number of tokens in the generated output.
- temperature (optional): Controls the randomness of the output.
- presencePenalty (optional): Applies a penalty based on the presence of tokens in the generated text.
- frequencyPenalty (optional): Applies a penalty based on the frequency of tokens in the generated text.
Here is an example input payload:
{
"topK": -1,
"topP": 0.95,
"prompt": "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n### Instruction:\nDataframe Name: Career summary, with 43 rows and 9 columns.\nDescription: This is a table about Gabriel Furlán: Career summary\nColumns: Season, Series, Team, Races, Wins, Poles, Podiums, Points, Position\nHere are the descriptions of the columns of the dataframe:\n{\"Column Name\": \"Season\", \"Type\": \"int\", \"MIN\": 1984, \"MAX\": 2011}\n{\"Column Name\": \"Wins\", \"Type\": \"string\", \"Enumerated Values\": [\"0\", \"6\", \"2\", \"3\", \"7\", \"?\", \"5\", \"1\"]}\n{\"Column Name\": \"Position\", \"Type\": \"string\", \"Enumerated Values\": [\"9th\", \"18th\", \"2nd\", \"10th\", \"N/A\", \"13th\", \"7th\", \"4th\", \"6th\", \"3rd\", \"8th\", \"?\", \"1st\", \"16th\", \"11th\", \"19th\", \"5th\"]}\n{\"Column Name\": \"Podiums\", \"Type\": \"string\", \"Enumerated Values\": [\"9\", \"0\", \"3\", \"7\", \"?\", \"5\", \"1\", \"4\"]}\n{\"Column Name\": \"Team\", \"Type\": \"string\", \"Enumerated Values\": [\"INI Competición\", \"Junior Team\", \"Forti Corse\", \"GF Motorsport\", \"GF Racing\", \"Toyota Team Argentina\", \"Gustavo Sommi\", \"Ford\", \"DTA\", \"Maldonado Competición\", \"Sommi-Zanón\", \"Bainotti Dowen Pagio\", \"Scuderia 111\", \"Jolly Club\"]}\n{\"Column Name\": \"Races\", \"Type\": \"string\", \"Enumerated Values\": [\"9\", \"8\", \"13\", \"2\", \"7\", \"14\", \"18\", \"?\", \"5\", \"1\", \"12\", \"4\", \"11\"]}\n{\"Column Name\": \"Points\", \"Type\": \"string\", \"Enumerated Values\": [\"39\", \"90\", \"67\", \"0\", \"35.5\", \"79\", \"78\", \"52\", \"N/A\", \"16\", \"38\", \"26\", \"65\", \"144\", \"1\", \"139\", \"175\", \"42\", \"32\", \"46\"]}\n{\"Column Name\": \"Series\", \"Type\": \"string\", \"Enumerated Values\": [\"Monaco Grand Prix Formula Three\", \"TC 2000\", \"Fórmula 2 Codasur\", \"Stock Car Brasil\", \"Formula Renault Argentina\", \"International Formula 3000\", \"Super Turismo V8\", \"World Cup Formula 3000\", \"Top Race V6\", \"Top Race V6 Copa América\", \"Formula Three Sudamericana\", \"Italian Formula Three\", \"TC 2000 Endurance series\"]}\n{\"Column Name\": \"Poles\", \"Type\": \"string\", \"Enumerated Values\": [\"0\", \"2\", \"3\", \"?\", \"5\", \"1\", \"4\"]}\nQuestion: \nCan we analyze the correlation between the number of races Gabriel Furlán participated in each season and the number of wins he achieved in the same season?\n\n### Response:\n",
"maxTokens": 512,
"temperature": 0.8,
"presencePenalty": 0,
"frequencyPenalty": 0
}
Output
The output from this action typically includes a detailed response generated by the model based on the input prompt. Here’s a conceptual example of what you might receive:
# Prepare the data: convert "Races" and "Wins" to numerical values, and replace '?' and 'N/A' with NaN
career_summary['Races'] = pd.to_numeric(career_summary['Races'], errors='coerce')
career_summary['Wins'] = pd.to_numeric(career_summary['Wins'], errors='coerce')
career_summary = career_summary.dropna(subset=['Races', 'Wins'])
# Calculate the correlation
correlation = career_summary['Races'].corr(career_summary['Wins'])
print(f"The correlation between the number of races and the number of wins is {correlation}")
Conceptual Usage Example (Python)
Here’s how you might call this action using Python:
import requests
import json
# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint
action_id = "70fdb2e3-a142-4d68-9d6b-f9a6e09ab65e" # Action ID for Perform Data Analysis Using Pandalyst
# Construct the input payload based on the action's requirements
payload = {
"topK": -1,
"topP": 0.95,
"prompt": "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n### Instruction:\nDataframe Name: Career summary, with 43 rows and 9 columns.\nDescription: This is a table about Gabriel Furlán: Career summary\nColumns: Season, Series, Team, Races, Wins, Poles, Podiums, Points, Position\nHere are the descriptions of the columns of the dataframe:\n{\"Column Name\": \"Season\", \"Type\": \"int\", \"MIN\": 1984, \"MAX\": 2011}\n{\"Column Name\": \"Wins\", \"Type\": \"string\", \"Enumerated Values\": [\"0\", \"6\", \"2\", \"3\", \"7\", \"?\", \"5\", \"1\"]}\n{\"Column Name\": \"Position\", \"Type\": \"string\", \"Enumerated Values\": [\"9th\", \"18th\", \"2nd\", \"10th\", \"N/A\", \"13th\", \"7th\", \"4th\", \"6th\", \"3rd\", \"8th\", \"?\", \"1st\", \"16th\", \"11th\", \"19th\", \"5th\"]}\n{\"Column Name\": \"Podiums\", \"Type\": \"string\", \"Enumerated Values\": [\"9\", \"0\", \"3\", \"7\", \"?\", \"5\", \"1\", \"4\"]}\n{\"Column Name\": \"Team\", \"Type\": \"string\", \"Enumerated Values\": [\"INI Competición\", \"Junior Team\", \"Forti Corse\", \"GF Motorsport\", \"GF Racing\", \"Toyota Team Argentina\", \"Gustavo Sommi\", \"Ford\", \"DTA\", \"Maldonado Competición\", \"Sommi-Zanón\", \"Bainotti Dowen Pagio\", \"Scuderia 111\", \"Jolly Club\"]}\n{\"Column Name\": \"Races\", \"Type\": \"string\", \"Enumerated Values\": [\"9\", \"8\", \"13\", \"2\", \"7\", \"14\", \"18\", \"?\", \"5\", \"1\", \"12\", \"4\", \"11\"]}\n{\"Column Name\": \"Points\", \"Type\": \"string\", \"Enumerated Values\": [\"39\", \"90\", \"67\", \"0\", \"35.5\", \"79\", \"78\", \"52\", \"N/A\", \"16\", \"38\", \"26\", \"65\", \"144\", \"1\", \"139\", \"175\", \"42\", \"32\", \"46\"]}\n{\"Column Name\": \"Series\", \"Type\": \"string\", \"Enumerated Values\": [\"Monaco Grand Prix Formula Three\", \"TC 2000\", \"Fórmula 2 Codasur\", \"Stock Car Brasil\", \"Formula Renault Argentina\", \"International Formula 3000\", \"Super Turismo V8\", \"World Cup Formula 3000\", \"Top Race V6\", \"Top Race V6 Copa América\", \"Formula Three Sudamericana\", \"Italian Formula Three\", \"TC 2000 Endurance series\"]}\n{\"Column Name\": \"Poles\", \"Type\": \"string\", \"Enumerated Values\": [\"0\", \"2\", \"3\", \"?\", \"5\", \"1\", \"4\"]}\nQuestion: \nCan we analyze the correlation between the number of races Gabriel Furlán participated in each season and the number of wins he achieved in the same season?\n\n### Response:\n",
"maxTokens": 512,
"temperature": 0.8,
"presencePenalty": 0,
"frequencyPenalty": 0
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json"
}
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json={"action_id": action_id, "inputs": payload} # Hypothetical structure
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))
except requests.exceptions.RequestException as e:
print(f"Error executing action {action_id}: {e}")
if e.response is not None:
print(f"Response status: {e.response.status_code}")
try:
print(f"Response body: {e.response.json()}")
except json.JSONDecodeError:
print(f"Response body: {e.response.text}")
In this code snippet, replace the API key and endpoint with your actual values. The action ID and input payload are structured according to the requirements of the Perform Data Analysis Using Pandalyst action.
Conclusion
The Pandalyst Cognitive Actions provide an efficient way for developers to integrate advanced data analysis capabilities into their applications. By leveraging these actions, you can derive meaningful insights from complex datasets with ease. Consider exploring further use cases, such as real-time data processing or automated reporting, to fully harness the power of Pandalyst in your projects.