r - prediction applied to whole data -
hi doing prediction data.if use data.frame throws folloing error.
input(bedrooms="2",bathrooms="2",area="1000") specified different types fit here program input <- function(bedrooms,bathrooms,area) { delhi <- read.delim("delhi.tsv", na.strings = "") delhi$lnprice <- log(delhi$price) heddel <- lm(lnprice ~ bedrooms+ area+ bathrooms,data=delhi) valuepred = predict (heddel,data.frame(bedrooms=bedrooms,area=area,bathrooms=bathrooms),na.rm = true) final_prediction = exp(valuepred) final_prediction }
if remove data.frame predicts value on data.i got following output.
1 2 3 4 5 6 7 15480952 11657414 10956873 6011639 6531880 9801468 16157549 9 10 11 14 15 16 17 10698786 5596803 14688143 20339651 22012831 16157618 26644246
but needs display 1 value only.
any idea how resolve this..any appreciated
sharon, want make prediction specific values of bedroom, bathroom , area, putting them in character rather numeric values. causing error seeing. when remove data.frame statement predict, produce predictions based on data set used build model, i.e. delhi.
try
input(bedrooms=2,bathrooms=2,area=1000)
Comments
Post a Comment