<jupyter_start><jupyter_text>Linear Regression<jupyter_code>mlflow.start_run()
from sklearn.linear_model  import LinearRegression

lr = LinearRegression()

lr.fit(X_train, Y_train)
mlflow.sklearn.log_model(lr,'lr')
lr_predicted = lr.predict(x_test)
len(lr_predicted)
x_test.iloc[0]
y_test
from sklearn.metrics import mean_squared_error, r2_score
import math

mse = mean_squared_error(y_test, lr_predicted)
rmse = math.sqrt(mse) 
r2 = r2_score(y_test, lr_predicted)

mlflow.log_metric('mse',mse)
mlflow.log_metric('rmse',rmse)
mlflow.log_metric('r2',r2)
mse
rmse
r2
mlflow.end_run()
from xgboost import XGBRFRegressor, XGBRegressor
xgb_params = {
    'learning_rate':0.2,
    'n_estimators': 50,
    'random_state':42
}

with mlflow.start_run():
    xgb = XGBRegressor(**xgb_params)
    xgb.fit(X_train, y_train)
    mlflow.xgboost.log_model(xgb,'xgboost')
    xgb_predicted = xgb.predict(X_test)
    mse = mean_squared_error(y_test, xgb_predicted)
    rmse =  math.sqrt(mse)
    r2 = r2_score(y_test, xgb_predicted)
    mlflow.log_metric('mse',mse)
    mlflow.log_metric('rmse',rmse)
    mlflow.log_metric('r2',r2)
mse
rmse
r2
mlflow.get_experiment_by_name('house-prices-eda')
mlflow.list_run_infos('1')
mlflow.get_run('22244b5029fa40dd9aed46c213dc71fa')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12383177570093458, 'fraction_numerical': 0.029595015576323987, 'mean_word_length': 6.3428571428571425, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '345419', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 589, 'n_tokens_neox': 563, 'n_words': 74, 'path': 'notebooks/MLflow.ipynb', 'repo_name': 'DaviRamos/MLFlow', 'size': '1284'}