logo
Loading...

執行DecisionTree.fit!(model, features, labels)出現boundserror如何解決 - Cupoy

df=biopsy[!, 2:6]df=dropmissing(df)labels=Vector{S...

decision tree

執行DecisionTree.fit!(model, features, labels)出現boundserror如何解決

2020/05/06 下午 11:02
Julia程式語言討論版
Casey Lin
觀看數:3
回答數:1
收藏數:0
decision tree

df=biopsy[!, 2:6]

df=dropmissing(df)

labels=Vector{String}(biopsy[!, :Class])

features=Matrix(df)

model = DecisionTree.RandomForestClassifier(n_trees=50, max_depth=2)

DecisionTree.fit!(model, features, labels) 執行OK


若改為 df=biopsy[!, 2:10]

DecisionTree.fit!(model, features, labels) 執行, 會有 boundserror

TaskFailedException:
BoundsError: attempt to access 683×9 Array{Int32,2} at index [[194, 460, 217, 16, 479, 502, 518, 202, 613, 524, 607, 615, 256, 554, 291, 590, 5


但在 atom IDE REPL 又OK, 可以請問原因?

回答列表

  • 2020/05/07 下午 00:09
    杜岳華
    贊同數:0
    不贊同數:0
    留言數:0

    請確認您的資料,從錯誤訊息看來,您的資料只有 9 行 (column),而您想存取第 10 行。

    這樣的情況下,理當會出現 BoundsError。