Gemini is a family of Google generative AI models that can assist with data analysis through a chat interface or an API. A practical question is whether it can help turn a request such as “find positive Portuguese customer reviews” into keywords and working Python code. It can propose both, but the results still need testing against the data. section 1.3.1 section 5.5.3
Choose an access route that fits the task:
- Use the Gemini web interface to enter a prompt and inspect its answer. Do not paste confidential data into a public service. section 1.3.1
- Use Google Vertex AI for programmatic requests. The illustrated Python setup installs google-cloud-aiplatform, identifies a Cloud project and location, and selects gemini-1.0-pro for text generation. The example also sets output and safety parameters; gemini-1.0-pro-vision is identified for multimodal requests. section 1.3.3
Listing 1.4 Example code to call Vertex AI on Google Cloud
import vertexai
from vertexai.generative_models import GenerativeModel, ChatSession,
HarmCategory, HarmBlockThreshold
# Replace PROJECT_ID with the ID of your Google Cloud project.
my_id = "PROJECT_ID"
# Replace with your Google Cloud location
my_location = "us-central1"
def generate_text(project_id: str, location: str, prompt: str) -> str:
# Initialize Vertex AI
vertexai.init(project=project_id, location=location)
# Load the model
model = GenerativeModel("gemini-1.0-pro")
# Generation config
config = {"max_output_tokens": 2048, "temperature": 0.4, "top_p": 1,
"top_k": 32}
# Safety config
safety_config = {
HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT:
HarmBlockThreshold.BLOCK_LOW_AND_ABOVE,
HarmCategory.HARM_CATEGORY_HARASSMENT:
HarmBlockThreshold.BLOCK_LOW_AND_ABOVE
}
# Generate content
responses = model.generate_content(
[prompt],
generation_config=config,
stream=True,
safety_settings=safety_config,
)
text_responses = []
for response in responses:
text_responses.append(response.text)
return "".join(text_responses)
prompt = "What are all the colors in a rainbow?"
print(generate_text(my_id, my_location, prompt))
Inspect the Vertex AI Python listing for model selection, generation settings, and safety configuration before adapting it to a project. section 1.3.3
Check a proposed review filter
Prompt Gemini for Python code to extract positive Portuguese reviews from a dataframe column named review_comment_message. Its proposed approach combined keyword search with NLTK stopword removal and VADER sentiment scoring. That extra machinery is not automatically an improvement: stopword removal adds little to a single-word search, and the cited sentiment package was not designed for languages other than English. Run the code, inspect selected and rejected raw reviews, and revise the method or ask a more targeted question. section 5.5.6
Gemini Advanced can also suggest possible explanations for differences in delivery times between Brazilian states, including geography, carrier performance, and warehouse location. Treat these as hypotheses to investigate, not findings established by the model. Likewise, check generated keyword formats and API code: response formatting may vary, and a model may be unaware of API changes. For web research, compare its synthesis with the underlying sources rather than accepting a fluent answer on trust. section 4.5 section 5.5.3 section 5.7






