<jupyter_start><jupyter_text>Import dependencies<jupyter_code>import pandas
import numpy as np
import mlflow
import tensorflow
from tensorflow import keras
import mlflow.keras
from sklearn.metrics import f1_score,confusion_matrix
from sklearn.model_selection import train_test_split<jupyter_output><empty_output><jupyter_text>Retrieve Data<jupyter_code>pandas_df = pandas.read_csv("training_data.csv")
X=pandas_df.iloc[:,:-1]
Y=pandas_df.iloc[:,-1]
X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.33, random_state=4284, stratify=Y)<jupyter_output><empty_output><jupyter_text>Run the Model<jupyter_code>mlflow.set_experiment("Baseline_Predictions_Mlflow_Check")
mlflow.tensorflow.autolog()

model = keras.Sequential([
  keras.layers.Dense(
    units=36,
    activation='relu',
    input_shape=(X_train.shape[-1],)
  ),
  keras.layers.BatchNormalization(),
  keras.layers.Dense(units=1, activation='sigmoid'),
])

model.compile(
  optimizer=keras.optimizers.Adam(lr=0.001),
  loss="binary_crossentropy",
  metrics="Accuracy"
)

with mlflow.start_run(run_name='keras_model_baseline') as run:
    model.fit(X_train, y_train, epochs=20, validation_split=0.05, shuffle=True,verbose=)

import mlflow
logged_model = '/data/artifacts/1/132e6fa332f2412d85f3cb9e6d6bc933/artifacts/model'

# Load model as a PyFuncModel.
loaded_model = mlflow.pyfunc.load_model(logged_model)

# Predict on a Pandas DataFrame.
import pandas as pd
loaded_model.predict(pd.DataFrame(X_test))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1171409662475182, 'fraction_numerical': 0.02911978821972204, 'mean_word_length': 7.842105263157895, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '303575', 'license': 'MIT', 'n_tokens_mistral': 601, 'n_tokens_neox': 574, 'n_words': 84, 'path': 'Chapter05/gradflow/notebooks/mlflow_run_keras.ipynb', 'repo_name': 'waltatgit/Machine-Learning-Engineering-with-MLflow', 'size': '1511'}