cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Machine Learning
Dive into the world of machine learning on the Databricks platform. Explore discussions on algorithms, model training, deployment, and more. Connect with ML enthusiasts and experts.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

CountVectorizer no longer works through Azure ML

dsiu
New Contributor II

Hello. I am trying to use the CountVectorizer module as part of our feature engineering. It works on a Databricks notebook directly, but when I try to run the code through Azure with the databricks connection, it throws an error. This isn't the first time I've had an issue with CountVectorizer. The weirdest part is that this same code has worked until last Thursday (07/28). I have tried the following which has solved previous issues.

  1. Launching a new clean cluster
  2. Changing spark.serializer back to default, since kyro serializer was causing issues
  3. Changing various spark-defaults.conf

Some things my searches have suggested that I haven't tried yet

  1. Reverting Java 11 -> Java 8
  2. Python Serializers

Thank you in advance for your help!

Code:

from pyspark.ml.feature import CountVectorizer
df = spark.createDataFrame([
    ("A", ['a','b']),
    ("B", ['a']),
    ("C", ['a','b','c']),
    ("D", ['d']),
    ("E", ['a','b','c']),
], ['ID','Category'])
cv = CountVectorizer(inputCol='Category',outputCol='vectors')
model = cv.fit(df)
model.transform(df).show()

Console Output & Error:

22/08/01 13:10:39 WARN Utils: Set SPARK_LOCAL_IP if you need to bind to another address
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.spark.unsafe.Platform (file:/anaconda/envs/major_medical_env_adb_py38/lib/python3.8/site-packages/pyspark/jars/spark-unsafe_2.12-3.1.1-SNAPSHOT.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of org.apache.spark.unsafe.Platform
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
22/08/01 13:10:40 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
22/08/01 13:10:41 WARN MetricsSystem: Using default name SparkStatusTracker for source because neither spark.metrics.namespace nor spark.app.id is set.
 
Traceback (most recent call last):
  File "test_sparse_adb_bare.py", line 14, in <module>
    model = cv.fit(df)
  File "/anaconda/envs/major_medical_env_adb_py38/lib/python3.8/site-packages/pyspark/ml/base.py", line 161, in fit
    return self._fit(dataset)
  File "/anaconda/envs/major_medical_env_adb_py38/lib/python3.8/site-packages/pyspark/ml/wrapper.py", line 335, in _fit
    java_model = self._fit_java(dataset)
  File "/anaconda/envs/major_medical_env_adb_py38/lib/python3.8/site-packages/pyspark/ml/wrapper.py", line 332, in _fit_java
    return self._java_obj.fit(dataset._jdf)
  File "/anaconda/envs/major_medical_env_adb_py38/lib/python3.8/site-packages/py4j/java_gateway.py", line 1304, in __call__
    return_value = get_return_value(
  File "/anaconda/envs/major_medical_env_adb_py38/lib/python3.8/site-packages/pyspark/sql/utils.py", line 117, in deco
    return f(*a, **kw)
  File "/anaconda/envs/major_medical_env_adb_py38/lib/python3.8/site-packages/py4j/protocol.py", line 326, in get_return_value
    raise Py4JJavaError(
py4j.protocol.Py4JJavaError: An error occurred while calling o41.fit.
: java.io.StreamCorruptedException: invalid type code: 01
   

1 REPLY 1

Noopur_Nigam
Valued Contributor II

Hi @Danny Siuโ€‹ Please check that you are using the latest dbconnect version corresponding to the DBR version that you are using in the databricks cluster.You can check the latest dbr version here: https://pypi.org/project/databricks-connect/#history

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group