R を使用して、以下のような構造のデータを含む「d」というデータ フレームを分類しています。
データには 576666 行があり、列 "classLabel" には 3 つのレベル (ONE、TWO、THREE) の係数があります。
rpart を使用して決定木を作成しています。
fitTree = rpart(d$classLabel ~ d$tripduration + d$from_station_id + d$gender + d$birthday)
そして、次の「classLabel」の値を予測したいと思いますnewdata
。
newdata = data.frame( tripduration=c(345,244,543,311),
from_station_id=c(60,28,100,56),
gender=c("Male","Female","Male","Male"),
birthday=c(1972,1955,1964,1967) )
p <- predict(fitTree, newdata)
私の結果は、「classLabel」の 3 つの可能な値の確率を持つ 4 行の行列になると期待していますnewdata
。しかし、p の結果として得られるのは、以下のような 576666 行のデータフレームです。
predict
関数を実行すると、次の警告も表示されます。
Warning message:
'newdata' had 4 rows but variables found have 576666 rows
私はどこで間違っていますか?!