DataAnalyzr.ask(
user_input: str = None ,
outputs: list = None ,
plot_path: str = None ,
recommendations_params: dict = None ,
counts: dict = None ,
context: dict = None ,
** kwargs,
) -> dict
This method orchestrates the analysis process and generates visualization, insights, recommendations, and tasks based on the specified inputs and parameters.
It is the recommended method to use for generating visualization, insights, recommendations, and tasks.
The method coordinates the analysis process and generates visualisation, insights, recommendations, and tasks based on the specified parameters.
Uses the analysis
, visualisation
, insights
, recommendations
, and tasks
methods internally.
It allows for customization of outputs, analysis rerun, insights usage, recommendations format, output type, and counts.
The generated outputs are returned as a dictionary.
Parameters
The input string provided by the user for generating outputs.
user_input = "What are the insights for the dataset?"
List of outputs to generate. Possible values are visualisation
, insights
, recommendations
, and tasks
.
Defaults to ["visualisation", "insights", "recommendations", "tasks"]
.
outputs = [ "insights" , "recommendations" ]
Path to save the generated plot. Only relevant when outputs
includes visualisation
.
Defaults to generated_plots/<random-plot-name>.png
.
plot_path = "path/to/save/plot.png"
Parameters for generating recommendations. Includes from_insights
, output_type
and json_format
.
recommendations_params = {
"from_insights" : True ,
"output_type" : "json" ,
"json_format" : {
"Recommendation" : "Recommendation text" ,
"Reason" : "Reason for the recommendation" ,
"Impact" : "Impact of the recommendation" ,
},
}
Whether to generate recommendations from insights. Default is True.
Type of output for recommendations. Default is json
.
Format for the JSON output of recommendations.
Dictionary containing the counts of insights, recommendations, and tasks to generate.
counts = {
"insights" : 3 ,
"recommendations" : 3 ,
"tasks" : 5 ,
}
Number of insights to generate. Default is 3.
Number of recommendations to generate. Default is 3.
Number of tasks to generate. Default is 5.
Context dictionary for the analysis. Includes analysis
, visualisation
, insights
, recommendations
, and tasks
.
context = {
"analysis" : "Analyze sales data" ,
"visualisation" : "Context for visualisation" ,
"insights" : "Context for insights" ,
"recommendations" : "Improve sales performance" ,
"tasks" : "Analyze sales data" ,
}
Context for the analysis method.
Context for the visualisation method.
Context for the insights method.
Context for the recommendations method.
Context for the tasks method.
Whether to rerun the analysis before generating outputs. Default is True.
Maximum number of retries for generating outputs. Default is 10.
Time limit in seconds for generating outputs. Default is 45 for analysis and 60 for visualization.
Whether to automatically add questions with their SQL query or Python code to the vector store. Default is True.
Returns
Dictionary containing the generated outputs. Includes visualisation
, insights
, recommendations
, and tasks
.
response = {
"visualisation" : "path/to/plot.png" ,
"insights" : "-Insight 1 \n -Insight 2 \n -Insight 3" ,
"recommendations" : "Recommendation 1 \n Recommendation 2 \n Recommendation 3" ,
"tasks" : "Task 1 \n Task 2 \n Task 3 \n Task 4 \n Task 5" ,
}
Path to the generated plot.
Insights generated based on the analysis output.
Recommendations generated based on the analysis output.
Tasks generated based on the analysis output.
Example usage
# Ask for visualisation, insights, recommendations, and tasks
response = data_analyzr.ask(
user_input = "What are the insights for the dataset?" ,
outputs = [ "visualisation" , "insights" , "recommendations" , "tasks" ],
plot_path = "path/to/plot.png" ,
recommendations_params = {
"from_insights" : True ,
"output_type" : "json" ,
"json_format" : {
"Recommendation" : "Recommendation text" ,
"Reason" : "Reason for the recommendation" ,
"Impact" : "Impact of the recommendation" ,
},
},
counts = {
"insights" : 3 ,
"recommendations" : 3 ,
"tasks" : 5 ,
},
context = {
"analysis" : "Analyze sales data" ,
"visualisation" : "Context for visualisation" ,
"insights" : "Context for insights" ,
"recommendations" : "Improve sales performance" ,
"tasks" : "Analyze sales data" ,
},
rerun_analysis = True ,
max_retries = 5 ,
time_limit = 60 ,
auto_train = True ,
)
# Display the visualisation
from PIL import Image
Image.open(response[ "visualisation" ]).show()
# Print insights
print (response[ "insights" ])
# Print recommendations
print (response[ "recommendations" ])
# Print tasks
print (response[ "tasks" ])