antitheft159 commited on
Commit
62e7298
·
verified ·
1 Parent(s): 79de665

Upload securecyphercreditcardanalysis_space.py

Browse files
securecyphercreditcardanalysis_space.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """securecyphercreditcardanalysis.space
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1WKtvyEIBM5bPAPOmwXTGkEAp8mSFNKii
8
+ """
9
+
10
+ import numpy as np
11
+ import pandas as pd
12
+
13
+ import os
14
+ for dirname, _, filenames in os.walk('/kaggle/input'):
15
+ for filename in filenames:
16
+ print(os.path.join(dirname, filename))
17
+
18
+ import numpy as np
19
+ import pandas as pd
20
+ from sklearn.preprocessing import StandardScaler
21
+ from sklearn.model_selection import train_test_split, GridSearchCV
22
+ from sklearn.svm import SVC
23
+ from sklearn.metrics import classification_report, confusion_matrix
24
+ import joblib
25
+ import matplotlib.pyplot as plt
26
+
27
+ input = pd.read_csv('/content/credit_card_fraud_synthetic.csv')
28
+
29
+ data = input.drop(['Timestamp', 'Transaction_Type', 'Location', 'Transaction_ID'], axis = 1)
30
+
31
+ data
32
+
33
+ y = data['Is_Fraudulent']
34
+ x = data.drop('Is_Fraudulent', axis = 1)
35
+ X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.3, random_state=42)
36
+
37
+ svm_model = SVC(kernel='rbf')
38
+ svm_model.fit(X_train, y_train)
39
+
40
+ y_pred = svm_model.predict(X_test)
41
+
42
+ print("Confusion Matrix:")
43
+ print(confusion_matrix(y_test, y_pred))
44
+
45
+ print("Classification Report:")
46
+ print(classification_report(y_test, y_pred))
47
+
48
+ from sklearn.metrics import accuracy_score
49
+ Accu = accuracy_score(y_test, y_pred)
50
+ Accu = Accu * 100
51
+ print("The Accuracy of the model is ", round(Accu, 2), "%")