# Attribute Error: 'numpy.ndarray' object has no attribute 'transform' [closed]

#Text Representation
from sklearn.feature_extraction.text import TfidfVectorizer
tfidf = TfidfVectorizer(sublinear_tf=True, min_df=2,max_df= 0.3, norm='l2', encoding='latin-1', ngram_range=(1, 2), stop_words='english')
features = tfidf.fit_transform(df.ContextualText).toarray()
labels = df.category_id
features.shape

#Running Linear SVC
from sklearn.model_selection import train_test_split

model = LinearSVC()

X_train, X_test, y_train, y_test, indices_train, indices_test = train_test_split(features, labels, df.index, test_size=0.2, random_state=0)
model.fit(X_train, y_train)
y_pred = model.predict(X_test)

#Predictions based on model
vectorized_text = features.transform("Heathcare is good").toarray()

• Hi @Manan Nawal, thank you for the post. However, we are struggling to understand what it is you are exactly asking and the context behind the issue you are experiencing. Could you edit your post accordingly so then we can help you? – shepan6 Jul 7 '20 at 9:11
• Hi, and welcome to the stackexchange network. To learn more on how to ask a good question, which is likely to be answered, please visit the site tour (datascience.stackexchange.com/tour), especially the "how to ask" part (datascience.stackexchange.com/help/how-to-ask). – Itamar Mushkin Jul 7 '20 at 10:34

Your question leaves a lot unexplained, but the error you're receiving probably came from the last line vectorized_text = features.transform("Heathcare is good").toarray().
The variable features is itself an array (it came from features = ... .toarray()).
vectorized_text = tfidf.transform("Heathcare is good").toarray()?