Anonymous
Not applicable

@Dip Kundu​ :

It seems like the error you are facing is related to sparklyr, which is used to interact with Apache Spark from R, and not directly related to mlflow. The error message suggests that an object could not be found, but it's not clear which object it is.

It's possible that the error is caused by the fact that you are using loaded_model as a function, but it's not a function. When you load a model with mlflow_load_model(), you get an R object that represents the loaded model, and you can use this object to make predictions. However, you cannot call this object as a function directly.

Instead, you should use the appropriate method for making predictions with the loaded model. The method will depend on the type of model that you have loaded. For example, if you have loaded a Spark MLlib model, you can use the ml_predict() method from sparklyr to make predictions. If you have loaded an R model, you can use the appropriate predict() method for that model.

Here is an example of how you can use ml_predict() to make predictions with a KMeans model loaded from mlflow:

# load the model
logged_model <- 'runs:/996bc4f0ad2a4681a4acf42515ee73d5/model'
loaded_model <- mlflow_load_model(logged_model)
 
# create a spark DataFrame with the data you want to predict on
data_to_predict <- sdf_copy_to(sc, iris, "data_to_predict", overwrite = TRUE)
 
# use ml_predict() to make predictions
predictions <- ml_predict(loaded_model, data_to_predict)

Note that you need to provide a spark DataFrame as the second argument to ml_predict(). In this example, I'm creating a new spark DataFrame with the data you want to predict on.