Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'numpy' has no attribute 'object' when using autokeras with structured data #1898

Open
GhulamMustafa0324 opened this issue Dec 4, 2023 · 5 comments

Comments

@GhulamMustafa0324
Copy link

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)
@hanzigs
Copy link

hanzigs commented Jan 4, 2024

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

@SarthakNikhal
Copy link

SarthakNikhal commented Jan 19, 2024

Can I work on this issue? @haifeng-jin

@Gafar1994
Copy link

Its numpy latest version problem. Use pip install numpy==1.23.4

@haifeng-jin
Copy link
Collaborator

@SarthakNikhal Sorry for the late reply. Anyone interested can work on this.

@wstlxx
Copy link

wstlxx commented May 27, 2024

Also, if someone is having <module 'numpy' has no attribute 'unicode'>
you can simply replace np.unicode into np.str_ in input_adapters.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants