This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tensorflow.keras.models import Sequential | |
from tensorflow.keras.layers import add, Dense, Dropout | |
from tensorflow.keras.optimizers import Adam | |
model = Sequential() | |
model.add(Dense(64,input_dim=29,activation='relu')) | |
model.add(Dense(32, activation = 'relu')) | |
model.add(Dropout(0.5)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Logistic Regression Classifier | |
logReg = LogisticRegression() | |
logReg.fit(X_train, y_train) | |
log_y_pred = logReg.predict(X_test) | |
log_precision = precision_score(y_test, log_y_pred) | |
log_recall = recall_score(y_test, log_y_pred) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Random Forest Classifier | |
rf = RandomForestClassifier(n_estimators = 15,random_state=42) | |
rf.fit(X_train, y_train) | |
y_pred = rf.predict(X_test) | |
precision = precision_score(y_test, y_pred) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
borderlineSMOTE = BorderlineSMOTE(k_neighbors = 10, random_state = 42) | |
X_train, y_train = borderlineSMOTE.fit_resample(X_train_Before,y_train_Before) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.preprocessing import StandardScaler | |
scaler = StandardScaler() | |
for i in X_train_Before: | |
scaler = StandardScaler() | |
X_train_Before[i] = scaler.fit_transform(X_train_Before[i].values.reshape(-1,1)) | |
X_test[i] = scaler.transform(X_test[i].values.reshape(-1,1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
X = data.drop(["Class","Time"],axis=1).values | |
y = data["Class"].values | |
X_train_Before, X_test, y_train_Before, y_test = train_test_split( | |
X, y, test_size = 0.3, | |
random_state = 42) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
correlation = data.corr() | |
fig = plt.subplots(figsize=(15,15)) | |
sns.heatmap(correlation, vmax= 1 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adjusting figuresize, and fontsize | |
plt.rcParams["figure.figsize"] = "8,6" | |
font = {'size': 12} | |
plt.rc('font', **font) | |
# Adding titles to the plots and axes | |
plt.title("Distribution of Time over Both Classes") | |
plt.xlabel("Time") | |
plt.ylabel("Class") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adjusting figuresize, and fontsize | |
plt.rcParams["figure.figsize"] = "8,6" | |
font = {'size': 12} | |
plt.rc('font', **font) | |
# Adding titles to the plots and axes | |
plt.title("Distribution of Amount over Both Classes") | |
plt.xlabel("Amount") | |
plt.ylabel("Class") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sns.countplot(x=data['Class']) | |
data["Class"].value_counts() |