Cancer that starts in hepatic cells is known as liver cancer, and hepatocellular carcinoma (HCC) is one of the typical kinds of liver cancer. Furthermore, it is the main malignancy that mostly occurs in people with underlying chronic liver disease and cirrhosis caused by hepatitis B or C infection. HCC ranks fourth as a leading cause of cancer deaths in the world, so it is important to do an early diagnosis as well as appropriate treatment for preventing this disease. In previous years, machine learning has been used by some studies to diagnose HCC. In this study, Particle Swarm Optimization (PSO) selection feature and Random Forest (RF) will be used to classify the HCC dataset gained from Al-Islam Hospital, Bandung, Indonesia. The dataset contains 192 patients, with 66 HCC and 126 non-HCC patients. Furthermore, there were seven features and two classes. This study aims to determine whether the PSO selection feature is useful for increasing the RF classifier performances by measuring some indicators, such as accuracy, precision, recall, and f1-score. The results showed PSO-RF method gave the best performance with 100% accuracy, precision, recall, and f1-score when five features were selected. Meanwhile, by using only RF classifier, the accuracy, precision, recall, and f1-score obtained were 99.42%, 100%, 98.31%, and 99.15% respectively when using 90% of the training data. Hence, it was concluded that adding the PSO selection feature to the RF classifier is useful for increasing the performance.