autokeras
autokeras copied to clipboard
AttributeError: module 'numpy' has no attribute 'object' when using autokeras with structured data
I am encountering an error when using autokeras for structured data classification. When I try to fit a model, I receive the following error message:
AttributeError: module 'numpy' has no attribute 'object'.
np.object was a deprecated alias for the builtin object. To avoid this error in existing code, use object by itself. Doing this will not modify any behavior and is safe.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
I have already upgraded the autokeras library to the latest version, but the error persists.
Here is an example of how I am using autokeras:
import autokeras as ak
from kerastuner import Objective
f1_objective = Objective("f1", direction="max")
clf = ak.StructuredDataClassifier(
objective=f1_objective,
max_trials=10,
)
clf.fit(X_train, y_train)
best_model_id = clf.get_best_model_id()
print("Best model ID:", best_model_id)
best_model = clf.export_model(best_model_id)
print("Best model:", best_model)
trials = clf.get_trials()
for trial in trials:
print("Trial ID:", trial.id)
print("Hyperparameters:", trial.hyperparameters)
print("Performance metrics:", trial.metrics)
I got the same error for StructuredDataClassifier, Since Numpy 1.24, np.object is deprecated, and to be replaced with object
ERROR:500 Internal Server Error: module 'numpy' has no attribute 'object'.
`np.object` was a deprecated alias for the builtin `object`. To avoid this error in existing code, use `object` by itself. Doing this will not modify any behavior and is safe.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
on here
File "C:\Users\PA\anaconda3\envs\py3117\Lib\site-packages\autokeras\adapters\input_adapters.py", line 73, in convert_to_dataset
if isinstance(dataset, np.ndarray) and dataset.dtype == np.object:
I replaced np.object --> object, It worked. Can we update the library. Using Python 3.11.7 Autokeras 1.0.20 Numpy 1.26.3
Can I work on this issue? @haifeng-jin
Its numpy latest version problem. Use pip install numpy==1.23.4
@SarthakNikhal Sorry for the late reply. Anyone interested can work on this.
Also, if someone is having <module 'numpy' has no attribute 'unicode'> you can simply replace np.unicode into np.str_ in input_adapters.py