The primary contributor to lung cancer is an abnormal proliferation of lung cells. Tobacco usage and smoking cigarettes are the primary contributors to the development of lung cancer. The most common forms of lung cancer fall into two distinct types. Non-small-cell lung cancers and small-cell lung cancers are the two primary subtypes of lung cancer. A computed tomography, or CT, scan is an essential diagnostic technique that may determine the kind of cancer a patient has, its stage, the location of any metastases, and the degree to which it has spread to other organs. Other diagnostic tools include biopsies and pathology tests. The creation of algorithms that allow computers to gain information and abilities by seeing and interacting with the world around them is the core emphasis of the field of machine learning. This article demonstrates how to detect lung cancer via the use of machine learning by using improved feature selection and image processing. Image quality may be improved with the help of the CLAHE algorithm. The K Means technique is used in order to segment a picture into its component components. In order to determine which traits are beneficial, the PSO algorithm is utilised. The photos are then categorised using the SVM, ANN, and KNN algorithms respectively. It uses images obtained from a CT scan. When it comes to detecting lung cancer, PSO SVM provides more accurate results.