Generative AI

Study to create data science agent: Code use using Gemini-2.0-flash-Lite model with Google API, Google.GenerativeIn, Pandas and Ipsython.Display active data analysis

In this lesson, we show the strongest Python compilation of fraudulent databases for advanced Google Cloud skills with Google.Gendi Pro Model. By setting up the nature and libraries required, preparing for the Google Cloud API lock, and the tendency to ipython displays the action method by the action of building data in the data-selling Data. For example shows how you can change the dataframe into the format of Markuw

!pip install pandas google-generativeai --quiet

First, we include Pandas and Google-Generativewai library libraries, which puts on the strongest nature of the AI.

import pandas as pd
import google.generativeai as genai
from IPython.display import Markdown

We import ponds to deceive data, Google.GenerativeIn to Find the Power of AI for Build Google, and Marketing from ythony.Display to provide the relief effects Markdown.

GOOGLE_API_KEY = "Use Your API Key Here"
genai.configure(api_key=GOOGLE_API_KEY)


model = genai.GenerativeModel('gemini-2.0-flash-lite')

We provide the Placel API key, prepare the Google.Genature Client, and start a 'Gemini-2.0-Lite' GenerativeModel to produce content.

data = {'Product': ['Laptop', 'Mouse', 'Keyboard', 'Monitor', 'Webcam', 'Headphones'],
        'Category': ['Electronics', 'Electronics', 'Electronics', 'Electronics', 'Electronics', 'Electronics'],
        'Region': ['North', 'South', 'East', 'West', 'North', 'South'],
        'Units Sold': [150, 200, 180, 120, 90, 250],
        'Price': [1200, 25, 75, 300, 50, 100]}
sales_df = pd.DataFrame(data)


print("Sample Sales Data:")
print(sales_df)
print("-" * 30)

Here, we create a pandas datafum called Sales_Daphum that contains sample sales data for various products, and prints the datafum followed by a separate distinguishing line.

def ask_gemini_about_data(dataframe, query):
    """
    Asks the Gemini Pro model a question about the given Pandas DataFrame.


    Args:
        dataframe: The Pandas DataFrame to analyze.
        query: The natural language question about the DataFrame.


    Returns:
        The response from the Gemini Pro model as a string.
    """
    prompt = f"""You are a data analysis agent. Analyze the following pandas DataFrame and answer the question.


    DataFrame:
    ```
    {dataframe.to_markdown(index=False)}
    ```


    Question: {query}


    Answer:
    """
    response = model.generate_content(prompt)
    return response.text

Here, we are built a huge attack from Pandas data and natural language, and then using Gemini Pro Model to produce and restore analytical response.

# Query 1: What is the total number of units sold across all products?
query1 = "What is the total number of units sold across all products?"
response1 = ask_gemini_about_data(sales_df, query1)
print(f"Question 1: {query1}")
print(f"Answer 1:n{response1}")
print("-" * 30)
Question 1 Issuing
# Query 2: Which product had the highest number of units sold?
query2 = "Which product had the highest number of units sold?"
response2 = ask_gemini_about_data(sales_df, query2)
print(f"Question 2: {query2}")
print(f"Answer 2:n{response2}")
print("-" * 30)
Question 2 output
# Query 3: What is the average price of the products?
query3 = "What is the average price of the products?"
response3 = ask_gemini_about_data(sales_df, query3)
print(f"Question 3: {query3}")
print(f"Answer 3:n{response3}")
print("-" * 30)
Question 3 Effect
# Query 4: Show me the products sold in the 'North' region.
query4 = "Show me the products sold in the 'North' region."
response4 = ask_gemini_about_data(sales_df, query4)
print(f"Question 4: {query4}")
print(f"Answer 4:n{response4}")
print("-" * 30)
Question 4 Release
# Query 5. More complex query: Calculate the total revenue for each product.
query5 = "Calculate the total revenue (Units Sold * Price) for each product and present it in a table."
response5 = ask_gemini_about_data(sales_df, query5)
print(f"Question 5: {query5}")
print(f"Answer 5:n{response5}")
print("-" * 30)
Question 5 output

In conclusion, a lesson effectively demonstrates how to meet between panda, Google's package, and Geminit Pro Model can change the data analysis activities into interight process. This method is simplicity to ask and interpret and opens up the ways of the program developed such as cleaning data, detail engineering, and assessment data analysis. By installing the State-of-The-Art Tools within the General Python Ecosystem, data scientists can improve their product and perform new materials, making it easier to find logical insight from complex dataset.


Here is the Colab Notebook. Also, don't forget to follow Sane and join ours Telegraph station including LinkedIn Grtopic. Don't forget to join ours 85k + ml subreddit.


Asphazzaq is a Markteach Media Inc. According to a View Business and Developer, Asifi is committed to integrating a good social intelligence. His latest attempt is launched by the launch of the chemistrylife plan for an intelligence, MarktechPost, a devastating intimate practice of a machine learning and deep learning issues that are clearly and easily understood. The platform is adhering to more than two million moon visits, indicating its popularity between the audience.

Source link

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button