Пример #1
0
def test_classifier_server_get():
    x_hotel = ['book a hotel', 'need a nice place to stay', 'any motels near by']
    x_weather = ['what is the weather like', 'is it hot outside']
    x_place = ['which place is this', 'where are we', 'where are you going', 'which place is it']
    x_name = ['What is your name', 'Who are you', 'What do i call you', 'what are you called']
    clf = Classifier()
    clf.fit(x_hotel, 'hotel')
    clf.fit(x_weather, 'weather')
    clf.fit(x_place, 'place')
    clf.fit(x_name, 'name')
    clf_serialized = clf.serialize()
    server = NLUServer(clf).serve(test=True)
    r = server.requests.get("/models/classifier/predict?input=will it rain today")
    assert r.text == 'weather'
    r = server.requests.get("/models/classifier/config")
    assert r.json() == clf_serialized
Пример #2
0
    def test_classifier_serialization(self):
        x_hotel = ['book a hotel', 'need a nice place to stay', 'any motels near by']
        x_weather = ['what is the weather like', 'is it hot outside']

        clf1 = Classifier()
        clf1.fit(x_hotel, 'hotel')
        clf1.fit(x_weather, 'weather')

        config = clf1.serialize()
        clf2 = Classifier.deserialize(config)

        assert clf1.classes == clf2.classes

        test_inputs = ['will it rain today', 'find a place to stay']

        for test_input in test_inputs:
            clf1_out = clf1.predict(test_input, return_probs=True)
            clf2_out = clf2.predict(test_input, return_probs=True)
            assert clf1_out == clf2_out
Пример #3
0
def test_classifier_serialization():
    x_hotel = ['book a hotel', 'need a nice place to stay', 'any motels near by']
    x_weather = ['what is the weather like', 'is it hot outside']

    clf1 = Classifier()
    clf1.fit(x_hotel, 'hotel')
    clf1.fit(x_weather, 'weather')

    config = clf1.serialize()
    clf2 = Classifier.deserialize(config)

    assert clf1.classes == clf2.classes

    test_inputs = ['will it rain today', 'find a place to stay']

    for test_input in test_inputs:
        clf1_out = clf1.predict(test_input, return_probs=True)
        clf2_out = clf2.predict(test_input, return_probs=True)
        assert clf1_out == clf2_out