<jupyter_start><jupyter_text>Importing MLFlow<jupyter_code>import mlflow<jupyter_output><empty_output><jupyter_text>Retrieve Data<jupyter_code>class RandomPredictor(mlflow.pyfunc.PythonModel):
  def __init__(self):
    pass

  def fit(self):
    pass

  def predict(self, context, model_input):
    return model_input.apply(lambda column: random.randint(0,1))<jupyter_output><empty_output><jupyter_text>Set Experiment<jupyter_code>mlflow.set_experiment("Baseline_Predictions")<jupyter_output><empty_output><jupyter_text>Create model<jupyter_code>mlflow.sklearn.autolog()
model = LogisticRegression()<jupyter_output><empty_output><jupyter_text>Run the model<jupyter_code>with mlflow.start_run(run_name='logistic_regression_model_baseline') as run:
    model.fit(X_train, y_train)
    preds = model.predict(X_test)
    y_pred = np.where(preds>0.5,1,0)
    f1 = f1_score(y_test, y_pred)
    mlflow.log_metric(key="f1_experiment_score", value=f1)
f1<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1158974358974359, 'fraction_numerical': 0.011282051282051283, 'mean_word_length': 9.061855670103093, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 22, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '6464', 'license': 'MIT', 'n_tokens_mistral': 385, 'n_tokens_neox': 377, 'n_words': 40, 'path': 'Chapter05/gradflow/notebooks/random_custom_logging_model.ipynb', 'repo_name': 'waltatgit/Machine-Learning-Engineering-with-MLflow', 'size': '975'}