title: cannot load a stringIndex model from HDFS
body: <p>When I use the stringindex to fit the train data, I want to save the index model for my predict data. And I saved to HDFS path successfully, But when I load it, it shows the error below. How could I load the index model correctly?</p>
  <pre><code>stringIndexerPath = &quot;hdfs://users/stringindexer&quot;
  stringindex_model.write().overwrite().save(stringIndexerPath) 
  loadedIndexer = StringIndexer.load(stringIndexerPath)
  </code></pre>
  <pre><code>Output exceeds the size limit. Open the full output data in a text editor
  ---------------------------------------------------------------------------
  Py4JJavaError                             Traceback (most recent call last)
  /ldap_home/yafeng.cheng/myproject/project_user_profile/apps/project_occupation/analyze/housewife/housewife_case_study.ipynb Cell 55' in &lt;cell line: 3&gt;()
        1 # from pyspark.ml.pipeline import PipelineModel
        2 # loadedIndexer = PipelineModel.load(stringIndexerPath)
  ----&gt; 3 loadedIndexer = StringIndexer.load(stringIndexerPath)
  
  File /usr/share/spark3/python/pyspark/ml/util.py:332, in MLReadable.load(cls, path)
      329 @classmethod
      330 def load(cls, path):
      331     &quot;&quot;&quot;Reads an ML instance from the input path, a shortcut of `read().load(path)`.&quot;&quot;&quot;
  --&gt; 332     return cls.read().load(path)
  
  File /usr/share/spark3/python/pyspark/ml/util.py:282, in JavaMLReader.load(self, path)
      280 if not isinstance(path, str):
      281     raise TypeError(&quot;path should be a string, got type %s&quot; % type(path))
  --&gt; 282 java_obj = self._jread.load(path)
      283 if not hasattr(self._clazz, &quot;_from_java&quot;):
      284     raise NotImplementedError(&quot;This Java ML type cannot be loaded into Python currently: %r&quot;
      285                               % self._clazz)
  
  File /usr/share/spark3/python/lib/py4j-0.10.9-src.zip/py4j/java_gateway.py:1304, in JavaMember.__call__(self, *args)
     1298 command = proto.CALL_COMMAND_NAME +\
     1299     self.command_header +\
     1300     args_command +\
  ...
      at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
      at py4j.commands.CallCommand.execute(CallCommand.java:79)
      at py4j.GatewayConnection.run(GatewayConnection.java:238)
      at java.lang.Thread.run(Thread.java:748)
  </code></pre>
  <pre><code>{
      &quot;name&quot;: &quot;Py4JJavaError&quot;,
      &quot;message&quot;: &quot;An error occurred while calling o3064.load.\n: java.lang.NoSuchMethodException: org.apache.spark.ml.feature.StringIndexerModel.&lt;init&gt;(java.lang.String)\n\tat java.lang.Class.getConstructor0(Class.java:3082)\n\tat java.lang.Class.getConstructor(Class.java:1825)\n\tat org.apache.spark.ml.util.DefaultParamsReader.load(ReadWrite.scala:468)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)\n\tat py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)\n\tat py4j.Gateway.invoke(Gateway.java:282)\n\tat py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)\n\tat py4j.commands.CallCommand.execute(CallCommand.java:79)\n\tat py4j.GatewayConnection.run(GatewayConnection.java:238)\n\tat java.lang.Thread.run(Thread.java:748)\n&quot;,
      &quot;stack&quot;: &quot;\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mPy4JJavaError\u001b[0m                             Traceback (most recent call last)\n\u001b[1;32m/user/case_study.ipynb Cell 55'\u001b[0m in \u001b[0;36m&lt;cell line: 1&gt;\u001b[0;34m()\u001b[0m\n\u001b[0;32m----&gt; &lt;a href='vscode-notebook-cell://ssh-remote%2Bdev01/user/case_study.ipynb#ch0000094vscode-remote?line=0'&gt;1&lt;/a&gt;\u001b[0m loadedIndexer \u001b[39m=\u001b[39m StringIndexer\u001b[39m.\u001b[39;49mload(stringIndexerPath)\n\nFile \u001b[0;32m/usr/share/spark3/python/pyspark/ml/util.py:332\u001b[0m, in \u001b[0;36mMLReadable.load\u001b[0;34m(cls, path)\u001b[0m\n\u001b[1;32m    329\u001b[0m \u001b[39m@classmethod\u001b[39m\n\u001b[1;32m    330\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mload\u001b[39m(\u001b[39mcls\u001b[39m, path):\n\u001b[1;32m    331\u001b[0m     \u001b[39m\&quot;\&quot;\&quot;Reads an ML instance from the input path, a shortcut of `read().load(path)`.\&quot;\&quot;\&quot;\u001b[39;00m\n\u001b[0;32m--&gt; 332\u001b[0m     \u001b[39mreturn\u001b[39;00m \u001b[39mcls\u001b[39;49m\u001b[39m.\u001b[39;49mread()\u001b[39m.\u001b[39;49mload(path)\n\nFile \u001b[0;32m/usr/share/spark3/python/pyspark/ml/util.py:282\u001b[0m, in \u001b[0;36mJavaMLReader.load\u001b[0;34m(self, path)\u001b[0m\n\u001b[1;32m    280\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39misinstance\u001b[39m(path, \u001b[39mstr\u001b[39m):\n\u001b[1;32m    281\u001b[0m     \u001b[39mraise\u001b[39;00m \u001b[39mTypeError\u001b[39;00m(\u001b[39m\&quot;\u001b[39m\u001b[39mpath should be a string, got type \u001b[39m\u001b[39m%s\u001b[39;00m\u001b[39m\&quot;\u001b[39m \u001b[39m%\u001b[39m \u001b[39mtype\u001b[39m(path))\n\u001b[0;32m--&gt; 282\u001b[0m java_obj \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_jread\u001b[39m.\u001b[39;49mload(path)\n\u001b[1;32m    283\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mhasattr\u001b[39m(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_clazz, \u001b[39m\&quot;\u001b[39m\u001b[39m_from_java\u001b[39m\u001b[39m\&quot;\u001b[39m):\n\u001b[1;32m    284\u001b[0m     \u001b[39mraise\u001b[39;00m \u001b[39mNotImplementedError\u001b[39;00m(\u001b[39m\&quot;\u001b[39m\u001b[39mThis Java ML type cannot be loaded into Python currently: \u001b[39m\u001b[39m%r\u001b[39;00m\u001b[39m\&quot;\u001b[39m\n\u001b[1;32m    285\u001b[0m                               \u001b[39m%\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_clazz)\n\nFile \u001b[0;32m/usr/share/spark3/python/lib/py4j-0.10.9-src.zip/py4j/java_gateway.py:1304\u001b[0m, in \u001b[0;36mJavaMember.__call__\u001b[0;34m(self, *args)\u001b[0m\n\u001b[1;32m   1298\u001b[0m command \u001b[39m=\u001b[39m proto\u001b[39m.\u001b[39mCALL_COMMAND_NAME \u001b[39m+\u001b[39m\\\n\u001b[1;32m   1299\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mcommand_header \u001b[39m+\u001b[39m\\\n\u001b[1;32m   1300\u001b[0m     args_command \u001b[39m+\u001b[39m\\\n\u001b[1;32m   1301\u001b[0m     proto\u001b[39m.\u001b[39mEND_COMMAND_PART\n\u001b[1;32m   1303\u001b[0m answer \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mgateway_client\u001b[39m.\u001b[39msend_command(command)\n\u001b[0;32m-&gt; 1304\u001b[0m return_value \u001b[39m=\u001b[39m get_return_value(\n\u001b[1;32m   1305\u001b[0m     answer, \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mgateway_client, \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mtarget_id, \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mname)\n\u001b[1;32m   1307\u001b[0m \u001b[39mfor\u001b[39;00m temp_arg \u001b[39min\u001b[39;00m temp_args:\n\u001b[1;32m   1308\u001b[0m     temp_arg\u001b[39m.\u001b[39m_detach()\n\nFile \u001b[0;32m/usr/share/spark3/python/pyspark/sql/utils.py:111\u001b[0m, in \u001b[0;36mcapture_sql_exception.&lt;locals&gt;.deco\u001b[0;34m(*a, **kw)\u001b[0m\n\u001b[1;32m    109\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mdeco\u001b[39m(\u001b[39m*\u001b[39ma, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkw):\n\u001b[1;32m    110\u001b[0m     \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m--&gt; 111\u001b[0m         \u001b[39mreturn\u001b[39;00m f(\u001b[39m*\u001b[39;49ma, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkw)\n\u001b[1;32m    112\u001b[0m     \u001b[39mexcept\u001b[39;00m py4j\u001b[39m.\u001b[39mprotocol\u001b[39m.\u001b[39mPy4JJavaError \u001b[39mas\u001b[39;00m e:\n\u001b[1;32m    113\u001b[0m         converted \u001b[39m=\u001b[39m convert_exception(e\u001b[39m.\u001b[39mjava_exception)\n\nFile \u001b[0;32m/usr/share/spark3/python/lib/py4j-0.10.9-src.zip/py4j/protocol.py:326\u001b[0m, in \u001b[0;36mget_return_value\u001b[0;34m(answer, gateway_client, target_id, name)\u001b[0m\n\u001b[1;32m    324\u001b[0m value \u001b[39m=\u001b[39m OUTPUT_CONVERTER[\u001b[39mtype\u001b[39m](answer[\u001b[39m2\u001b[39m:], gateway_client)\n\u001b[1;32m    325\u001b[0m \u001b[39mif\u001b[39;00m answer[\u001b[39m1\u001b[39m] \u001b[39m==\u001b[39m REFERENCE_TYPE:\n\u001b[0;32m--&gt; 326\u001b[0m     \u001b[39mraise\u001b[39;00m Py4JJavaError(\n\u001b[1;32m    327\u001b[0m         \u001b[39m\&quot;\u001b[39m\u001b[39mAn error occurred while calling \u001b[39m\u001b[39m{0}\u001b[39;00m\u001b[39m{1}\u001b[39;00m\u001b[39m{2}\u001b[39;00m\u001b[39m.\u001b[39m\u001b[39m\\n\u001b[39;00m\u001b[39m\&quot;\u001b[39m\u001b[39m.\u001b[39m\n\u001b[1;32m    328\u001b[0m         \u001b[39mformat\u001b[39m(target_id, \u001b[39m\&quot;\u001b[39m\u001b[39m.\u001b[39m\u001b[39m\&quot;\u001b[39m, name), value)\n\u001b[1;32m    329\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m    330\u001b[0m     \u001b[39mraise\u001b[39;00m Py4JError(\n\u001b[1;32m    331\u001b[0m         \u001b[39m\&quot;\u001b[39m\u001b[39mAn error occurred while calling \u001b[39m\u001b[39m{0}\u001b[39;00m\u001b[39m{1}\u001b[39;00m\u001b[39m{2}\u001b[39;00m\u001b[39m. Trace:\u001b[39m\u001b[39m\\n\u001b[39;00m\u001b[39m{3}\u001b[39;00m\u001b[39m\\n\u001b[39;00m\u001b[39m\&quot;\u001b[39m\u001b[39m.\u001b[39m\n\u001b[1;32m    332\u001b[0m         \u001b[39mformat\u001b[39m(target_id, \u001b[39m\&quot;\u001b[39m\u001b[39m.\u001b[39m\u001b[39m\&quot;\u001b[39m, name, value))\n\n\u001b[0;31mPy4JJavaError\u001b[0m: An error occurred while calling o3064.load.\n: java.lang.NoSuchMethodException: org.apache.spark.ml.feature.StringIndexerModel.&lt;init&gt;(java.lang.String)\n\tat java.lang.Class.getConstructor0(Class.java:3082)\n\tat java.lang.Class.getConstructor(Class.java:1825)\n\tat org.apache.spark.ml.util.DefaultParamsReader.load(ReadWrite.scala:468)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)\n\tat py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)\n\tat py4j.Gateway.invoke(Gateway.java:282)\n\tat py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)\n\tat py4j.commands.CallCommand.execute(CallCommand.java:79)\n\tat py4j.GatewayConnection.run(GatewayConnection.java:238)\n\tat java.lang.Thread.run(Thread.java:748)\n&quot;
  }
  </code></pre>