Similarity-Based Pattern Recognition