Predict the category of crimes that occurred in the city by the bay
From 1934 to 1963, San Francisco was infamous for housing some of the world’s most notorious criminals on the inescapable island of Alcatraz.
Today, the city is known more for its tech scene than its criminal past. But, with rising wealth inequality, housing shortages, and a proliferation of expensive digital toys riding BART to work, there is no scarcity of crime in the city by the bay.
From Sunset to SOMA, and Marina to Excelsior, this competition’s dataset provides nearly 12 years of crime reports from across all of San Francisco’s neighborhoods. Given time and location, you must predict the category of crime that occurred.
We’re also encouraging you to explore the dataset visually. What can we learn about the city through visualizations like this Top Crimes Map? The top most up-voted scripts from this competition will receive official Kaggle swag as prizes.
预测旧金山的犯罪种类。可用的特征只有时间和地点,预测结果要求给出概率,最后优化的目标函数是logloss。
犯罪数据本身是十分有趣的,简单探索可以发现比如周五的犯罪最多,某些犯罪可能偏向于发生在某些特定地区和特定时间,最常见的犯罪比如偷窃等等。论坛里有很多漂亮的数据可视化的展示。
预测概率,选择了简单的朴素贝叶斯算法,特征中有很多字符串类,需要把他们转化成数值类,如果直接对字符串hash给一个数值,这个数值可能并不能真实反映特征不同种类之间的关系,所以选择二值化处理。这里学会了一个很方便的方法,用pandas的get_dummies。
最后排名50%。
代码: