We propose a nearest neighbor method of pattern recognition which is based on a weighted distance measure between patterns derived from profiles. There are new ingredients to the proposed method, compared to the conventional nearest ceighbor methods. The distance measure is defined as a weighted sum of each pattern component, and the weight paramters are optimized. We introduce a second-layer prediction procedure analogous to that in neural network methods. We first construct a pattern database, where the classification of each pattern is already known. Prediction for a query pattern is performed by examining patterns close to it. We apply the proposed method to predict the protein secondary structure of the proteins in the CB513 set and 29 proteins from CASP5 in blind fashion. We find that the performance of our approach, especially with the second-layer prediction, is almost comparable to the state-of-the-art method based on neural network methods.