Classifier for the question classification dataset (UIUC's CogComp QC Dataset).
- Results from the empirical tests carried out, are in results file.
All the results are for
coarse:fine
, combined prediction class out of the total 50 classes. - More details about the execution/logic is available in execution details.
- Diagrammatic representation of the data flow can be accessed here.
- The data-flow is different for Neural Network, its only a single
coarse
model predicting for all 50 different classes.
- python - v3.6.3
- configobj - v5.0.6
- numpy - v1.15.0
- spaCy - v2.0.11 (with "en_core_web_lg" english model)
- scipy - v1.0.0
- scikit-learn - v0.19.1
- torch (PyTorch) - v0.4.0
bin
executable files are helpful only for Linux or macOS users. Microsoft users please execute the python modules by matching your requirement from the shell scripts.
Check your systems' text encoding scheme. It is set to text_file_encoding = "utf8"
, can be changed in qc.utils.file_ops.py
.
- Go to the project directory.
- We need to execute the command
./bin/qc.sh nlp
first. - Once the Natural Language Processing (NLP) is done for computing annotated natural language property we can train one of the models.
- To train a model execute command
./bin/qc.sh train {ml_algo_model}
. e.g./bin/qc.sh train svm
- To test a model execute command
./bin/qc.sh test {ml_algo_model}
.
- All the trained models are saved inside a folder named -
${ml_algo_model}
, inside the project's root directory.
svm
= Support Vector Machinelr
= Logistic Regressionlinear_svm
= Linear Support Vector Classifier (Machine)nn
= Neural Network
./bin/cleanup.sh nlp
- This will delete all the NLP related data../bin/cleanup.sh all_models
- This will delete all the pre-trained models../bin/cleanup.sh model ${ml_algo_model}
- This will delete the specific ML model which was pre-trained../bin/cleanup.sh all
- This will delete all the computed data.
all_models
will not clean the additional model defined by you. It will only clean the models mentioned above.
-
The method to convert text data to ML features can be modified in function
qc.dataprep.text_features.get_vect
. code location -
The feature stack (what all data is to be feed to ML algorithm) can be modified/transformed/generated in file
qc.dataprep.feature_stack
. code locationThese (point 1, 2) changes are used whenever you execute training process again. There is no need to execute
nlp
step again. -
Machine learning algorithms can be added in function
qc.ml.train.train_one_node
. code location (Parameter tuning too can be done). e.g In the experimental part of the code add extraelif
statementelif == {your_model_name}: machine = {Initialize the algorithm you want to use}
elif ml_algo == "lr_lsvm": if cat_type == "coarse": machine = linear_model.LogisticRegression(solver="newton-cg") else: machine = svm.LinearSVC()
While executing, use the shell command
./bin/qc.sh train lr_lsvm
, and this command will use the model defined by you.lr_lsvm
is{your_model_name}
. In the example we have defined to use LogisticRegression for coarse class prediction and LinearSVC for fine class predictions (all of the fine class predictions).
This project has been inspired from one of the problem we tried to solve - understanding the question for our QA bot.
In a project named Invoker
, I did work with Akash Pateria, we worked together
in the undergraduate capstone project. We did use python - v2.7, practNLPtools,
and LinearSVC, as the ML algorithm, for our tasks in the project Invoker
.
This project aims at exploring more options to process Natural Language (English), test with various combinations of features and improve the accuracy.
High-Performance Question Classification Using Semantic Features