Skip to content

Instantly share code, notes, and snippets.

@amauryma55
Last active May 14, 2025 05:02
Show Gist options
  • Save amauryma55/87a17391944bb2e95a771b7f7a440826 to your computer and use it in GitHub Desktop.
Save amauryma55/87a17391944bb2e95a771b7f7a440826 to your computer and use it in GitHub Desktop.
# Predicciones y probabilidades
y_train_pred = model.predict(X_train)
y_train_proba = model.predict_proba(X_train)[:, 1]
y_test_pred = model.predict(X_test)
y_test_proba = model.predict_proba(X_test)[:, 1]
X_oos = df_model_monop[['var_1', 'var2']]
y_oos = df_model_monop['target']
y_oos_pred = model.predict(X_oos)
y_oos_proba = model.predict_proba(X_oos)[:, 1]
print("\n--- Entrenamiento (Train) ---")
print("Accuracy:", accuracy_score(y_train, y_train_pred))
print("F1 Score:", f1_score(y_train, y_train_pred))
print("AUC:", roc_auc_score(y_train, y_train_proba))
print("AR:", 2 * roc_auc_score(y_train, y_train_proba) - 1)
print("\n--- Prueba (Test) ---")
print("Accuracy:", accuracy_score(y_test, y_test_pred))
print("F1 Score:", f1_score(y_test, y_test_pred))
print("AUC:", roc_auc_score(y_test, y_test_proba))
print("AR:", 2 * roc_auc_score(y_test, y_test_proba) - 1)
print("\n--- Fuera de muestra (OOS) ---")
print("Accuracy:", accuracy_score(y_oos, y_oos_pred))
print("F1 Score:", f1_score(y_oos, y_oos_pred))
print("AUC:", roc_auc_score(y_oos, y_oos_proba))
print("AR:", 2 * roc_auc_score(y_oos, y_oos_proba) - 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment