Closed Fake45mar closed 5 months ago
What version of scikit-learn are you using?
@adriangb , '1.4.1.post1'
Same here. Using scikit-learn 1.4.1.post1 with scikeras 0.12.0.
TypeError: OneHotEncoder.__init__() got an unexpected keyword argument 'sparse'
From Scikit page: https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.OneHotEncoder.html
"sparse_outputbool, default=True When True, it returns a scipy.sparse.csr_matrix, i.e. a sparse matrix in “Compressed Sparse Row” (CSR) format.
New in version 1.2: sparse was renamed to sparse_output"
Could you please try #317 (pip install -U 'git+https://github.com/adriangb/scikeras.git@keras-3'
) and see if it fixes your problem? Thanks!
Thanks for the quick response! Just tested and did not see that error with this combination:
Previously, I was seeing the error with this combination:
This seemed to require an update to keras 3.2.0, and then I had to update tensorflow for compatibility. Not a bad thing, been wanting to upgrade, but did have to update some of my tf.keras references after this to be just keras.
Thank you for trying and confirming compatibility. Indeed I plan on releasing SciKeras 0.13.0 only with compatibility with Keras 3. As an unpaid maintainer I don’t have the resources to support multiple major versions of dependencies unfortunately.
This should be fixed now. Please let me know if this is still not fixed with SciKeras 0.13.0. Thanks!
def clean_text(df1,column,max_len,vocab_size): stemmer=PorterStemmer()
corpus=[]
for text in df1[column]:
text=re.sub("[^a-zA-Z]",' ',text)
text=text.lower()
text=text.split()
text=[stemmer.stem(w) for w in text if w not in stp]
text=" ".join(text)
corpus.append(text)
OneHotEncoder_word=[ OneHotEncoder(input_text=word,n=vocab_size) for word in corpus]
pad=pad_sequences(sequences= OneHotEncoder_word,max_len=max_len,padding='pre')
return pad
x_train=clean_text(df1,'Comment',vocab_size=10000,max_len=298)
TypeError Traceback (most recent call last) Cell In[100], line 1 ----> 1 clean_text(df1, 'Comment', vocab_size=10000, max_len=298)
Cell In[99], line 13, in clean_text(df1, column, max_len, vocab_size) 10 text=" ".join(text) 11 corpus.append(text) ---> 13 OneHotEncoder_word=[ OneHotEncoder(input_text=word,n=vocab_size) for word in corpus] 14 pad=pad_sequences(sequences= OneHotEncoder_word,max_len=max_len,padding='pre') 15 return pad
Cell In[99], line 13, in
TypeError: OneHotEncoder.init() got an unexpected keyword argument 'input_text'
@ellysabbath please open a new issue and provide a self contained reproducible example to report a bug. Thanks!
There is a problem in the file venv/lib/pythonX/site-packages/scikeras/utils/transformers.py
I use 'KerasClassifier' to be able to wrap my tensorflow model and put it into sklearn Voting Classifier.
The issue is in this segment:
I think it should be:
Please, take a look.
Thank you!