Pseudo-labeling and confidence
Quick answer
Semi-supervised learning uses a small labeled training set together with unlabeled training observations. Pseudo-labeling treats sufficiently confident model predictions as provisional labels, then refits the model. Confidence is not proof of correctness. Static examples tested locally with Python 3.13.5, scikit-learn 1.8.0 SciPy 1.17.0 and NumPy 2.3.5 where imported. ByteMind package execution is unverified.
Select provisional labels with an explicit strict threshold
scores=[[20,80],[19,81],[95,5],[50,50]]print([max(range(len(p)),key=p.__getitem__) if max(p)>80 else -1 for p in scores])Observed local output:
[-1, 1, 0, -1]The equality case abstains, and low-confidence rows keep the unlabeled sentinel.
How it works
Start with a classifier fitted on labeled rows. For each unlabeled row, compute class probabilities, choose the class with the highest probability, and accept its prediction if the maximum meets a chosen threshold. Refit on original labels plus accepted pseudo-labels; repeat with a bounded iteration count or stop when no rows qualify. For probabilities [0.2, 0.8] and a threshold of 0.75, accept class 1; for [0.45, 0.55], abstain. Some implementations use strict greater-than rather than greater-than-or-equal: scikit-learn SelfTrainingClassifier with criterion="threshold" uses a strict threshold. Its input labels mark unlabeled rows as -1, so that value cannot represent a real class. Its estimator needs predict_proba; use estimator= rather than the older base_estimator argument. The transduction_ attribute contains the final assigned labels, labeled_iter_ records when labels were assigned (0 for original labels and -1 for still-unlabeled samples). The approach assumes the initial model is informative about unlabeled data. Incorrect confident predictions may reinforce themselves (confirmation bias), especially under distribution shift or class imbalance. Use development-only validation to choose thresholds, inspect acceptance by class, and reserve a separate audit set where labels are available only after selection. A calibrated probability model can help but does not eliminate error. Never add held-out features to the fitting pool for inductive evaluation.
Fit a native self-training classifier
import numpy as npfrom sklearn.linear_model import LogisticRegressionfrom sklearn.semi_supervised import SelfTrainingClassifierX=np.array([[-5.],[-4.],[4.],[5.],[-6.],[6.],[0.]])y=np.array([0,0,1,1,-1,-1,-1])m=SelfTrainingClassifier(estimator=LogisticRegression(),threshold=.9,max_iter=3).fit(X,y)print(m.transduction_.tolist())print(bool((m.labeled_iter_[:4]==0).all()))Observed local output:
[0, 0, 1, 1, 0, 1, -1]TrueThe confident extremes are added; the symmetric center remains unassigned. Original labels are preserved.
Common mistakes
Do not interpret 0.9 confidence as guaranteed 90% accuracy, overwrite original labels, or use test features or labels in self-training. A high threshold can select no samples; report that outcome rather than silently lowering it.
Practice and next steps
At threshold 0.8, compare strict acceptance for maximum probabilities 0.79, 0.8 and 0.81. Explain how class imbalance could make a confident majority-class predictor harmful. Complete the knowledge check and staged exercise. Next: Label propagation and spreading.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Pseudo-labeling and confidence — knowledge check
Apply pseudo-labeling and confidence to new scenarios.
What does a pseudo-label represent?
At strict threshold 0.8, what happens to confidence 0.8?
What value marks unlabeled rows in SelfTrainingClassifier?
What is confirmation bias here?
Where should threshold selection happen?