0
$\begingroup$

I'm trying to make news classification. Here is the neural network:

y = dataset.iloc[:, vocabularySize]
matrix = CountVectorizer(max_features=vocabularySize)
X = matrix.fit_transform(data).toarray()
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33)  

classifier = GaussianNB()

classifier.fit(X_train, y_train)
y_pred = classifier.predict(X_test)

accuracy = accuracy_score(y_test, y_pred)
print(f'accuracy: {accuracy}')

y is the column of news categories. And x is the vectors of my news contents. Code is working fine and it makes prediction on the test group. But I want to predict the category of the specific news with this trained neural network.

There is my test group: 301321110301321033123232123223313131232033031000303020 

There is predictions of them: [2 0 1 2 2 1 1 1 1 3 0 0 1 2 0 1 3 1 1 2 3 2 3 2 1 2 3 2 2 0 1 1 3 1 3 1 2 1 2 0 3 2 1 3 0 0 0 0 1 0 3 0 3 0]

But I want to give a random news as input and want it's predicted category. But it works on big data which can separate to train and test groups. How can I predict a single news category? It takes my all news data set and separate them train and test but I want to do fit this neural network with train group but give a any news as test.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.