Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. CSVFile f_feats_train("@SHOGUN_DATA@/classifier_4class_2d_linear_features_train.dat")
  2. CSVFile f_feats_test("@SHOGUN_DATA@/classifier_4class_2d_linear_features_test.dat")
  3. CSVFile f_labels_train("@SHOGUN_DATA@/classifier_4class_2d_linear_labels_train.dat")
  4. CSVFile f_labels_test("@SHOGUN_DATA@/classifier_4class_2d_linear_labels_test.dat")
  5.  
  6. #![create_features]
  7. Features features_train = features(f_feats_train)
  8. Features features_test = features(f_feats_test)
  9. Labels labels_train = labels(f_labels_train)
  10. Labels labels_test = labels(f_labels_test)
  11. #![create_features]
  12.  
  13. #![create_kernel]
  14. Kernel kernel_gaussian = kernel("GaussianKernel")
  15. kernel_gaussian.put("log_width", 2.1)
  16. #![create_kernel]
  17.  
  18. #![choose_strategy]
  19. MulticlassStrategy one_vs_rest=multiclass_strategy("MulticlassOneVsRestStrategy")
  20. #![choose_strategy]
  21.  
  22. #![create_classifier]
  23. Machine classifier = machine("LibSVM")
  24. classifier.put("epsilon",1e-5)
  25. #![create_classifier]
  26.  
  27. #![create_machine]
  28. Machine mc_class = machine("KernelMulticlassMachine",one_vs_rest,kernel_gaussian,classifier,labels_train)
  29. #![create_machine]
  30.  
  31. #![train_and_apply]
  32. mc_class.train(features_train)
  33. Labels labels_predict = mc_class.apply_multiclass(features_test)
  34. #![train_and_apply]
  35.  
  36. # integration testing variables
  37. RealVector output = labels_predict.get_labels()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement