Credit card has become an indispensable payment tool in People's Daily life. However, credit card fraud has also increased, resulting in huge financial losses for banks and individuals. Based on the real world credit card transaction data, this paper uses a variety of machine learning algorithms to identify and analyze credit card fraud. Firstly, the problem of missing and unbalanced data is solved through data preprocessing and feature selection, and important features are screened out, Such as transaction amount, product code, payment card type, etc. Then, integrated logistic regression, random forest, LightGBM, XGBoost, and Stacking models were constructed, and the models were trained and evaluated through cross-validation and parameter optimization. The experimental results show that the integrated Stacking model performs best in credit card fraud detection, with an AUC(Area Under the Curve) value of 0.960, which can accurately identify fraudulent transactions and provide an effective fraud warning mechanism for financial institutions. This mechanism significantly benefits both financial institutions and credit card users by reducing fraud losses and enhancing transaction security. However, it is acknowledged that the study has limitations, including the potential impact of data imbalance on model performance, the need for further testing of model generalization ability to new fraud patterns, and the importance of optimizing real-time performance to ensure practical applicability.