I am running a linear regression model and I would like to add the coefficients and P-values of each variable and the variable name in to the metrics of the mlflow output. I am new to using mlflow and not very familiar in doing this. Below is an example of part of my code
with mlflow.start_run(run_name=p_key + '_' + str(o_key)):
lr = LinearRegression(
featuresCol = 'features',
labelCol = target_var,
maxIter = 10,
regParam = 0.0,
elasticNetParam = 0.0,
solver="normal"
)
lr_model_item = lr.fit(train_model_data)
lr_coefficients_item = lr_model_item.coefficients
lr_coefficients_intercept = lr_model_item.intercept
lr_predictions_item = lr_model_item.transform(train_model_data)
lr_predictions_item_oos = lr_model_item.transform(test_model_data)
rsquared = lr_model_item.summary.r2
# Log mlflow attributes for mlflow UI
mlflow.log_metric("rsquared", rsquared)
mlflow.log_metric("intercept", lr_coefficients_intercept)
for i in lr_coefficients_item:
mlflow.log_metric('coefficients', lr_coefficients_item[i])
Would like to know whether this is possible? In the final output I should have the intercept, coefficients, p-values and the relevant variable name.