?????????以?????????????????????????????????????????ж???????????????????????

??????????????????5-10????????????????????????1??С????????????????? …

????8809=6

????7111=0

????2172=0

????6666=4

????1111=0

????3213=0

????7662=2

????9313=1

????0000=4

????2222=0

????3333=0

????5555=0

????8193=3

????8096=5

????7777=0

????9999=4

????7756=1

????6855=3

????9881=5

????5531=0

????2581=?

????????? …

????.

????.

????.

????.

????.

????.

????.

????.

????.

??????????????????ж???????й??????????8??2?????????????Ρ?0????????????1?Ρ?????2581=2?????????????????????????????????????ó???????????????????

???????????????????????????????????????????????????????????????????????????ü??????????????????????????????£?????????????????????????????????????????????????????????OLS(ordinary least squares)??????????????????????????????????????????漰????????????????СС??OLS????????????????е???????????????????????????????????????????8809=6??????????????????????????????????????

????1??0??0??0??0??0??0??0??2??1 = 6

??????????????????У?10?????????????????0-9??????????г?????????????????εó???????α???????????????????????????????????????????????????StackOverflow.com???????????????????????????????????????α????????????????????10?????????????????????

?????????????????——???????????????——????????Щ???????????????R??????????????С?

????## read in the training data

????## more lines than it should be because of the https requirement in Github

????temporaryFile <- tempfile()

????download.file("https://raw.github.com/gist/2061284/44a4dc9b304249e7ab3add86bc245b6be64d2cdd/problem.csv"??destfile=temporaryFile?? method="curl")

????series <- read.csv(temporaryFile)

????## munge the data to create a frequency table

????freqTable <- as.data.frame( t(apply(series[??1:4]?? 1?? function(X) table(c(X?? 0:9))-1)) )

????names(freqTable) <- c("zero"??"one"??"two"??"three"??"four"??"five"??"six"??"seven"??"eight"??"nine")

????freqTable$dep <- series[??5]

????## now a simple OLS regression with no intercept

????myModel <- lm(dep ~ 0 + zero + one + two + three + four + five + six + seven + eight + nine?? data=freqTable)

????round(myModel$coefficients)

????Created by Pretty R at inside-R.org

????????????????£?

????> round(myModel$coefficients)

????zero one two three four five six seven eight nine

????1 0 0 0 NA 0 1 0 2 1

??????????????0??6??9????????1????8????????2?????????????????0????4?ó?????NA?????????????????????г???4??

????????????????????????????????????????ó????????????