I want to load the NSL_KDD data set in python using this link:
https://github.com/smellslikeml/deepIDS/blob/master/deep_IDS.ipynb
But when I run this command, attack_map = {k:v for (k,v) in attack_map} I get this error:
ValueError: not enough values to unpack (expected 2, got 0)
hence I’m a newbie to Python, I don’t know how to fix this error. could you anyone help me?
with open(‘G:/RUN_PYTHON/kddcup.names.txt’, ‘r’) as infile:
kdd_names = infile.readlines() kdd_cols = [x.split(’:’)[0] for x in kdd_names[1:]]
kdd_cols += [‘class’, ‘difficulty’]
kdd = pd.read_csv(‘G:/RUN_PYTHON/KDDTrain+.txt’, names=kdd_cols)
kdd_t = pd.read_csv(‘G:/RUN_PYTHON/KDDTest+.txt’, names=kdd_cols)
kdd_cols = [kdd.columns[0]] + sorted(list(set(kdd.protocol_type.values))) + sorted(list(set(kdd.service.values))) + sorted(list(set(kdd.flag.values))) + kdd.columns[4:].tolist()
attack_map = [x.strip().split() for x in open(‘G:/RUN_PYTHON/training_attack_types.txt’, ‘r’)]
attack_map = {k:v for (k,v) in attack_map}
I know attack_map has empty elements.
when I printed the attack_map, print(attack_map),
out: [[‘back’, ‘dos’], [‘buffer_overflow’, ‘u2r’], [‘ftp_write’, ‘r2l’], [‘guess_passwd’, ‘r2l’], [‘imap’, ‘r2l’], [‘ipsweep’, ‘probe’], [‘land’, ‘dos’], [‘loadmodule’, ‘u2r’], [‘multihop’, ‘r2l’], [‘neptune’, ‘dos’], [‘nmap’, ‘probe’], [‘perl’, ‘u2r’], [‘phf’, ‘r2l’], [‘pod’, ‘dos’], [‘portsweep’, ‘probe’], [‘rootkit’, ‘u2r’], [‘satan’, ‘probe’], [‘smurf’, ‘dos’], [‘spy’, ‘r2l’], [‘teardrop’, ‘dos’], [‘warezclient’, ‘r2l’], [‘warezmaster’, ‘r2l’], []]
it has a [] element but I don’t how to can solved this problem.
best regards