
Develop practical prompt engineering, generative AI, and data science skills through real projects using OpenAI API, XGBoost, SHAP, and AI agents, including handling hallucinations.
Diogo Alves de Rezende shares his data-driven background in management and analytics, and his Betacom startup's mission to help restaurants optimize menus and pricing using data.
set up Google Colaboratory for Python programming, upload the Python folder, link to Google Drive, and start new Google Colaboratory files with automatic saving.
Install Python and Jupyter on your laptop, install Jupyter with pip, launch in a browser, create ipynb notebooks, and compare local Jupyter with Google Colab; understand .py versus .ipynb.
Install R and the RStudio IDE on Windows or Mac OS by downloading from CRAN, following the prompts, and seeking help from IT if needed.
Explore the basics of prompt engineering, learn how AI language models like transformers process language with attention, and practice one-shot, few-shot, and chain-of-thought prompts in LM Studio.
Explore how transformers process language with input embeddings, positional encoding, and multi-head attention in encoder and decoder architectures. Learn how residual connections, feedforward networks, and softmax output produce language predictions.
Master prompt engineering by applying explicit instruction, zero-shot and few-shot prompting, and chain-of-thought reasoning to elicit accurate, relevant AI outputs; tailor prompts with clear context, examples, and step-by-step guidance.
Set up LM Studio to test prompts and compare with ChatGPT, using a free local setup and a lightweight llama 3.2 model (1B parameters).
Explore explicit instructions and one-shot prompts using LM Studio and llama 3.21 billion. Analyze writing styles, load models, and refine promotional emails for prompt engineering in data science.
Explore few-shot prompts in practice with LM Studio, comparing to regular prompts, and learn how to generate structured outputs with a consistent writing style, format, and vocabulary.
Explore how large language models learn from few-shot prompts—zero, one, and few-shot learning—alongside scaling laws and long-form factuality, with safety measures and bias considerations.
Practice chain-of-thought reasoning with LM Studio by solving reasoning problems and comparing to GPT-4, using think step by step and question-first prompts to improve accuracy.
Discover prompt engineering and chain of thought prompting to elicit step-by-step reasoning in large language models, compare few-shot and standard prompting, and apply methods across domains and tasks.
Master prompt engineering by using explicit instructions, one-shot and few-shot prompts, and chain-of-thought reasoning to elicit precise, creative responses from llms. Apply these techniques to business tasks with patient experimentation.
Explore tokenization and system messages to steer large language models, adjust temperature and top_p, and craft prompts that reveal bias, randomness, and accuracy.
Analyze how tokenization converts text into tokens—words, subword units, or characters—through Harry Potter examples, reducing ambiguity for AI models to understand and generate language.
Demonstrate how the OpenAI tokenizer splits text into tokens, reveals token IDs, and shows how capitalization and model selection affect tokenization with Harry and apples.
Explore tokenization quirks and bias in language models through hands-on prompts in prompt engineering, using rock-paper-scissors, dice, and strawberries to reveal how prompts shape ai behavior.
Explore system messages as the AI's guiding role and how prompt injection harms behavior. Build defenses with input sanitization, reinforced system messages, role separation, and guardrails.
explore lm studio's system message and system prompt features, experiment with model sizes and discovery tools, and craft concise personas to guide ai conversations.
Practice handling system messages and privacy rules by refusing to reveal a name, using the Diego Sanchez example, in a breaking the system message exercise.
Explore how system prompts can be crafted and tested to avoid revealing real names, using aliases like Diego, with an iterative challenge to build a robust, unbreakable system prompt.
Adjust generation model parameters like temperature, top k, top p, repetition penalty, and sampling mode to improve accuracy, diversity, and coherence in AI outputs for chatbots and content creation.
Explore LM Studio parameters such as temperature, top k, top p, and repeat penalty to balance randomness and precision in LLM outputs, with notes on presence and frequent penalties.
Master prompt engineering basics from tokenization and system messages to tuning llm parameters like temperature and top-p with concise prompts. Reflect on progress, troubleshoot iteratively, and envision innovative ai applications.
Explore how to improve AI reasoning and curb hallucinations through meta prompting, structured response patterns, analogical reasoning prompting, rephrase questions, anchored sources, multi persona collaborations, and emotion prompts.
Explore meta prompting for AI systems with six prompt engineering techniques, including reasoning and hallucination methods, demonstrated using GPT-4 and step-by-step prompts.
Explore analogical reasoning prompting to optimize prompt engineering by solving similar math problems, tapping into training data, and reducing hallucinations through structured example-less prompts.
Learn how rephrase and respond prompts work, with examples on even months and days, GPT-4 tests, and comparisons of zero shot, few shot, and chain-of-thought approaches.
Explore why hallucinations occur when language models rely on token probabilities rather than facts, and how grounding prompts such as according to Wikipedia and retrieval-augmented approaches improve accuracy.
Explore multi persona collaboration by guiding an AI to simulate discussions among experts, using prompts like 'please assume multiple personas' and comparing chain of thought and React prompts.
Explore emotion prompting as a prompt engineering technique and its impact across models like ChatGPT and GPT four, and discuss grounding outputs to sources to reduce hallucinations.
Learn to improve reasoning and reduce hallucinations through meta prompting, syntax emphasis, analogical reasoning, and rephrasing, while grounding outputs in sources and using multi‑persona collaboration and emotion prompts.
Explore how LLMs reason step by step, distinguishing true reasoning from pattern matching, and learn prompting strategies and evaluation methods to test logical consistency under distractions.
Learn how reasoning LLMs use internal chain-of-thought planning and hidden reasoning tokens to improve accuracy in multi-step tasks like coding and math, with slower but more reliable outputs.
Learn to prompt reasoning models with OpenAI focus, using developer messages as truth, apply zero-shot and few-shot tactics, manage reasoning and delimiters, and consider RAG contexts for clear outputs.
Explore how overthinking prompts large language models to spend hidden reasoning on decoy tasks, inflating costs and latency. Learn defense tactics like filtering and caching to mitigate these prompt injections.
Explore how reasoning models respond to prompt injection and overthinking, including Sudoku solving with GPT-4, context-aware prompts, token costs, and cybersecurity considerations in prompt engineering.
Explore how Apple's research shows large language models struggle with genuine math reasoning, as GSM 8-K variations and the GSM symbolic template expose reliance on pattern matching.
Explore the fundamentals of the OpenAI API with hands-on coding in Google Colab. Master text generation, system prompts, and parameters for practical email writing and LinkedIn posts.
Learn to use the OpenAI API for text with the chat completions endpoint and GPT-4, including API key setup, pip install, and the importance of the system prompt.
Learn how to set up an OpenAI API key for your data science projects, including creating a secret key in the OpenAI dashboard and storing it securely in Google Colab.
Set up the OpenAI API in Python by installing the OpenAI package, configuring API keys, and selecting models like GPT-4 while reviewing pricing and docs.
Generate text using the OpenAI API by designing system and user prompts to craft compelling emails, adopting one-sentence paragraphs, funny hooks, and copywriter-style prompts.
Explore the OpenAI API parameters and system prompts, configuring messages, model, temperature, max tokens, and penalties in chat completions.
Explore building reliable OpenAI API prompts using few-shot examples to craft emails, analyze writing style, and design a structured message flow with system, user, and assistant roles.
Explore how to set up and master the OpenAI API for text, using system prompts, temperature, tokens, and few-shot learning to tailor, optimize, and mimic writing styles.
Build a rock, paper, scissors game using OpenAI API, exploring bias and randomness. Implement three strategies: random, pattern analysis, and adaptive, and analyze temperature and prompts to reveal AI behavior.
learn how to set up the OpenAI API in Python, install the openai library, and configure the API key and model. run a rock-paper-scissors experiment to test strategies.
Implement a random rock paper scissors strategy in Python by defining system and user prompts and calling the AI API. Iterate on a get_ai_random_move function to generate moves.
Iteratively improve the system prompt in Python to guide a rock-paper-scissors agent toward a single word move. Experiment with randomness and temperature to study bias and output behavior.
Experiment with temperature parameters to influence AI move bias in a rock paper scissors game, comparing zero and higher temperatures and exploring adaptive strategies for game design.
Explore for tat strategy in rock paper scissors by defining a system prompt that uses last move and last result, changing after a loss and continuing after a win.
Build a rock, paper, scissors game in Python by defining a winner function and a play game loop that tracks rounds, moves, and a for tat strategy.
Build the analyst strategy for rock paper scissors by using a language model to analyze history and predict the next move, then test it against a random player.
Explore Python testing strategies by implementing a rock paper scissors game that pits a random player against an analyst strategy, tracks rounds, moves, and outcomes.
Explore how to use the OpenAI API's vision capabilities with GPT-4 to analyze images via URLs or base64 and build effective prompts with model, messages, and token limits.
Set up the Python OpenAI API by configuring the API key, importing base64, and connecting the client in Google Collaboratory to process images.
Analyze images from links with Python by using the OpenAI API to extract wine bottle information from an image URL, leveraging vision capabilities and GPT-4o mini.
Define a python function to encode images in base64 for the OpenAI image api, reading binary data, encoding to base64, decoding utf-8, and setting a practical system prompt.
Learn how to analyze images encoded in base64 using Python and the OpenAI chat completions API, extracting structured information with a system prompt and user prompt.
Wraps up a Python Google search workflow to query Vivino for wine ratings, extract links, and assemble a gleaned response, while iterating queries and output formatting.
Explore random forest as an ensemble of decision trees to predict customer satisfaction from airline data, using Python with hands-on coding, pre-processing, feature importance, and classification evaluation.
Explore ensemble learning and the random forest, a robust, versatile ensemble of decision trees trained on random data and features to improve accuracy, handle missing values, and model non-linear relationships.
Understand how a decision tree splits data to maximize information and entropy, and how random forests combine many trees for classification, with notes on regression using frequencies and averages.
Set up the random forest workflow in Google Colab, connect to Google Drive, import numpy, pandas, matplotlib, seaborn, load the customer survey data, and refer to its data dictionary.
Perform light data processing and exploratory data analysis in pandas, encoding gender and life cycle with get_dummies, and summarize satisfaction and returning customers via describe and group by means.
Isolate x and y, drop the id column, and compute a correlation matrix; visualize it with a Seaborn heatmap to reveal positive and negative relationships.
Split the data into training and test sets using sklearn's train_test_split, adjusting test_size and random_state, and consider stratify to preserve class proportions in classification.
Apply a random forest classifier from sklearn to fit on the training data, using default settings with 100 estimators and a random state, then explore simple parameter tuning.
Explore evaluation metrics for classification problems and distinguish balanced from imbalanced datasets using accuracy, precision, recall, F1, ROC AUC, and confusion matrix concepts.
Explore evaluation metrics for classification, including accuracy, precision, recall, F1 score, confusion matrix, and AUC ROC, with attention to balanced versus imbalanced data and business goals.
Assess the classification model by selecting appropriate metrics, focusing on understanding customer satisfaction with a balanced dataset, evaluating accuracy around 93%, and tuning parameters for improvement.
Identify tunable model parameters, define a parameter grid, and explore common options such as number of estimators, max depth, min samples split, min samples leaf, and max features.
Explore parameter tuning with grid search cv on scikit-learn's random forest classifier, configuring estimator, parameter grid, scoring, cross-validation, and resources to find 32 candidates across 160 fits.
Tune a random forest classifier with grid search and cross-validation to identify best parameters, compare accuracy score across configurations, and prepare for feature importance analysis.
Compute feature importance from a tuned model, build a pandas series, and plot top drivers—chocolate variety packaging, payment options, and delivery options—then drop non-drivers like gender and age.
Learn to build an actionable scatter plot in Python that maps median ratings against importance, identifies improvement areas, and guides focus with a four-quadrant chart and Pandas plotting.
Add labels to the plot by looping over rows, place text with score and importance, adjust font size, and introduce vertical and horizontal lines using the median as reference.
Color the chart with red and green spans, adding min-to-median and median-to-max areas to reveal KPI dynamics. Tweak alpha, margins, and layering with scatter to finalize a clearer, informative visualization.
Master random forest and ensemble learning through decision trees, training and evaluating classification models with train-test splits, correlation heatmaps, and feature importance, while applying business-focused insights.
Outline the problem statement for binary prediction in a bank telemarketing campaign with Xgboost. Explain how demographic drivers and segmentation influence opportunity cost and revenue, underscoring the analytic solution.
Introduce XGBoost as an extreme gradient boosting ensemble algorithm for classification and regression, highlighting its tree-based (and linear) approaches, parallel processing, and superior accuracy.
Explore how xgboost builds trees through iterative weighting, improves accuracy by focusing on misclassified cases, and uses ensemble learning to handle multicollinearity with observations and predictors for regression or classification.
Explore the quirks of xgboost: it cannot handle factors without dummy variables, treats missing values as information, and excels at capturing non-linear relationships.
Explore the dummy variable trap and how omitting one category prevents multi-collinearity in regression, preserving the baseline. Transform factors into dummy variables and define a hypothesis-driven dataset with train-test split.
Master root mean square error as the performance measure for xgboost in regression, quantifying gap between actual and predicted values and guiding cross validation and parameter tuning to improve accuracy.
Explore the bias-variance trade-off by comparing overfitting and underfitting, and learn how cross-validation helps find the sweet spot for reliable test-set performance.
Tune xgboost models by selecting parameters such as rounds, learning rate, min child weight, max depth, gamma, subsample, and column sample, using cross‑validation to find optimal values.
Explore Shap values and their role in model interpretability by ranking drivers like duration, with red high and blue low, and note correlation is not causation for management.
Set up xgboost in google colab, mount drive, import libraries, load bank full.csv, and build an xgboost model with shap explainable ai.
Transform the dependent variable from yes/no to zeros and ones, then split the data into training and test sets to address the unbalanced dataset and prepare xgboost d matrices.
Learn to build your first XGBoost model by setting key parameters, train with AUC and AUC PR evaluation, and apply early stopping to optimize performance.
Evaluate an imbalanced XGBoost model by generating predictions, applying a 0.5 threshold, and analyzing KPIs with a confusion matrix, a classification report, AUC, and AUC PR to optimize outcomes.
Evaluate a model over time by reporting precision, recall, and F1 for the minority class, and visualize a confusion matrix heatmap to guide future model improvements.
Build a function to print kpis and a heat map for the coefficient matrix, then evaluate the model with precision, recall, and f1 score using y true and y pred.
Transform categorical variables to numerical using pandas get_dummies, convert booleans to integers, and combine features for a train-test split to prepare data for modeling.
Build a second XGBoost model, configure params, train with 100 boost rounds and evals, and apply early stopping. Then predict and evaluate, improving precision, recall, and F1 for class one.
Explore how random parameter tuning uses randomness to find high-performing configurations with fewer evaluations than exhaustive grid search, acknowledging diminishing returns. Balance exploration and exploitation to achieve efficient model optimization.
Tune hyperparameters by building a tune grid and using randomized search cross-validation to optimize an XGBoost classifier with objective binary: logistic, exploring estimators, max depth, learning rate, subsample, and colsample_bytree.
Build the final XGBoost model from the best parameters, fit on training data, and generate probabilistic predictions; tune the threshold to maximize business objectives, guided by F1, precision, and recall.
Explore explainable AI with SHAP in XGBoost and learn to plot feature importance. Interpret SHAP values on unseen data to understand how features drive predictions.
Explore shap dependence plots to visualize interactions between age and housing, and interpret single-prediction force plots with positive and negative contributions.
Explore creating SHAP waterfall plots to visualize feature shifts and perform cohort analysis with age-based cohorts, using Shap values and summary plots for deeper insights.
Load the bank marketing dataset in R, fix semicolon separators in read.csv, identify 17 variables (16 predictors and a binary target), and transform categorical features into dummy variables.
Inspect data structure with str, identify numeric and character variables, convert non-numeric to dummy variables for xgboost, and create a numeric-only data set using the player package.
Explore summary statistics and a correlation matrix for a numerical data set, identify potential outliers, and discuss how xgboost's non-linearity mitigates their impact while noting multicollinearity considerations.
Learn how to add a dependent variable to a data set in R by binding it with cbind, placing the new column first, and renaming with the names function.
Learn to split a dataset into training and test sets in R using set.seed and the sample.split approach, with an 80/20 ratio and subset operations.
Isolate the Y and X from training and test sets, convert yes/no to zeros and ones via factor and numeric steps, and convert to matrices for Xgboost use.
Learn how to set XGBoost parameters for binary classification, optimize using AUC, and understand relationships among eta, max depth, subsample, gamma, and booster choices.
Detect your computer cores with a simple doParallel function and reserve one or two for yourself to speed up hyperparameter tuning with XGBoost's parallel processing.
Learn to run XGBoost in R, set up data and parameters, tune rounds and threads, use early stopping and set.seed, and evaluate with AUC on a training set.
Predict with the XGBoost model by calling predict on the test data, convert probabilities to binary outcomes with a 0.5 threshold, and assess using metrics like ROC AUC and accuracy.
Evaluate a model in R using a confusion matrix to compute accuracy, sensitivity, and specificity, and interpret business implications of predicting positives versus negatives.
Transform character variables into dummy variables with R's fast dummies package, use dummy_calls and remove_first_dummy to avoid the dummy variable trap, and create a dataset_dummy containing only the dummy features.
finalize the dataset by combining datasets with cbind, place the dependent variable at the front, remove the extra y_yes dummy, and prep for XGBoost with 43 variables using dplyr.
Reuse prior xgboost code to split the dataset into training and test sets. Isolate the y and x variables and run model two.
Evaluate the model by updating predictions to two and running the code with Xgboost, then note specificity improves toward 46% and plan hyperparameter tuning in the next video.
Initiate parallel processing for hyperparameter tuning by creating a CPU object, building a six-core cluster with make cluster, and registering it for parallel execution.
Isolate the y and x variables for cross-validation inputs, switch to data set instead of train/test, and use a different hyperparameter tuning library to evaluate the XGBoost model.
Configure cross-validation parameters in R using trainControl, set method to cv, enable parallel processing, and choose a five-fold split for parameter tuning.
Tune seven xgboost parameters in the first phase: eta, max_depth, subsample, colsample_bytree, min_child_weight, gamma, and n_rounds. Use an expand.grid with seq-generated ranges to explore values and refine around promising ones.
The lecture demonstrates cross validation and initial parameter tuning for an xgboost model in R, measures runtime with RS.time, and reviews the best tune grid and model accuracy.
Learn to perform a second round of xgboost parameter tuning, using copy-paste grid setup, dynamic eta, max depth, gamma, subsample, and minimum child weight, with cross-validation and result evaluation.
Run the final XGBoost model in R using tuned hyperparameters from the earlier steps, replacing model one with model three and validating the results for business-ready performance.
Evaluate the final XGBoost model using predictions and the confusion matrix, and analyze the business impact of threshold choices on specificity and revenue.
examine XGBoost explainability by exploring importance drivers and SHAP values in R, using a test set to identify top features and their direction.
Learn prompt engineering, generative AI and data science in 10 focused days.
I'm Diogo. This course takes you from how large language models work to prompts that make them reliable, then to building with the OpenAI API in Python, then to machine learning with random forest and XGBoost, and finally to AI agents with CrewAI. There are 14.5 hours of video, Python and R code you can follow along, and lifetime updates.
Day by day
Introduction: meet your instructor, download the course materials and set up Google Colab, Jupyter Notebook and R with RStudio.
Day 1: Basics of prompt engineering. How transformers and attention work, then explicit instructions, one-shot, few-shot and chain-of-thought prompting, practised in LM Studio with a local LLM.
Day 2: System messages and LLM parameters. Tokenization, the OpenAI tokenizer, how a system message steers a model, three challenges where you try to break it, and the generation parameters.
Day 3: Prompt engineering for better reasoning. Meta prompting, analogical reasoning, rephrase and respond, according-to prompting, multi-persona collaboration and emotion prompting, to improve reasoning and reduce hallucinations.
Day 4: Reasoning LLMs. How reasoning models work, how to prompt them, overthinking as a prompt injection, and a look at the Apple research paper on whether LLMs can really reason.
Day 5: OpenAI API for text. Set up your API key in Python, generate text, adjust parameters such as temperature and use few-shot examples.
Day 6: Capstone project. Can GPT play rock-paper-scissors? Build the game, improve the system prompt, test temperature and compare playing strategies.
Day 7: OpenAI API for images. Send images to a multimodal model from links and as base64, and add Google searches to the model.
Day 8: Random forest for customer satisfaction. Decision trees and ensembles, data processing, evaluation metrics, parameter tuning, feature importance and how to chart a great plot.
Day 9: XGBoost in Python and R. How XGBoost works, parameter tuning and cross-validation, evaluation (confusion matrix, AUC, RMSE, bias-variance), and SHAP values to explain the model.
Day 10: Agentic AI with CrewAI. Set up CrewAI, then build your first AI agent, a task, an AI crew and two more agents.
Why this course
Projects, not slides: a rock-paper-scissors AI, a customer-satisfaction model and your own AI agents
One path from prompting to the API to machine learning to agents
Python throughout, with R for the XGBoost section
Lifetime updates and a community to ask questions
Who it is for: developers, data analysts and students who already know basic Python (loops, functions).
Ready to build with prompt engineering, generative AI and data science? Enrol and start Day 1 today.