Home > front end >  How to classify a data set in a neural network that is working
How to classify a data set in a neural network that is working

Time:11-07

I made a neural network that shows me the probability that a comment is positive, calculated from 0 to 1.

In fact, I can now enter new data and it offers me results in this line

Dcnn(np.array([tokenizer.encode("I feel very happy with the product")]), training = False).numpy()

Then the result shows me something like this

array([[0.9083]] , dtype = float32)

as you can see i introduced a text , now i would like to make a loop to give it n texts. I would be happy if someone can help me

i am expecting to get the result of the comment for each comment something like this

Text 1: "......." ; prob: 0.0002

Text 2: "......." ; prob: 0.7840

CodePudding user response:

This should be as simple as this:

for index, comment in enumerate(comments, 1):
    pred_proba = Dcnn(np.array([tokenizer.encode(comment)]), training = False).numpy()[0][0]
    print(f"Text {index}: '{comment}'; Probability: {pred_proba}")

Hope this helps!

  • Related