'StringIndexerModel' object has no attribute '_java_obj'

14 Views Asked by At

I am trying to load a PipeLineModel by using PipeLineModel.load("Path") and getting this error:

Traceback (most recent call last): line 53, in __del__ if SparkContext._active_spark_context and self._java_obj is not None: ^^^^^^^^^^^^^^ AttributeError: 'StringIndexerModel' object has no attribute '_java_obj'

My code:

from pyspark.ml import PipelineModel, Model
# Function to run Ml Model for prediction...
    def runModel(self, request_df: DataFrame, weight: str) -> DataFrame:
        model_location = self.__model_location + weight
        if self.__pipeline_mnodel_HM is None:
            self.__pipeline_mnodel_HM = {}
        print("model_location", model_location)
        pipeline_model: PipelineModel = self.__pipeline_mnodel_HM.get(
            model_location, PipelineModel.load(model_location)
        )
        self.__pipeline_mnodel_HM.setdefault(model_location, pipeline_model)

        prediction: DataFrame = pipeline_model.transform(request_df)

        return prediction

Note: It loads the model fine on my local wsl ubuntu distro but when I try to run the service fro this code in a linux server it gives me this error.

I tried rechecking the location in the server and it is fine.

0

There are 0 best solutions below