<jupyter_start><jupyter_text>Create Model  Spliting data and resampled<jupyter_code>X = data.drop('y', axis=1)
y = data['y']
X_resampled, y_resampled = SMOTE().fit_resample(X, y)
X_train, X_test, y_train, y_test = train_test_split(X_resampled, y_resampled, test_size=0.4, random_state=42)
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.fit_transform(X_test)
X_train.shape
model = Sequential()
model.add(Dense(units=60, activation='relu', input_dim=69))
model.add(Dense(units = 32, activation = 'relu'))
model.add(Dense(units = 32, activation = 'relu'))
model.add(Dense(units = 1, activation = 'sigmoid'))
model.compile(optimizer = 'adam', loss = 'binary_crossentropy', metrics = ['accuracy'])
model.fit(X_train, y_train, batch_size = 10, epochs = 100)

pred = model.predict(X_test)
pred
pred = (pred > 0.5)
pred
# pred = model.predict(X_test)<jupyter_output><empty_output><jupyter_text>Ligth GBM<jupyter_code>pipe = Pipeline([('model', LGBMClassifier())])
pipe.fit(X_train, y_train)
pipe.score(X_test, y_test)<jupyter_output><empty_output><jupyter_text>Cros Val Score<jupyter_code>def cross_val(pipe, X, y, cv):
    return cross_val_score(pipe, X, y, scoring='f1', cv=cv, n_jobs=-1)
cv = RepeatedStratifiedKFold(n_splits=5, n_repeats=3, random_state=42)
cross_val(pipe, X, y, cv).mean()<jupyter_output><empty_output><jupyter_text>Tune Model, com bayesian optimize<jupyter_code>params = {'model__learning_rate': [0.01], 'model__n_estimators': [8, 24, 50, 100, 500],
                   'model__num_leaves': [6, 8, 12, 16], 'model__boosting_type': ['gbdt'], 
                   'model__seed': [500],
                   'model__colsample_bytree': [0.65, 0.75, 0.8], 
                   'model__subsample': [0.7, 0.75], 'model__reg_alpha': [1, 2, 6],
                   'model__reg_lambda': [1, 2, 6]}
model_tune = BayesSearchCV(pipe, [(params, 20)], n_iter=-1, cv=cv)
model_tune.fit(X_train, y_train)
model_tune.score(X_test, y_test)
cross_val(model_tune, X, y)<jupyter_output><empty_output><jupyter_text>Submission<jupyter_code>y_pred = clf.predict(X_test)
f1_score(y_test, y_pred)
print(classification_report(y_test, y_pred))<jupyter_output>precision    recall  f1-score   support

           0       0.72      0.83      0.77      4467
           1       0.81      0.68      0.74      4552

    accuracy                           0.76      9019
   macro avg       0.76      0.76      0.76      9019
weighted avg       0.76      0.76      0.76      9019<jupyter_text>Submission<jupyter_code>pred = model.predict(X_test)
X_test.shape
test.shape
sub_pred = model.predict(test)
sub_pred
sub_pred.shape
df = pd.DataFrame()
df = pd.DataFrame(sub_pred, columns=['predicted'])
df = pd.concat([test['id'], df], axis=1)
df
df['predicted'] = df['predicted'].astype(bool)
df.to_csv('submission/14.csv', index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14689462665736217, 'fraction_numerical': 0.04815073272854152, 'mean_word_length': 4.279926335174954, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '468131', 'license': 'MIT', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1116, 'n_words': 198, 'path': 'ps_challenge.ipynb', 'repo_name': 'MaksonViini/PS-Data-Challenge-2021', 'size': '2866'}