This is one of a series of posts on how to use nkululeko and deals with setting up the "hello world" of nkululeko: performing classification on the berlin emodb emotional datbase.
Typically nkululeko experiments are defined by two files:
- a python file that is called by the interpreter
- an initialization file that is interpreted by the nkululeko framework
First we'll take a look at the python file:
# my_experiment.py
# Demonstration code to use the Nkululeko framework
import sys
sys.path.append("TO BE ADAPTED/nkululeko/src")
import configparser # to read the ini file
import experiment as exp # central nkululeko class
from util import Util # mainly for logging
def main(config_file):
# load one configuration per experiment
config = configparser.ConfigParser()
config.read(config_file) # read in the ini file, the experiment is defined there
util = Util() # init the logging and global stuff
# create a new experiment
expr = exp.Experiment(config)
util.debug(f'running {expr.name}')
# load the data sets (specified in ini file)
expr.load_datasets()
# split into train and test sets
expr.fill_train_and_tests()
util.debug(f'train shape : {expr.df_train.shape}, test shape:{expr.df_test.shape}')
# extract features
expr.extract_feats()
util.debug(f'train feats shape : {expr.feats_train.df.shape}, test feats shape:{expr.feats_test.df.shape}')
# initialize a run manager and run the experiment
expr.init_runmanager()
expr.run()
print('DONE')
if __name__ == "__main__":
main('PATH TO INI FILE/exp_emodb.ini')
# main(sys.argv[1]) # alternatively read it from command line
and this would be a minimal nkululeko configuration file (tested with version 0.8)
[EXP]
root = ./emodb/
name = exp_emodb
[DATA]
databases = ['emodb']
emodb = TO BE ADAPTED/emodb
emodb.split_strategy = speaker_split
emodb.testsplit = 40
target = emotion
labels = ['anger', 'boredom', 'disgust', 'fear', 'happiness', 'neutral', 'sadness']
[FEATS]
type = os
[MODEL]
type = svm
I hope the names of the entries are self-explanatory, here's the link to the config file description
One thought on “Setting up a base nkululeko experiment”