best_C = best["params"]["C"]
best_solver = best["params"]["solver"]
final_pipe = Pipeline([
("scaler", StandardScaler()),
("clf", LogisticRegression(
C=best_C,
solver=best_solver,
penalty="l2",
max_iter=2000,
random_state=42
))
])
with mlflow.start_run(run_name="final_model_run"Final_run:Metrics =
final_pipe.fit(X_train, y_train)
proba = final_pipe.predict_proba(X_test)[:, 1]
pred = (proba >= 0.5).astype(int)
metrics = {
"test_auc": float(roc_auc_score(y_test, proba)),
"test_accuracy": float(accuracy_score(y_test, pred)),
"test_precision": float(precision_score(y_test, pred, zero_division=0)),
"test_recall": float(recall_score(y_test, pred, zero_division=0)),
"test_f1": float(f1_score(y_test, pred, zero_division=0)),
}
mlflow.log_metrics(metrics)
mlflow.log_params({"C": best_C, "solver": best_solver, "model": "LogisticRegression+StandardScaler"})
input_example = X_test.iloc[:5].copy()
signature = infer_signature(input_example, final_pipe.predict_proba(input_example)[:, 1])
model_info = mlflow.sklearn.log_model(
sk_model=final_pipe,
artifact_path="model",
signature=signature,
input_example=input_example,
registered_model_name=None,
)
print("Final run_id:", final_run.info.run_id)
print("Logged model URI:", model_info.model_uri)
eval_df = X_test.copy()
eval_df["label"] = y_test.values
eval_result = mlflow.models.evaluate(
model=model_info.model_uri,
data=eval_df,
targets="label",
model_type="classifier",
evaluators="default",
)
eval_summary = {
"metrics": {k: If isinstance (v, (int. float. np.floating), else str(v).
for k, v in eval_result.metrics.items()},
"artifacts": {k: str(v) for k, v in eval_result.artifacts.items()},
}
mlflow.log_dict(eval_summary, "evaluation/eval_summary.json")
Trending
- DeepSeek AI releases DeepSeek V4: Sparse attention and heavily compressed attention enable one-million-token contexts.
- AI-Designed drugs by a DeepMind spinoff are headed to human trials
- Apple’s new CEO must launch an AI killer product
- OpenMythos Coding Tutorial: Recurrent-Depth Transformers, Depth Extrapolation and Mixture of Experts Routing
- 5 Reasons to Think Twice Before Using ChatGPT—or Any Chatbot—for Financial Advice
- OpenAI Releases GPT-5.5, a Absolutely Retrained Agentic Mannequin That Scores 82.7% on Terminal-Bench 2.0 and 84.9% on GDPval
- Your Favorite AI Gay Thirst Traps: The Men Behind them
- Mend Releases AI Safety Governance Framework: Masking Asset Stock, Danger Tiering, AI Provide Chain Safety, and Maturity Mannequin

