2015-11-03 104 views
0

我建立使用RSofia包河下一個SVM模型,我試了樣本數據的代碼:SVM使用RSofia崩潰[R

library(RSofia) 

x1 <- as.factor(sample(c("a","b","c"),1000,replace = TRUE)) 
x2 <- as.factor(sample(c("e","f","g"),1000,replace = TRUE)) 
y <- as.factor(sample(c(0,1),1000,replace = TRUE)) 
train <- data.frame(x1=x1,x2=x2,y=y) 

lambda <- 0.01 
iterations <- 1e+07 
learner_type <- 'pegasos' 
eta_type <- 'pegasos' 
loop_type <- 'rank' 
rank_step_probability <- 0.5 

sofiaModel <- sofia(y ~ ., 
        data=train, 
        random_seed =9, 
        lambda = lambda, 
        iterations = iterations, 
        learner_type = learner_type, 
        eta_type = eta_type, 
        loop_type = loop_type, 
        rank_step_probability = rank_step_probability) 

此代碼崩潰[R我的Windows機器上,使用下列消息:

R for Windows GUI front-end has stopped working 

我試圖在Linux計算機上相同的代碼,並得到了以下錯誤:

*** caught segfault *** 
address 0x1, cause 'memory not mapped' 

Traceback: 
1: .External(list(name = "CppMethod__invoke_notvoid", address = <pointer: 0xe06ee00>,  dll = list(name = "Rcpp", path = "/opt/vertica/R/library/Rcpp/libs/Rcpp.so",   dynamicLookup = TRUE, handle = <pointer: 0xccad950>,   info = <pointer: 0x2ba407d43a80>), numParameters = -1L),  <pointer: 0xc916ac0>, <pointer: 0xdc1b840>, .pointer, ...) 
2: sofia_facade$train_fit(x, y, random_seed, lambda, iterations,  learner_type, eta_type, loop_type, rank_step_probability,  passive_aggressive_c, passive_aggressive_lambda, perceptron_margin_size,  training_objective, dimensionality, hash_mask_bits, no_bias_term,  verbose, reserve) 
3: sofia.fit(parsed$data, parsed$labels, random_seed, lambda, iterations,  learner_type, eta_type, loop_type, rank_step_probability,  passive_aggressive_c, passive_aggressive_lambda, perceptron_margin_size,  training_objective, parsed$no_bias_term, dimensionality,  hash_mask_bits, verbose, reserve) 
4: sofia.formula(y ~ ., data = train, random_seed = 9, lambda = lambda,  iterations = iterations, learner_type = learner_type, eta_type = eta_type,  loop_type = loop_type, rank_step_probability = rank_step_probability) 
5: sofia(y ~ ., data = train, random_seed = 9, lambda = lambda,  iterations = iterations, learner_type = learner_type, eta_type = eta_type,  loop_type = loop_type, rank_step_probability = rank_step_probability) 

Possible actions: 
1: abort (with core dump, if enabled) 
2: normal R exit 
3: exit R without saving workspace 
4: exit R saving workspace 

I N用更大的數據和只有兩個/三個變量引起相同的行爲。

有人能指出一個解決這個問題?

回答

2

我可以重現在OS X上這裏的回溯(與R -d lldb運行後):

(lldb) bt 
* thread #1: tid = 0x10690f, 0x0000000109099fd1 RSofia.so`SfSparseVector::Init(char const*) + 113, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x1) 
    * frame #0: 0x0000000109099fd1 RSofia.so`SfSparseVector::Init(char const*) + 113 
    frame #1: 0x000000010909a391 RSofia.so`SfSparseVector::SfSparseVector(char const*, bool) + 257 
    frame #2: 0x0000000109097842 RSofia.so`SfDataSet::AddVector(char const*) + 34 
    frame #3: 0x00000001090884e5 RSofia.so`RSofiaFacade::train_fit(Rcpp::Matrix<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<14, Rcpp::PreserveStorage> const&, long, float, long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, float, float, float, float, bool, int, int, bool, bool, int) + 789 
    frame #4: 0x00000001090950ca RSofia.so`Rcpp::CppMethod18<RSofiaFacade, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, SEXPREC*, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, SEXPREC*> > >, Rcpp::Matrix<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<14, Rcpp::PreserveStorage> const&, long, float, long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, float, float, float, float, bool, int, int, bool, bool, int>::operator()(RSofiaFacade*, SEXPREC**) + 762 
    frame #5: 0x000000010908cf9f RSofia.so`Rcpp::class_<RSofiaFacade>::invoke_notvoid(SEXPREC*, SEXPREC*, SEXPREC**, int) + 447 
    frame #6: 0x0000000109009e55 Rcpp.so`CppMethod__invoke_notvoid(SEXPREC*) + 261 
    frame #7: 0x0000000100079256 libR.dylib`do_External(call=0x00000001080a2b40, op=<unavailable>, args=<unavailable>, env=<unavailable>) + 342 at dotcode.c:548 
    frame #8: 0x00000001000b044a libR.dylib`Rf_eval(e=<unavailable>, rho=0x00000001024cee78) + 1274 at eval.c:655 
    frame #9: 0x00000001000e251f libR.dylib`do_begin(call=0x00000001080a1c08, op=0x0000000101832778, args=<unavailable>, rho=0x00000001024cee78) + 447 at eval.c:1717 
    frame #10: 0x00000001000b05c8 libR.dylib`Rf_eval(e=<unavailable>, rho=0x00000001024cee78) + 1656 at eval.c:627 
    frame #11: 0x00000001000df627 libR.dylib`Rf_applyClosure(call=0x00000001021b5e60, op=0x00000001024a68a8, arglist=0x00000001024cebb8, rho=0x0000000102219918, suppliedvars=<unavailable>) + 1415 at eval.c:1045 
    frame #12: 0x00000001000b04c8 libR.dylib`Rf_eval(e=0x00000001021b5e60, rho=0x0000000102219918) + 1400 at eval.c:674 
    frame #13: 0x00000001000e3068 libR.dylib`do_set(call=<unavailable>, op=0x000000010182f9c8, args=<unavailable>, rho=0x0000000102219918) + 1832 at eval.c:2107 
    frame #14: 0x00000001000b05c8 libR.dylib`Rf_eval(e=<unavailable>, rho=0x0000000102219918) + 1656 at eval.c:627 
    frame #15: 0x00000001000e251f libR.dylib`do_begin(call=0x00000001021b5200, op=0x0000000101832778, args=<unavailable>, rho=0x0000000102219918) + 447 at eval.c:1717 
    frame #16: 0x00000001000b05c8 libR.dylib`Rf_eval(e=<unavailable>, rho=0x0000000102219918) + 1656 at eval.c:627 
    frame #17: 0x00000001000df627 libR.dylib`Rf_applyClosure(call=0x00000001071cafb8, op=0x00000001021b4c30, arglist=0x0000000102218d78, rho=0x00000001071ceb58, suppliedvars=<unavailable>) + 1415 at eval.c:1045 
    frame #18: 0x00000001000b04c8 libR.dylib`Rf_eval(e=0x00000001071cafb8, rho=0x00000001071ceb58) + 1400 at eval.c:674 
    frame #19: 0x00000001000e3068 libR.dylib`do_set(call=<unavailable>, op=0x000000010182f9c8, args=<unavailable>, rho=0x00000001071ceb58) + 1832 at eval.c:2107 
    frame #20: 0x00000001000b05c8 libR.dylib`Rf_eval(e=<unavailable>, rho=0x00000001071ceb58) + 1656 at eval.c:627 
    frame #21: 0x00000001000e251f libR.dylib`do_begin(call=0x00000001071d4140, op=0x0000000101832778, args=<unavailable>, rho=0x00000001071ceb58) + 447 at eval.c:1717 
    frame #22: 0x00000001000b05c8 libR.dylib`Rf_eval(e=<unavailable>, rho=0x00000001071ceb58) + 1656 at eval.c:627 
    frame #23: 0x00000001000df627 libR.dylib`Rf_applyClosure(call=0x00000001071d0c38, op=0x00000001071db878, arglist=0x00000001071cc7f0, rho=0x00000001071caa78, suppliedvars=<unavailable>) + 1415 at eval.c:1045 
    frame #24: 0x0000000100123d73 libR.dylib`dispatchMethod(op=0x00000001071ccfb8, sxp=0x00000001071db878, dotClass=0x00000001070b97e8, cptr=0x00007fff5fbfc000, method=0x00000001080244a0, generic=<unavailable>, rho=<unavailable>, callrho=<unavailable>, defrho=<unavailable>) + 723 at objects.c:335 
    frame #25: 0x000000010e8 libR.dylib`Rf_usemethod(generic="sofia", obj=<unavailable>, call=<unavailable>, args=<unavailable>, rho=0x00000001071caa78, callrho=0x000000010185e260, defrho=<unavailable>, ans=<unavailable>) + 840 at objects.c:375 
    frame #26: 0x0000000100123fa3 libR.dylib`do_usemethod(call=0x00000001071cc940, op=<unavailable>, args=<unavailable>, env=0x00000001071caa78) + 515 at objects.c:451 
    frame #27: 0x00000001000b05c8 libR.dylib`Rf_eval(e=<unavailable>, rho=0x00000001071caa78) + 1656 at eval.c:627 
    frame #28: 0x00000001000e251f libR.dylib`do_begin(call=0x00000001071cc5f8, op=0x0000000101832778, args=<unavailable>, rho=0x00000001071caa78) + 447 at eval.c:1717 
    frame #29: 0x00000001000b05c8 libR.dylib`Rf_eval(e=<unavailable>, rho=0x00000001071caa78) + 1656 at eval.c:627 
    frame #30: 0x00000001000df627 libR.dylib`Rf_applyClosure(call=0x00000001026fbe68, op=0x00000001071ccfb8, arglist=0x00000001071cc7f0, rho=0x000000010185e260, suppliedvars=<unavailable>) + 1415 at eval.c:1045 
    frame #31: 0x00000001000b04c8 libR.dylib`Rf_eval(e=0x00000001026fbe68, rho=0x000000010185e260) + 1400 at eval.c:674 
    frame #32: 0x00000001000e3068 libR.dylib`do_set(call=<unavailable>, op=0x000000010182f9c8, args=<unavailable>, rho=0x000000010185e260) + 1832 at eval.c:2107 
    frame #33: 0x00000001000b05c8 libR.dylib`Rf_eval(e=<unavailable>, rho=0x000000010185e260) + 1656 at eval.c:627 
    frame #34: 0x00000001000e421f libR.dylib`do_eval(call=<unavailable>, op=0x000000010184ab50, args=<unavailable>, rho=<unavailable>) + 2095 at eval.c:2478 
    frame #35: 0x00000001000bb4ee libR.dylib`bcEval(body=<unavailable>, rho=0x00000001071ccab0, useCache=<unavailable>) + 44286 at eval.c:5527 
    frame #36: 0x00000001000b010e libR.dylib`Rf_eval(e=0x000000010188f758, rho=0x00000001071ccab0) + 446 at eval.c:558 
    frame #37: 0x00000001000df627 libR.dylib`Rf_applyClosure(call=0x000000010087d838, op=0x000000010188fb48, arglist=0x00000001071cc400, rho=0x00000001026cb430, suppliedvars=<unavailable>) + 1415 at eval.c:1045 
    frame #38: 0x00000001000bab80 libR.dylib`bcEval(body=<unavailable>, rho=0x00000001026cb430, useCache=<unavailable>) + 41872 at eval.c:5499 
    frame #39: 0x00000001000b010e libR.dylib`Rf_eval(e=0x0000000100881f90, rho=0x00000001026cb430) + 446 at eval.c:558 
    frame #40: 0x00000001000deb6d libR.dylib`forcePromise(e=0x00000001071cd060) + 157 at eval.c:457 
    frame #41: 0x00000001000b01cc libR.dylib`Rf_eval(e=<unavailable>, rho=<unavailable>) + 636 at eval.c:581 
    frame #42: 0x00000001000e4571 libR.dylib`do_withVisible(call=<unavailable>, op=<unavailable>, args=0x00000001026fc240, rho=<unavailable>) + 49 at eval.c:2507 
    frame #43: 0x0000000100122128 libR.dylib`do_internal(call=0x0000000100000007, op=<unavailable>, args=<unavailable>, env=0x00000001071cca40) + 344 at names.c:1350 
    frame #44: 0x00000001000bb67d libR.dylib`bcEval(body=<unavailable>, rho=0x00000001071cca40, useCache=<unavailable>) + 44685 at eval.c:5547 
    frame #45: 0x00000001000b010e libR.dylib`Rf_eval(e=0x00000001026fc320, rho=0x00000001071cca40) + 446 at eval.c:558 
    frame #46: 0x00000001000df627 libR.dylib`Rf_applyClosure(call=0x000000010087d8a8, op=0x00000001026fc390, arglist=0x00000001071cd028, rho=0x00000001026cb430, suppliedvars=<unavailable>) + 1415 at eval.c:1045 
    frame #47: 0x00000001000bab80 libR.dylib`bcEval(body=<unavailable>, rho=0x00000001026cb430, useCache=<unavailable>) + 41872 at eval.c:5499 
    frame #48: 0x00000001000b010e libR.dylib`Rf_eval(e=0x000000010086d268, rho=0x00000001026cb430) + 446 at eval.c:558 
    frame #49: 0x00000001000df627 libR.dylib`Rf_applyClosure(call=0x00000001026ca8e8, op=0x000000010086c9f8, arglist=0x00000001026cb708, rho=0x000000010185e260, suppliedvars=<unavailable>) + 1415 at eval.c:1045 
    frame #50: 0x00000001000b04c8 libR.dylib`Rf_eval(e=0x00000001026ca8e8, rho=0x000000010185e260) + 1400 at eval.c:674 
    frame #51: 0x00000001001136b1 libR.dylib`Rf_ReplIteration(rho=0x000000010185e260, savestack=<unavailable>, browselevel=40675560, state=0x00007fff5fbfe7a0) + 785 at main.c:258 
    frame #52: 0x0000000100114b63 libR.dylib`run_Rmainloop [inlined] R_ReplConsole(rho=0x000000010185e260, savestack=0, browselevel=0) + 97 at main.c:308 
    frame #53: 0x0000000100114b02 libR.dylib`run_Rmainloop + 98 at main.c:1015 
    frame #54: 0x0000000100000f3b R`main(ac=<unavailable>, av=<unavailable>) + 27 at Rmain.c:29 
    frame #55: 0x00007fff9c8f05ad libdyld.dylib`start + 1 

我最好的猜測:在C字符串是SfParseVector::Init(char const*)被接收爲NULL。我建議你聯繫RSofia軟件包的維護人員。

+0

謝謝,凱文。我已聯繫軟件包維護人員瞭解錯誤。 – Ravi