Skip to main content

Data Analysis using LLAMA 3 and GROQ

Are you ready to move to the most effective level of big data analytics? In this post what we are going to discuss is the L3 and Panda’s AI and also the way we can use all of them in the data analysis process.

Getting Started

To get started, we’ll need to install Panda’s AI and Llama3 Groq model. We can do this using pip:


pip install pandas
pip install llama3-groq

Once both packages are installed, we can import the necessary libraries:


import pandas as pd
from pandas_ai import SmartDataFrame
from llama3_groq import ChatGroq

Loading the Data

Next, we’ll load our dataset, a CSV file called “Coffee Shop Sales”. We can use the read_csv function from Panda’s library:

data = pd.read_csv(‘coffee_shop_sales.csv’)

o1

Creating a Smart Data Frame

Next, we are going to create a Smart Data Frame; a main functionality of the Panda’s Artificial Intelligence. It’s used to interact with a single data frame and contains all the features and properties of a simple data frame, plus conversation features:

smart_df = SmartDataFrame(data, config={‘llm’: LLM})

Interacting with the Data

As a matter of fact, due to the chat function of the Smart Data Frame, we are actually able to deal with our data. For example, we can ask it to check if the data requires any cleaning or if there are any issues:

response = smart_df.chat(“Check if the data requires any cleaning or if there are any issues.”)
print(response)

o2

Data Cleaning

Now, we’ll look for the rows that need cleaning and clean the data.

response = smart_df.chat(“Can you show me the rows having missing values?”)
print(response)

o3

Descriptive Statistics

Firstly, we will have a look at our dataset for that we’ll ask it:

Tell me the number of rows and columns, as well as a description of the columns

o5

Next, we can ask the Smart Data Frame to provide descriptive statistics about our data:


response = smart_df.chat(“Provide descriptive statistics about the data.”)
print(response)

o6

Next, we’ll have a look at the average sales of each product category.

Calculate the overall average sales of each product category and also display it in a bar chart

o7

Next, we’ll have a quick look at the statistical summary of the dataset along with visualizations.

Please give me a statistical summary, along with histograms for all the numeric columns

o8

o9

o10

Exploratory Data Analysis

We can also perform exploratory data analysis on our data:


response = smart_df.chat(“Perform exploratory data analysis on each column of the data set and also provide appropriate visualizations.”)
print(response)

a1

a2

a3

a5

Sales Trend Analysis

Using the Smart Data Frame, we can also perform sales trend analysis:

response = smart_df.chat(“Explore the changes and trends in sales over time.”)
print(response)
a6
Next, we’ll view the sales breakdown for different store locations
Give me a breakdown of sales by location along with some noticeable differences

a7

a8

Prescriptive Analysis

Finally, we can ask the Smart Data Frame to provide prescriptive analysis and actionable recommendations on how to improve sales:

response = smart_df.chat(“Based on everything that you have observed in the data, highlight the key insights, key trends, and then generate actionable recommendations on how to improve the sales.”)
print(response)

a9

a10

0
    0
    Your Cart
    Your cart is emptyReturn to Courses