<jupyter_start><jupyter_text><jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
dff = pd.read_csv('/content/drive/MyDrive/Muniba_Project_CSV/dff.csv')
from sklearn.svm import SVC
from sklearn import svm, datasets
from sklearn.model_selection import train_test_split
X = dff.drop('Label',axis=1)
y = dff['Label']
X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=0.2, random_state=0)

print(X_train.shape, y_train.shape)

print(X_test.shape, y_test.shape)
type(X_train)
X_train_np = X_train.to_numpy()
X_test_np = X_test.to_numpy()

y_train_np = y_train.to_numpy()
y_test_np = y_test.to_numpy()

print(X_train_np.shape,X_test_np.shape,y_train_np.shape,y_test_np.shape)

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Input,Dense, Dropout
# input shape of our model
X_train_np[0].shape
# Model definition
model = Sequential()
model.add(Input(shape=(246,)))
model.add(Dense(16, activation = 'relu'))
model.add(Dropout(0.2))
model.add(Dense(246,activation = 'relu'))
model.add(Dropout(0.2))
model.add(Dense(1,activation = 'sigmoid'))

model
# configure model training
model.compile(optimizer = 'sgd',loss = 'binary_crossentropy', metrics = ['accuracy'])
# train model
history = model.fit(X_train_np,y_train_np,epochs = 92)
history.history
# Evaluate the model on the test data using `evaluate`
print("Evaluate on test data")
results = model.evaluate(X_test_np, y_test_np, batch_size=128)
print("test loss, test acc:", results)

# Generate predictions (probabilities -- the output of the last layer)
# on new data using `predict`
print("Generate predictions for 3 samples")
predictions = model.predict(X_test_np[:3])
print("predictions shape:", predictions.shape)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12321232123212321, 'fraction_numerical': 0.013751375137513752, 'mean_word_length': 6.943231441048035, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '120030', 'license': 'MIT', 'n_tokens_mistral': 680, 'n_tokens_neox': 663, 'n_words': 150, 'path': 'Copy_of_DL.ipynb', 'repo_name': 'Noman-Nosher/Data-Science-Tasks', 'size': '1818'}