# This R environment comes with all of CRAN preinstalled, as well as many other helpful packages
# The environment is defined by the kaggle/rstats docker image: https://github.com/kaggle/docker-rstats
# For example, here's several helpful packages to load in 

library(ggplot2) # Data visualization
library(readr) # CSV file I/O, e.g. the read_csv function
library(data.table)

# Input data files are available in the "../input/" directory.
# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory

# system("ls ../input")

# Any results you write to the current directory are saved as output.
train <- fread("../input/train.csv", integer64 = "character")
test <- fread("../input/test.csv")
summary(train)
# distribution of accuracy
ggplot(train, aes(accuracy)) + geom_density()
setkeyv(train, "place_id")
top10=train[, .N, by = key(train)][order(-N)][1:10,]
top10$id = rownames(top10)

merged = merge(train,top10, by="place_id")
qplot(merged$x, merged$y, colour=merged$place_id) + guides(colour=FALSE)