Skip to content

Instantly share code, notes, and snippets.

@OXPHOS
Created May 27, 2016 14:38
Show Gist options
  • Save OXPHOS/4d58f4371e4e49ae8fbef16d176d8149 to your computer and use it in GitHub Desktop.
Save OXPHOS/4d58f4371e4e49ae8fbef16d176d8149 to your computer and use it in GitHub Desktop.
with '0' error when making cookbook
CSVFile f_feats_train("../../data/classifier_4class_2d_linear_features_train.dat")
CSVFile f_feats_test("../../data/classifier_4class_2d_linear_features_test.dat")
CSVFile f_labels_train("../../data/classifier_4class_2d_linear_labels_train.dat")
CSVFile f_labels_test("../../data/classifier_4class_2d_linear_labels_test.dat")
#![create_features]
RealFeatures features_train(f_feats_train)
RealFeatures features_test(f_feats_test)
MulticlassLabels labels_train(f_labels_train)
MulticlassLabels labels_test(f_labels_test)
#![create_features]
#![create_instance]
QDA qda(features_train, labels_train)
#![create_instance]
#![train_and_apply]
qda.train()
MulticlassLabels labels_predict = qda.apply_multiclass(features_test)
#![train_and_apply]
#![extract_mean_and_cov]
int classlabel = 0
RealVector m = qda.get_mean(classlabel)
#![train_and_apply]
#![evaluate_accuracy]
MulticlassAccuracy eval()
real accuracy = eval.evaluate(labels_predict, labels_test)
#![evaluate_accuracy]
# additional integration testing variables
RealVector output = labels_predict.get_labels()
@OXPHOS
Copy link
Author

OXPHOS commented May 27, 2016

$make cookbook

Generating examples from meta-language
Traceback (most recent call last):
  File "/Users/zora/Github/shogun/examples/meta/generator/generate.py", line 116, in <module>
    includedTargets=args.targets, storeVars=storeVars)
  File "/Users/zora/Github/shogun/examples/meta/generator/generate.py", line 48, in translateExamples
    ast = parse(file.read(), os.path.join(dirRelative, filename))
  File "/Users/zora/Github/shogun/examples/meta/generator/parse.py", line 234, in parse
    return parser.parse(programString, filePath)
  File "/Users/zora/Github/shogun/examples/meta/generator/parse.py", line 32, in parse
    program = self.parser.parse(programString)
  File "/usr/local/lib/python2.7/site-packages/ply-3.8-py2.7.egg/ply/yacc.py", line 331, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/usr/local/lib/python2.7/site-packages/ply-3.8-py2.7.egg/ply/yacc.py", line 1049, in parseopt_notrack
    lookahead = get_token()     # Get the next token
  File "/usr/local/lib/python2.7/site-packages/ply-3.8-py2.7.egg/ply/lex.py", line 386, in token
    newtok = self.lexerrorf(tok)
  File "/Users/zora/Github/shogun/examples/meta/generator/parse.py", line 100, in t_error
    raise TypeError("Failed to tokenize input. Unknown text on line %d '%s'" % (t.lineno, t.value,))
TypeError: Failed to tokenize input. Unknown text on line 16 '0
RealVector m = qda.get_mean(classlabel)
#![train_and_apply]

#![evaluate_accuracy]
MulticlassAccuracy eval()
real accuracy = eval.evaluate(labels_predict, labels_test)
#![evaluate_accuracy]

# additional integration testing variables
RealVector output = labels_predict.get_labels()
'
make[3]: *** [examples/meta/CMakeFiles/meta_examples] Error 1
make[2]: *** [examples/meta/CMakeFiles/meta_examples.dir/all] Error 2
make[1]: *** [doc/cookbook/CMakeFiles/cookbook.dir/rule] Error 2
make: *** [cookbook] Error 2

@karlnapf
Copy link

karlnapf commented May 28, 2016

I dont get this in latest develop
EDIT: I do get the error .... on it

@karlnapf
Copy link

See email I wrote to @sorig

@karlnapf
Copy link

One potential fix would be to change t_NUMERAL = "([1-9][0-9]*(\.[0-9]+)?)|0\.[0-9]+" in generator/parse.py to t_NUMERAL = "([0-9][0-9]*(\.[0-9]+)?)|0\.[0-9]+"

@karlnapf
Copy link

For now, we can just use class index 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment