iseliget
V2EX  ›  问与答

MacBook Air 用 R 做随机森林,根本跑不动

  •  
  •   iseliget · Dec 30, 2015 · 3764 views
    This topic created in 3791 days ago, the information mentioned may be changed or developed.

    数据是常见的 handwritten digits , 700 多个特征。我的训练集有 10000 行。用的就是 randomForest 包里的 randomForest()函数。
    ```
    training_set = raw_data[1:10000, ]

    label_train = training_set[,1]
    label_train = as.factor(label_train) # randomForest()只接受 factor

    X_train = training_set[,2:ncol(training_set)]

    bagging_digits = randomForest(x=X_train, y=label_train, mytr=100, importance=TRUE)
    ```

    本人电脑配置 1.6GHz Intel Core i5, 4GB 内存。根本跑不动, R 就直接冻在那里。不知道这是因为配置太低,还是因为 randomForest 本身就慢,还是因为mytr太大?昨天跑 k-NN 的时候并没有这样。

    Supplement 1  ·  Dec 31, 2015
    不知道使用 Scikit 的话速度会不会有所改善?
    2 replies    2016-01-01 18:48:46 +08:00
    JamesRuan
        1
    JamesRuan  
       Dec 31, 2015
    R 本来就慢的,而且大多数程序还不是学计算机的写的,你才 1.6GHz Intel Core i5, 4GB ,我的 2.60GHz Intel Core i5, 8GB ,常常算起来(算法开了 4 线程)就是半个小时,还常常内存不足。

    可以试试这个:
    http://www.r-statistics.com/2012/04/speed-up-your-r-code-using-a-just-in-time-jit-compiler/
    newton108
        2
    newton108  
       Jan 1, 2016 via iPhone
    正常,看一下 random forest 的算法你就知道为啥了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5892 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 07:09 · PVG 15:09 · LAX 00:09 · JFK 03:09
    ♥ Do have faith in what you're doing.