AI & Machine Learning Master Course — 151. Recommendation tasks and feedback
Smartyfy AI & Machine Learning Master Course
Course ID: smartyfy-ai-ml-master-200
Lesson 151: Recommendation tasks and feedback
Prerequisites: Lesson 150. Learning outcome: Separate explicit ratings, implicit interactions, exposure, and missing feedback.
Recommendation is a decision over available items
A recommendation system selects or orders items for a user or context. The task might be finding a useful article, suggesting a course lesson, or ranking products. Define the action and success measure before choosing a model: predicting a star rating, predicting a click, and selecting a useful top-ten list are different objectives.
The candidate set is part of the task. An item may be unavailable, already consumed, inappropriate for the context, or outside a user’s access permissions. Ranking an impossible item highly is not useful merely because its score is large. Evaluation should use the item availability that existed at the decision time.
Recommendation also creates feedback. What the system displays influences which interactions can be observed next. A dataset of clicks therefore reflects both user behavior and the previous presentation policy. It is not a complete map of every user’s preferences over every item.
Explicit feedback and implicit feedback say different things
Explicit feedback asks users to provide an assessment, such as a rating or a thumbs-down. Implicit feedback records behavior such as an impression, click, watch, save, or purchase. A click can signal interest, but it can also reflect curiosity, an accidental tap, or a misleading title.
Missing feedback is not an explicit negative. A user may never have seen the item, may have been busy, or may have chosen another relevant item. Even an exposed no-click does not necessarily mean dislike. Define the time window, event semantics, and target label carefully.
Repeated interactions can indicate stronger interest, repeated need, or interface friction. Collapsing counts into binary values discards that distinction. Conversely, treating every repeat as a fully independent positive can overrepresent a small number of highly active users. The aggregation rule belongs in the experiment record.
Exposure creates a selection mechanism
An impression records that an item was presented under a defined visibility rule. Without exposure data, unclicked user–item pairs mix unseen opportunities with seen-but-not-selected ones. Position, device, time, and previous recommendations can affect the chance of interaction.
Suppose item A receives ten clicks from one hundred impressions and item B receives four from ten. A has more clicks, while B has a larger observed click rate. Neither comparison alone proves which item every user would prefer: audiences and presentation positions may differ, and B’s denominator is small.
Causal evaluation of a changed recommendation policy requires stronger assumptions or experimental design than ordinary predictive scoring. Propensity weighting can address particular exposure mechanisms when its assumptions and logged probabilities are appropriate, but an arbitrary weight does not automatically remove all bias. This introductory lab does not estimate causal effects.
CPU lab: preserve three feedback states
The fictional matrix contains three users and three items, giving nine possible user–item pairs. Six pairs were exposed once. Three produced clicks and three produced no click. The remaining three are unexposed and represented by NaN rather than zero.
Item click counts are [2,1,0]. Observed click rates among exposed pairs are approximately [0.666667,0.5,0]. The pair u1–C remains unknown. Assertions verify the distinction between unexposed and exposed no-click states.
No recommender is trained and no policy is evaluated. The example checks a data representation. Its tiny rates are descriptive fixture statistics, not estimates of stable preference or an instruction to favor one item in a real system.
import numpy as np
users=['u1','u2','u3'];items=['A','B','C']
# One fictional impression for each listed user-item pair.
logs=[('u1','A',1),('u1','B',0),('u2','A',0),
('u2','B',1),('u3','A',1),('u3','C',0)]
feedback=np.full((3,3),np.nan)
for user,item,click in logs:
feedback[users.index(user),items.index(item)]=click
observed=np.isfinite(feedback)
print('Exposed / unexposed pairs:',int(observed.sum()),int((~observed).sum()))
print('Clicks / exposed no-click:',int(np.nansum(feedback)),int(np.sum(feedback==0)))
print('Item click counts:',np.nansum(feedback,axis=0).astype(int).tolist())
print('Observed click rates:',np.nanmean(feedback,axis=0).round(6).tolist())
assert np.isnan(feedback[0,2])
assert observed.sum()==6 and np.sum(feedback==0)==3
print('Unexposed u1-C remains unknown:',bool(np.isnan(feedback[0,2])))
Build evaluation around the actual use case
For returning users, a chronological split can hold out later interactions while retaining only earlier history for user profiles and item statistics. For new-user evaluation, hold out users entirely. For new-item evaluation, ensure the item has no interaction history available to the trained model. These tests measure different forms of generalization.
Keep derived popularity counts, embeddings, and negative-sampling choices inside the permitted training boundary. An item first released after an evaluation cutoff should not appear as a candidate for an earlier recommendation. A randomly held-out interaction can be useful for a narrow matrix-completion exercise, but it does not automatically reproduce future recommendation.
When evaluating top-k recommendations, define relevance judgments, candidate sampling, and already-consumed-item filtering. A model can look better when ranked against a few easy sampled negatives than against the full eligible catalog. Report the protocol rather than comparing incompatible scores.
Finally, distinguish immediate engagement from user value. A click-oriented objective can reward sensational or repetitive content. Use task-appropriate outcomes and guardrails, and inspect coverage, diversity, and relevant user groups. A recommendation system affects the data it will later learn from, so measurement choices shape the feedback loop.
Four practice questions with worked answers
Practice 1
Nine possible pairs contain six exposures and three clicks. How many exposed no-click and unexposed pairs exist?
Answer: There are six minus three equals three exposed no-click pairs, and nine minus six equals three unexposed pairs. Those two groups should not be conflated simply because neither has a click.
Practice 2
Compute click rates for ten clicks from one hundred impressions and four clicks from ten impressions.
Answer: The rates are 0.10 and 0.40. The smaller-exposure item has the larger observed rate, but different audiences, presentation conditions, and sampling uncertainty prevent a simple causal preference conclusion.
Practice 3
Why is an unexposed item not an explicit dislike?
Answer: The user had no recorded opportunity to interact with it under the exposure definition. Absence of a click therefore does not establish a negative assessment. Even an exposed no-click can have several explanations.
Practice 4
What split tests cold-start behavior for new items?
Answer: Keep selected items’ interaction histories unavailable during fitting and evaluate them using only information that would exist at their introduction, such as permitted metadata. Randomly hiding a few ratings for otherwise familiar items tests a different situation.
Five multiple-choice questions
Question 1
Which event is explicit feedback?
- A. A recorded impression with no click.
- B. A user-provided star rating.
- C. The absence of any logged user–item pair.
Correct: B. A rating directly expresses an assessment. Exposure and missing logs are behavioral or missing-data states, not explicit ratings.
Question 2
What does NaN represent in the lab matrix?
- A. A clicked pair whose rating is exactly zero.
- B. An exposed pair known to be disliked.
- C. A user–item pair with no recorded exposure.
Correct: C. Missing exposure is intentionally distinct from the zero used for exposed no-click. The lab contains click indicators, not zero-star ratings.
Question 3
Why can raw click popularity reflect the previous policy?
- A. The prior display position cannot affect whether an item is noticed.
- B. Every click is an independent randomized treatment assignment.
- C. Items shown more often have more opportunities to receive clicks.
Correct: C. Exposure and position shape observed opportunities. The logs do not automatically come from random assignment.
Question 4
Which evaluation targets future behavior of existing users?
- A. A test that assumes every missing pair is a confirmed dislike.
- B. A time-aware split using only their earlier histories at each decision.
- C. A random split that lets future clicks enter earlier user profiles.
Correct: B. Chronological information boundaries match future-use questions. Future-history leakage and unsupported negative labels distort the task.
Question 5
Why report candidate sampling in a ranking evaluation?
- A. Ranking against easy sampled negatives can differ from ranking the full eligible catalog.
- B. The candidate set has no effect on any top-k metric.
- C. Sampling negatives converts implicit feedback into verified explicit ratings.
Correct: A. The difficulty and metric depend on competing items. Sampling does not create new ground-truth preference statements.
Common pitfalls
Avoid treating missing interactions as dislike, confusing click counts with preference, fitting popularity on future events, or comparing ranking scores under different candidate sets. Preserve exposure and event semantics in the data.
Summary
Recommendation begins with a defined decision, eligible catalog, and feedback meaning. Explicit ratings, implicit behavior, exposure, and missingness provide different evidence. Honest evaluation respects both time and the policy that generated the observations.