| |
| """securecyphercreditcardanalysis.space |
| |
| Automatically generated by Colab. |
| |
| Original file is located at |
| https://colab.research.google.com/drive/1WKtvyEIBM5bPAPOmwXTGkEAp8mSFNKii |
| """ |
|
|
| import numpy as np |
| import pandas as pd |
|
|
| import os |
| for dirname, _, filenames in os.walk('/kaggle/input'): |
| for filename in filenames: |
| print(os.path.join(dirname, filename)) |
|
|
| import numpy as np |
| import pandas as pd |
| from sklearn.preprocessing import StandardScaler |
| from sklearn.model_selection import train_test_split, GridSearchCV |
| from sklearn.svm import SVC |
| from sklearn.metrics import classification_report, confusion_matrix |
| import joblib |
| import matplotlib.pyplot as plt |
|
|
| input = pd.read_csv('/content/credit_card_fraud_synthetic.csv') |
|
|
| data = input.drop(['Timestamp', 'Transaction_Type', 'Location', 'Transaction_ID'], axis = 1) |
|
|
| data |
|
|
| y = data['Is_Fraudulent'] |
| x = data.drop('Is_Fraudulent', axis = 1) |
| X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.3, random_state=42) |
|
|
| svm_model = SVC(kernel='rbf') |
| svm_model.fit(X_train, y_train) |
|
|
| y_pred = svm_model.predict(X_test) |
|
|
| print("Confusion Matrix:") |
| print(confusion_matrix(y_test, y_pred)) |
|
|
| print("Classification Report:") |
| print(classification_report(y_test, y_pred)) |
|
|
| from sklearn.metrics import accuracy_score |
| Accu = accuracy_score(y_test, y_pred) |
| Accu = Accu * 100 |
| print("The Accuracy of the model is ", round(Accu, 2), "%") |