This is the primary way supervised methods work, with the loss function relativized to training label patterns.
for unsupervised learning, the primary candidate for an objective function is the data likelihood, and we don't have another suggestion here.