Class imbalance limits the performance of most traditional algorithms. Cost-sensitive algorithm has been introduced to handle imbalanced datasets. The cost sensitive random forest can deal with imbalanced data better. However, the cost function of cost-sensitive algorithm does not consider the actual distribution of the sample set and feature weight. And for the final prediction of random forest, it adopts equal vote but the base classifiers in random forests are not of equal accuracy. This paper proposes an improved cost-sensitive random forest algorithm called ICSRF, which constructs a cost function based on the actual distribution of imbalanced data set and introduces the weight distance, then takes weighted voting according to the performance of the base classifier that can improve the classification accuracy. The experiment results show that the ICSRF algorithm has higher accuracy rate and can effectively improve the classification performance of a few classes.