liveBook · Manning

Human-in-the-loop

As explained in Starting Data Analytics with Generative AI and Python

Oversight is the monitoring and supervision of an AI system's performance, impacts, and compliance by responsible people or groups.

If an AI system classifies customer reviews, who notices when its answers look plausible but are wrong? Human oversight keeps people responsible for checking outputs, monitoring performance and impact, and correcting problems. Automation can flag issues, but it does not replace human judgment. section 1.3.6 section 5.2.1 section 8.2.1

Build review into the workflow:

  • Double-check AI results, especially before critical or high-stakes decisions; test performance on different tasks and datasets before full integration. section 1.3.6
  • Use automated data-quality checks to flag issues, then have domain experts periodically review both the data and the analysis. section 5.2.1
  • Assign responsibility for monitoring impacts, receiving concerns, and taking corrective action when needed. section 8.2.1

Reviewing a mismatched sentiment model

Suppose a Portuguese financial-news classifier is used to find positive customer reviews. Its training domain does not match the task, and sarcasm or regional expressions may cause errors. Inspect classifications against the original reviews and monitor recurring mistakes before relying on the filtered results. A label assumed to mean “positive” also needs verification. section 6.2.5

Listing 6.2 Extracting positive reviews with the help of a suboptimal model
import pandas as pd
from transformers import pipeline

# Assuming df is your DataFrame and it has a column named 
'review_comment_message'
# Load the sentiment analysis pipeline with the FinBERT-PT-BR model
classifier = pipeline("sentiment-analysis", 
model="lucas-leme/FinBERT-PT-BR")
def get_sentiment(review):
    try:
        result = classifier(review)[0]
        return result['label'], result['score']
    except Exception as e:
        print(f"Error processing review: {e}")
        return None, None
# Apply the sentiment analysis to each review
df['sentiment'], df['score'] = 
zip(*df['review_comment_message'].map(get_sentiment))
# Filter the DataFrame to only include positive reviews
positive_reviews_df = df[df['sentiment'] == 'LABEL_1']   
# Assuming 'LABEL_1' is positive; adjust label as necessary based on model
output
# Now positive_reviews_df contains only the positive reviews

The Python workflow records a sentiment label and score for each review, catches processing errors, and filters on `LABEL_1`. Those outputs give reviewers concrete cases to inspect; the listing explicitly treats the label’s meaning as an assumption to check. section 6.2.5

Oversight also extends beyond accuracy. Review how data is protected, whether outcomes are fair, and whether concerns can be reported. Revisit the policy as technology, laws, and expectations change. section 8.2.1 section 1.3.6

How Starting Data Analytics with Generative AI and Python covers it

How deep it goes
Outlines review, testing, error monitoring, and corrective action without specifying a formal audit procedure.
Examples
Uses Portuguese customer-review sentiment classification with a financial-news model to show why error monitoring matters.
What it assumes
Assumes familiarity with an analytics task and its data; the classifier example starts from an existing review DataFrame.
What you can do after
Practice/perform it by checking model outputs against reviews, monitoring errors, and escalating issues for corrective action.
How it connects
Links human oversight to data quality, model bias, privacy, fairness, and AI use policy.

Also explained in

Compare how 17 books explain human-in-the-loop →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Starting Data Analytics with Generative AI and Python. The section links point to the parts of the book it draws on.