Model Selection by Loss Rank for Classification and Unsupervised Learning