Ransomware attacks have become increasingly sophisticated, targeting critical systems and encrypting vast amounts of data, often causing significant financial and operational damage. To address this escalating threat, a novel approach has been developed that leverages feature optimization techniques to enhance the performance of machine learning models for ransomware detection. Through the application of Recursive Feature Elimination (RFE) and Principal Component Analysis (PCA), the study demonstrates that reducing the feature space not only improves detection accuracy but also reduces false positives and computational overhead. The experiments conducted show that optimized models generalize effectively across a variety of ransomware strains, improving both efficiency and scalability. The findings demonstrate the critical role of feature selection in building adaptive and resilient ransomware detection systems, with potential applications in real-time cybersecurity infrastructure.