Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. Error in strsplit(tmp, """)[[1]] : subscript out of bounds
  2.  
  3. import rpy2.robjects as robjects
  4. from rpy2.robjects.packages import importr
  5. from rpy2.robjects.vectors import FloatVector
  6. from rpy2.robjects import pandas2ri
  7. Cubist = importr('Cubist')
  8. lattice = importr('lattice')
  9. r = robjects.r
  10. # 准备样点数据
  11. dt = r('mtcars')
  12. Z = FloatVector(dt[3])
  13. X = FloatVector(dt[5])
  14. X1 = FloatVector(dt[6])
  15. T = r['cbind'](X,X1)
  16.  
  17. regr = r['cubist'](x=T,y=Z,committees=10)
  18.  
  19. library(Cubist)
  20.  
  21. dt = mtcars
  22. Z = dt[, 4]
  23. X = dt[, 6]
  24. X1 = dt[, 7]
  25.  
  26. > T = cbind(dt[, 6], dt[, 7])
  27. > str(T)
  28. num [1:32, 1:2] 2.62 2.88 2.32 3.21 3.44 ...
  29. > cubist(x=T, y=Z, committees=10)
  30. cubist code called exit with value 1
  31. Error in strsplit(tmp, """)[[1]] : subscript out of bounds
  32.  
  33. > T = cbind(X, X1)
  34. > str(T)
  35. num [1:32, 1:2] 2.62 2.88 2.32 3.21 3.44 ...
  36. - attr(*, "dimnames")=List of 2
  37. ..$ : NULL
  38. ..$ : chr [1:2] "X" "X1"
  39. > cubist(x=T, y=Z, committees=10)
  40.  
  41. Call:
  42. cubist.default(x = T, y = Z, committees = 10)
  43.  
  44. Number of samples: 32
  45. Number of predictors: 2
  46.  
  47. Number of committees: 10
  48. Number of rules per committee: 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  49.  
  50. In [15]: T = r['cbind'](X=X,X1=X1)
  51.  
  52. In [16]: print(r['str'](T))
  53. num [1:32, 1:2] 2.62 2.88 2.32 3.21 3.44 ...
  54. - attr(*, "dimnames")=List of 2
  55. ..$ : NULL
  56. ..$ : chr [1:2] "X" "X1"
  57. <rpy2.rinterface.NULLType object at 0x7f0d7c0f5608> [RTYPES.NILSXP]
  58.  
  59. In [17]: print(r['cubist'](x=T,y=Z,committees=10))
  60.  
  61. Call:
  62. cubist.default(x = structure(c(2.62, 2.875, 2.32, 3.215, 3.44, 3.46,
  63. 205, 215, 230, 66, 52, 65, 97, 150, 150, 245, 175, 66, 91, 113, 264, 175,
  64. 335, 109), committees = 10L)
  65.  
  66. Number of samples: 32
  67. Number of predictors: 2
  68.  
  69. Number of committees: 10
  70. Number of rules per committee: 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement