Ошибка значения: неправильная форма ввода (1, 4)

#python #scikit-learn #rasa-nlu

Вопрос:

Я следую учебнику, и я получаю ValueError: bad input shape (1, 4) . В своем коде я использую Rasa, но поскольку мой конвейер rasa требует как Spacy, так и Scikit-learn, я их тоже установил. Вот мой код:

 from rasa_nlu.converters import load_data
from rasa_nlu.config import RasaNLUConfig
from rasa_nlu.model import Trainer

args = {
    "pipeline": "spacy_sklearn"
}

config = RasaNLUConfig(cmdline_args = args)
trainer = Trainer(config)
training_data = load_data("./training_data.json")
interpreter = trainer.train(training_data)

print(interpreter.parse("I'm looking for a Mexican restaurant in the North of town"))
 

Мой training_data.json :

 {
    "rasa_nlu_data": {
      "common_examples": [
        {
          "text": "hey", 
          "intent": "greet", 
          "entities": []
        }, 
        {
          "text": "howdy", 
          "intent": "greet", 
          "entities": []
        }, 
        {
          "text": "hey there",
          "intent": "greet", 
          "entities": []
        }, 
        {
          "text": "hello", 
          "intent": "greet", 
          "entities": []
        }, 
        {
          "text": "hi", 
          "intent": "greet", 
          "entities": []
        },
        {
          "text": "good morning",
          "intent": "greet",
          "entities": []
        },
        {
          "text": "good evening",
          "intent": "greet",
          "entities": []
        },
        {
          "text": "dear sir",
          "intent": "greet",
          "entities": []
        },
        {
          "text": "yes", 
          "intent": "affirm", 
          "entities": []
        }, 
        {
          "text": "yep", 
          "intent": "affirm", 
          "entities": []
        }, 
        {
          "text": "yeah", 
          "intent": "affirm", 
          "entities": []
        },
        {
          "text": "indeed",
          "intent": "affirm",
          "entities": []
        },
        {
          "text": "that's right",
          "intent": "affirm",
          "entities": []
        },
        {
          "text": "ok",
          "intent": "affirm",
          "entities": []
        },
        {
          "text": "great",
          "intent": "affirm",
          "entities": []
        },
        {
          "text": "right, thank you",
          "intent": "affirm",
          "entities": []
        },
        {
          "text": "correct",
          "intent": "affirm",
          "entities": []
        },
        {
          "text": "great choice",
          "intent": "affirm",
          "entities": []
        },
        {
          "text": "sounds really good",
          "intent": "affirm",
          "entities": []
        },
        {
          "text": "i'm looking for a place to eat",
          "intent": "restaurant_search",
          "entities": []
        },
        {
          "text": "I want to grab lunch",
          "intent": "restaurant_search",
          "entities": []
        },
        {
          "text": "I am searching for a dinner spot",
          "intent": "restaurant_search",
          "entities": []
        },
        {
          "text": "i'm looking for a place in the north of town",
          "intent": "restaurant_search",
          "entities": [
            {
              "start": 31,
              "end": 36,
              "value": "north",
              "entity": "location"
            }
          ]
        },
        {
          "text": "show me chinese restaurants",
          "intent": "restaurant_search",
          "entities": [
            {
              "start": 8,
              "end": 15,
              "value": "chinese",
              "entity": "cuisine"
            }
          ]
        },
        {
          "text": "show me chines restaurants",
          "intent": "restaurant_search",
          "entities": [
            {
              "start": 8,
              "end": 14,
              "value": "chinese",
              "entity": "cuisine"
            }
          ]
        },
        {
          "text": "show me a mexican place in the centre", 
          "intent": "restaurant_search", 
          "entities": [
            {
              "start": 31, 
              "end": 37, 
              "value": "centre", 
              "entity": "location"
            }, 
            {
              "start": 10, 
              "end": 17, 
              "value": "mexican", 
              "entity": "cuisine"
            }
          ]
        },
        {
          "text": "i am looking for an indian spot called olaolaolaolaolaola",
          "intent": "restaurant_search",
          "entities": [
            {
              "start": 20,
              "end": 26,
              "value": "indian",
              "entity": "cuisine"
            }
          ]
        },     {
          "text": "search for restaurants",
          "intent": "restaurant_search",
          "entities": []
        },
        {
          "text": "anywhere in the west",
          "intent": "restaurant_search",
          "entities": [
            {
              "start": 16,
              "end": 20,
              "value": "west",
              "entity": "location"
            }
          ]
        },
        {
          "text": "I am looking for asian fusion food",
          "intent": "restaurant_search",
          "entities": [
            {
              "start": 17,
              "end": 29,
              "value": "asian fusion",
              "entity": "cuisine"
            }
          ]
        },
        {
          "text": "I am looking for mexican indian fusion",
          "intent": "restaurant_search",
          "entities": [
            {
              "start": 17,
              "end": 38,
              "value": "mexican indian fusion",
              "entity": "cuisine"
            }
          ]
        },
        {
          "text": "central indian restaurant",
          "intent": "restaurant_search",
          "entities": [
            {
              "start": 0,
              "end": 7,
              "value": "central",
              "entity": "location"
            },
            {
              "start": 8,
              "end": 14,
              "value": "indian",
              "entity": "cuisine"
            }
          ]
        },
        {
          "text": "bye", 
          "intent": "goodbye", 
          "entities": []
        }, 
        {
          "text": "goodbye", 
          "intent": "goodbye", 
          "entities": []
        }, 
        {
          "text": "good bye", 
          "intent": "goodbye", 
          "entities": []
        }, 
        {
          "text": "stop", 
          "intent": "goodbye", 
          "entities": []
        }, 
        {
          "text": "end", 
          "intent": "goodbye", 
          "entities": []
        },
        {
          "text": "farewell",
          "intent": "goodbye",
          "entities": []
        },
        {
          "text": "Bye bye",
          "intent": "goodbye",
          "entities": []
        },
        {
          "text": "have a good one",
          "intent": "goodbye",
          "entities": []
        }
      ]
    }
  }
 

Я запускаю это в лаборатории Google. Вывод, который я получаю, когда запускаю приведенный выше код, выглядит так:

 Fitting 2 folds for each of 6 candidates, totalling 12 fits

[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.
[Parallel(n_jobs=1)]: Done  12 out of  12 | elapsed:    0.0s finished

---------------------------------------------------------------------------

ValueError                                Traceback (most recent call last)

<ipython-input-5-f801178ceccf> in <module>()
     12 interpreter = trainer.train(training_data)
     13 
---> 14 print(interpreter.parse("I'm looking for a Mexican restaurant in the North of town"))

4 frames

/usr/local/lib/python3.7/dist-packages/sklearn/utils/validation.py in column_or_1d(y, warn)
    795         return np.ravel(y)
    796 
--> 797     raise ValueError("bad input shape {0}".format(shape))
    798 
    799 

ValueError: bad input shape (1, 4)
 

How do I fix this?