One of the popular approaches in recommendation systems is Collaborative Filtering (CF). The most significant step in CF is choosing the appropriate set of users. For this purpose, similarity measures are usually used for computing the similarity between a specific user and the other users. This paper proposes a new invasive weed optimization (IWO) based CF approach that uses users' context to identify important and effective users set. By using a newly defined similarity measure based on both rating values and a measure values called confidence, the proposed approach calculates the similarity between users and thus identifies and filters the most similar users to a specific user. It then uses IWO to calculate the importance degree of users and finally, by using the identified important users and their importance degrees it predicts unknown ratings. To evaluate the proposed method, several experiments have been performed on two known real world datasets and the results show that the proposed method improves the state of the art results up to 15% in terms of Root Mean Square Error (RMSE) and Mean Absolute Error (MAE).