Model unable to classify intents

rasa-nlu

(Rameshjesswani) #1

I am using python code for training and prediction, but model does not classifies intents. I have created my training dataset from Chatito. This is my code for training the model:

class trainModel:

    def __init__(self, train_data_path, config_path):
        
        self.train_data_path = train_data_path
        self.config_path = config_path
        self.model_directory = None
        
    def startTraining(self):
        
        print ("training")
        training_data = load_data(self.train_data_path)
        trainer = Trainer(config.load(self.config_path))
        trainer.train(training_data)       
        self.model_directory = trainer.persist('./projects/default/')
     

    training_data = "./trainingData.json"
    conf_path = "./spacy_config.json"
    train = trainModel(training_data, conf_path)
# #start training
`train.startTraining()`

This is my spacy_config.json

{
  "language": "en",
  "pipeline": "spacy_sklearn"
    }

For prediction, I do:

interpret = Interpreter.load(train.model_directory)
msg = "please search details of Car [class]"
res = interpret.parse(msg)
print(json.dumps(res, indent=2))

Output:

{
  "intent": null,
  "entities": [
    {
      "start": 25,
      "end": 28,
      "value": "car",
      "entity": "class",
      "confidence": 0.9787197096050472,
      "extractor": "ner_crf"
    }
  ],
  "intent_ranking": [],
  "text": "please search details of HPC [class]"
}

Model is able to extract the entities, but in case of intents it outputs: “null” . could anyone please help with this?


(Rameshjesswani) #2

Problem solved. Thanks, I was using only one intent in my data-set and in python I was not getting error about that. So when I tried on terminal, then I came to know this problem.