{"cells":[{"metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","collapsed":true,"trusted":false},"cell_type":"code","source":"# data analysis and wrangling\nimport pandas as pd\nimport numpy as np\nimport random as rnd\n\n# visualization\nimport seaborn as sns\nimport matplotlib as mpl\nimport matplotlib.pyplot as plt\nimport matplotlib.pylab as pylab\n%matplotlib inline\nmpl.style.use( 'ggplot' )\nsns.set_style( 'whitegrid' )\nsns.set_palette(\"Set3\")\npylab.rcParams[ 'figure.figsize' ] = 8 , 6\n","execution_count":1,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","collapsed":true},"cell_type":"markdown","source":"Acquire data"},{"metadata":{"_uuid":"4f9f5135b3c5102fe3add68b4573501eef8b1a12","collapsed":true,"trusted":false},"cell_type":"code","source":"train_df = pd.read_csv('../input/train.csv')\ntest_df = pd.read_csv('../input/test.csv')\ncombine = [train_df, test_df]","execution_count":2,"outputs":[]},{"metadata":{"_uuid":"310af729e65b5cf25ec4c60d2254352481aba82a","trusted":false},"cell_type":"code","source":"train_df.head()","execution_count":3,"outputs":[]},{"metadata":{"_uuid":"a9b2db4d4f3e9aadcc0d79fea76f728d02032297","trusted":false},"cell_type":"code","source":"sns.distplot(train_df['deal_probability'])","execution_count":4,"outputs":[]},{"metadata":{"_uuid":"3c3cf2adad49d2bdb35afe6500f26f02e6f74c40"},"cell_type":"markdown","source":"# 3. Translating Columns\n## Translating few key columns in the dataset from russian to english language. These ready to use dictionaries are prepared using yandex and SRK's kernel."},{"metadata":{"_uuid":"36d3c679195319ef97eff2814e7f947e180919f2","collapsed":true,"trusted":false},"cell_type":"code","source":"parent_category_name_map = {\"Личные вещи\" : \"Personal belongings\",\n                            \"Для дома и дачи\" : \"For the home and garden\",\n                            \"Бытовая электроника\" : \"Consumer electronics\",\n                            \"Недвижимость\" : \"Real estate\",\n                            \"Хобби и отдых\" : \"Hobbies & leisure\",\n                            \"Транспорт\" : \"Transport\",\n                            \"Услуги\" : \"Services\",\n                            \"Животные\" : \"Animals\",\n                            \"Для бизнеса\" : \"For business\"}\n\nregion_map = {\"Свердловская область\" : \"Sverdlovsk oblast\",\n            \"Самарская область\" : \"Samara oblast\",\n            \"Ростовская область\" : \"Rostov oblast\",\n            \"Татарстан\" : \"Tatarstan\",\n            \"Волгоградская область\" : \"Volgograd oblast\",\n            \"Нижегородская область\" : \"Nizhny Novgorod oblast\",\n            \"Пермский край\" : \"Perm Krai\",\n            \"Оренбургская область\" : \"Orenburg oblast\",\n            \"Ханты-Мансийский АО\" : \"Khanty-Mansi Autonomous Okrug\",\n            \"Тюменская область\" : \"Tyumen oblast\",\n            \"Башкортостан\" : \"Bashkortostan\",\n            \"Краснодарский край\" : \"Krasnodar Krai\",\n            \"Новосибирская область\" : \"Novosibirsk oblast\",\n            \"Омская область\" : \"Omsk oblast\",\n            \"Белгородская область\" : \"Belgorod oblast\",\n            \"Челябинская область\" : \"Chelyabinsk oblast\",\n            \"Воронежская область\" : \"Voronezh oblast\",\n            \"Кемеровская область\" : \"Kemerovo oblast\",\n            \"Саратовская область\" : \"Saratov oblast\",\n            \"Владимирская область\" : \"Vladimir oblast\",\n            \"Калининградская область\" : \"Kaliningrad oblast\",\n            \"Красноярский край\" : \"Krasnoyarsk Krai\",\n            \"Ярославская область\" : \"Yaroslavl oblast\",\n            \"Удмуртия\" : \"Udmurtia\",\n            \"Алтайский край\" : \"Altai Krai\",\n            \"Иркутская область\" : \"Irkutsk oblast\",\n            \"Ставропольский край\" : \"Stavropol Krai\",\n            \"Тульская область\" : \"Tula oblast\"}\n\n\ncategory_map = {\"Одежда, обувь, аксессуары\":\"Clothing, shoes, accessories\",\n\"Детская одежда и обувь\":\"Children's clothing and shoes\",\n\"Товары для детей и игрушки\":\"Children's products and toys\",\n\"Квартиры\":\"Apartments\",\n\"Телефоны\":\"Phones\",\n\"Мебель и интерьер\":\"Furniture and interior\",\n\"Предложение услуг\":\"Offer services\",\n\"Автомобили\":\"Cars\",\n\"Ремонт и строительство\":\"Repair and construction\",\n\"Бытовая техника\":\"Appliances\",\n\"Товары для компьютера\":\"Products for computer\",\n\"Дома, дачи, коттеджи\":\"Houses, villas, cottages\",\n\"Красота и здоровье\":\"Health and beauty\",\n\"Аудио и видео\":\"Audio and video\",\n\"Спорт и отдых\":\"Sports and recreation\",\n\"Коллекционирование\":\"Collecting\",\n\"Оборудование для бизнеса\":\"Equipment for business\",\n\"Земельные участки\":\"Land\",\n\"Часы и украшения\":\"Watches and jewelry\",\n\"Книги и журналы\":\"Books and magazines\",\n\"Собаки\":\"Dogs\",\n\"Игры, приставки и программы\":\"Games, consoles and software\",\n\"Другие животные\":\"Other animals\",\n\"Велосипеды\":\"Bikes\",\n\"Ноутбуки\":\"Laptops\",\n\"Кошки\":\"Cats\",\n\"Грузовики и спецтехника\":\"Trucks and buses\",\n\"Посуда и товары для кухни\":\"Tableware and goods for kitchen\",\n\"Растения\":\"Plants\",\n\"Планшеты и электронные книги\":\"Tablets and e-books\",\n\"Товары для животных\":\"Pet products\",\n\"Комнаты\":\"Room\",\n\"Фототехника\":\"Photo\",\n\"Коммерческая недвижимость\":\"Commercial property\",\n\"Гаражи и машиноместа\":\"Garages and Parking spaces\",\n\"Музыкальные инструменты\":\"Musical instruments\",\n\"Оргтехника и расходники\":\"Office equipment and consumables\",\n\"Птицы\":\"Birds\",\n\"Продукты питания\":\"Food\",\n\"Мотоциклы и мототехника\":\"Motorcycles and bikes\",\n\"Настольные компьютеры\":\"Desktop computers\",\n\"Аквариум\":\"Aquarium\",\n\"Охота и рыбалка\":\"Hunting and fishing\",\n\"Билеты и путешествия\":\"Tickets and travel\",\n\"Водный транспорт\":\"Water transport\",\n\"Готовый бизнес\":\"Ready business\",\n\"Недвижимость за рубежом\":\"Property abroad\"}\n","execution_count":5,"outputs":[]},{"metadata":{"_uuid":"63eca9b2ada59723d55450c7855f8a614b606cf9","collapsed":true,"trusted":false},"cell_type":"code","source":"train_df['region_en'] = train_df['region'].apply(lambda x : region_map[x])\ntrain_df['parent_category_name_en'] = train_df['parent_category_name'].apply(lambda x : parent_category_name_map[x])\ntrain_df['category_name_en'] = train_df['category_name'].apply(lambda x : category_map[x])","execution_count":6,"outputs":[]},{"metadata":{"collapsed":true,"trusted":false,"_uuid":"960c67793474dd04d4c942743ba2a66c5d04c337"},"cell_type":"code","source":"pd.set_option('display.max_columns', 100)","execution_count":7,"outputs":[]},{"metadata":{"_uuid":"d2f3fd123f3fbb42eacf6446cf0209c138935cca","trusted":false},"cell_type":"code","source":"train_df.describe(include='all')","execution_count":8,"outputs":[]},{"metadata":{"_uuid":"a82c6949db7e0a569e608f07f22bd130e969da06","trusted":false},"cell_type":"code","source":"sns.distplot(train_df['price'].dropna())","execution_count":9,"outputs":[]},{"metadata":{"trusted":false,"_uuid":"ff3fd65ba5b5393d7e5ad9b0bca0df7c4041a0d2"},"cell_type":"code","source":"sns.pairplot(train_df.dropna(), hue='region_en',  markers='.',  plot_kws={'alpha': 0.4})","execution_count":10,"outputs":[]},{"metadata":{"trusted":false,"_uuid":"3a90a0735f885db0e0b7bbad76385738a258ca46"},"cell_type":"code","source":"sns.pairplot(train_df.dropna(), hue='activation_date',  markers='.',  plot_kws={'alpha': 0.4})","execution_count":11,"outputs":[]},{"metadata":{"trusted":false,"_uuid":"0dde1cf4429c4bcb5ad28230369b8463c8206d79"},"cell_type":"code","source":"sns.pairplot(train_df.dropna(), hue='user_type',  markers='.',  plot_kws={'alpha': 0.4})","execution_count":12,"outputs":[]},{"metadata":{"trusted":false,"_uuid":"719535815ea5737a5fa609af4748992c1e2eb9bd"},"cell_type":"code","source":"sns.pairplot(train_df.dropna(), hue='parent_category_name_en',  markers='.',  plot_kws={'alpha': 0.4})","execution_count":13,"outputs":[]},{"metadata":{"trusted":false,"_uuid":"36cc6a0ff6363e82f60f63d024a3a20128685dec"},"cell_type":"code","source":"sns.pairplot(train_df.dropna(), hue='category_name_en',  markers='.',  plot_kws={'alpha': 0.4})","execution_count":14,"outputs":[]},{"metadata":{"collapsed":true,"trusted":false,"_uuid":"e6b6cb5bcb5c8eac466d3510015cb3b355893832"},"cell_type":"code","source":"df01 = train_df[['price', 'item_seq_number', 'activation_date', 'user_type', 'image_top_1', 'deal_probability', 'region_en', 'parent_category_name_en', 'category_name_en']]","execution_count":20,"outputs":[]},{"metadata":{"collapsed":true,"trusted":false,"_uuid":"d42d0c26438d1460e1880de3dda828d273da0be3"},"cell_type":"code","source":"df01 = pd.get_dummies(df01, drop_first='true')","execution_count":21,"outputs":[]},{"metadata":{"trusted":false,"_uuid":"26626554ac45a909731c4fec87bacd103d175bf2"},"cell_type":"code","source":"df01.corr()['deal_probability'].sort_values()","execution_count":32,"outputs":[]},{"metadata":{"trusted":false,"_uuid":"148c84ed0131e2172ade82ce9317a0d60af86553"},"cell_type":"code","source":"sns.factorplot(x=\"parent_category_name_en_Personal belongings\", y=\"deal_probability\", data=df01, kind='box')","execution_count":36,"outputs":[]},{"metadata":{"collapsed":true,"trusted":false,"_uuid":"4ea04e8a8a0fe396994c62a825a0fe604c8e2854"},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.6.0"}},"nbformat":4,"nbformat_minor":1}