Contenu connexe
Plus de Atsushi Hayakawa (20)
Julia0.3でランダムフォレスト
- 3. DecisionTree.jl
● bensadeghiさんが開発
○ 他には、
■ MineSweeperSolver.jl
■ METADATA.jl
■ pyplot.jl
○ なども開発に関わっている。
● MITライセンス
● 決定木はID3 algorithmで実装されている。
CARTで実装されたランダムフォレストは、
@bicycle1885さんが開発している。
https://github.com/bicycle1885/RandomForests.jl
- 4. 「R言語による Random Forest 徹底入門 -集団学習による分類・予測-」 - #TokyoR #11
http://www.slideshare.net/hamadakoichi/introduction-torandomforest-tokyor
- 10. ソースコードを覗いてみる(分類)
function build_forest(labels::Vector, features::Matrix, nsubfeatures::Integer,
ntrees::Integer, partialsampling=0.7)
partialsampling = partialsampling > 1.0 ? 1.0 : partialsampling
Nlabels = length(labels)
Nsamples = int(partialsampling * Nlabels)
forest = @parallel (vcat) for i in [1:ntrees]
inds = rand(1:Nlabels, Nsamples)
build_tree(labels[inds], features[inds,:], nsubfeatures)
end
return Ensemble([forest])
end
● バージョン0.2の頃に合わせているのか、データの持ち方がVectorとMtrixになってる。
● arrayとの違いはなんだろうか?
● 引数は、nsubfeatrues, ntrees, partialsamplingの3つ
● partialsamplingは、指定しなくても動作する
● 並列処理に対応しているっぽい
- 11. ソースコードを覗いてみる(回帰)
function build_forest{T<:FloatingPoint,U<:Real}(labels::Vector{T},features::Matrix{U},
nsubfeatures::Integer, ntrees::Integer, maxlabels=0.5, partialsampling=0.7)
partialsampling = partialsampling > 1.0 ? 1.0 : partialsampling
Nlabels = length(labels)
Nsamples = int(partialsampling * Nlabels)
forest = @parallel (vcat) for i in [1:ntrees]
inds = rand(1:Nlabels, Nsamples)
build_tree(labels[inds], features[inds,:], maxlabels, nsubfeatures)
end
return Ensemble([forest])
end
● Javaでいうオーバーライドが出来るのかな?
● 関数を宣言した直後に型を指定?
● パラメータにmaxlabelsが追加されている。葉あたりの平均サンプル数を指定する