Dialog State Agent created for the course 1-GS Methods in AI research (INFOMAIR) 2020-2021 at Utrecht University. Current functionality is train and test classifier, classify user utterance.
Run Dialogue_Agent.py for the text based chatbot for restaurant domain. classification.py contains functions to train and test classifiers.
Pandas
python-Levenshtein
NLTK
re
random
Numpy
SkLearn
Implementation of 2 baselines:
- classify every utterance as majority class
- classify every utterance based on self-defined rules Score for both baselines is based on accuracy. To get the error, output 1-accuracy
Example code:
from baseline import Baseline
b = Baseline()
b.open_dataset("dialog_acts.dat")
b.split_dataset()
b.get_highest_label()
b.test_highest_label()
print(b.score())To test the keyword rules, simply run the function:
b.test_keyword_rule()
print(b.score())To classify user utterance, simply run the following command:
b.user_input()Class to split data and train and test classifier. Usage:
- create instance of class Classification()
clf=Classification()- initialize data using initialize_data(filename)
clf.initialize_data("dialog_acts.dat")- train and test classifier using one of the classifiers (LR or NN)
clf.train_lr()#or
clf.train_nn()- Testing and getting performance measures:
Test and make confusion matrix
clf.test_clf()Cross Validation. For this function, create a classifier and call the cv function. Second parameter for cv function is a boolean indicating whether or not to oversample.
lr=LogisticRegression(random_state=0, max_iter=200, penalty='l2')
clf.cv(lr,False) Predict a single sentence
sentence="Hi, I would like to get a suggestion"
clf.predict(sentence):