The ability to estimate if a module or a class or a method is faulty, or not, is called the defect prediction. Prediction can be used to target the improvement efforts to those modules or classes that need it the most. We investigated the classification process (deciding if an element is faulty or not) in which the set of software metrics and several data mining algorithms were used. We conducted an experiment on ten open source projects. The data concerning defects were extracted from the repository of the control version system. In this study the process of choosing appropriate metrics for the defect prediction is described. In the selection process we use unique approach by random forest.