Autokeras - Get classes name

193 views Asked by At

I am trying to get the classes names I used for Autokeras. Both sentences and labels are strings.

import pandas as pd
import autokeras as ak


df = pd.read_csv("train.csv", names=['text', 'category'])
sentences = df.text.values
labels = df.category.values
x_train, x_test, y_train, y_test = train_test_split(sentences, labels, test_size=0.10, random_state=2021)

clf = ak.TextClassifier(overwrite=True, max_trials=2)  
clf.fit(x_train, y_train, epochs=400)
predicted_y = clf.predict(x_test)
clf.evaluate(x_test, y_test)

Now when I try importing to keras and running the prediction on a sample I'm only getting an index number.

model = clf.export_model()
probas = model.predict(["Hello world"])
predicted_class = probas.argmax(axis=-1)

predicted_class returns:

[20]

This assumes I have a list of the classes that were used with their order or a dict.

How can I know which string was assigned the index 20?

0

There are 0 answers