{"cells":[{"metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","trusted":true},"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nimport os\nprint(os.listdir(\"../input\"))\n\n# Any results you write to the current directory are saved as output.","execution_count":192,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"from plotly.offline import init_notebook_mode, iplot\nfrom wordcloud import WordCloud\nimport plotly.graph_objs as go\nimport matplotlib.pyplot as plt\nimport plotly.plotly as py\nfrom plotly import tools\nfrom datetime import date\nimport pandas as pd\nimport numpy as np \nimport seaborn as sns\nimport random \nimport warnings\nwarnings.filterwarnings(\"ignore\")\ninit_notebook_mode(connected=True)\n\n\n\nimport numpy as np\nimport pandas as pd\ntrain_df=pd.read_csv(\"../input/train.csv\")\ntest_df=pd.read_csv(\"../input/test.csv\")","execution_count":193,"outputs":[]},{"metadata":{"_cell_guid":"919b053e-5c16-492d-a024-90b7ce18f077","_uuid":"70bc38c8429bc821a8fd00ccc94e1911fe941208","trusted":true},"cell_type":"code","source":"train_df.info()","execution_count":194,"outputs":[]},{"metadata":{"_cell_guid":"931a675c-8875-40e4-a233-572b7d5dc531","_uuid":"82f79a53820be755483c3bc7eae00e761eb50f85","trusted":true},"cell_type":"code","source":"train_df.head()","execution_count":195,"outputs":[]},{"metadata":{"collapsed":true,"_uuid":"93c98d7d9eec84f96e5b09bfe55d6cf6ecec9a53","trusted":true},"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","execution_count":196,"outputs":[]},{"metadata":{"collapsed":true,"_uuid":"06f925855e9a302c318d56466472bf535bbdc968","trusted":true},"cell_type":"code","source":"category_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":197,"outputs":[]},{"metadata":{"collapsed":true,"_cell_guid":"5f5a9e0b-1c6e-4875-b3cf-e1504c6a9163","_uuid":"e26d18a1429c87f14ef0080b93a26d63cd8f994c","trusted":true},"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])\n\n\ntest_df['region_en'] = test_df['region'].apply(lambda x : region_map[x])\ntest_df['parent_category_name_en'] = test_df['parent_category_name'].apply(lambda x : parent_category_name_map[x])\ntest_df['category_name_en'] = test_df['category_name'].apply(lambda x : category_map[x])","execution_count":198,"outputs":[]},{"metadata":{"_cell_guid":"f63601ff-1562-4043-95a7-2a80ecc39983","_uuid":"c3a22da7e7cee173a421a119bf0cad5604950dad","trusted":true},"cell_type":"code","source":"#result = pd.concat([df1, df4], axis=1, sort=False)\n#train_df1=pd.concat([train_df, train_df['region_en']], axis=1, sort=False)\ntrain_df.head()","execution_count":199,"outputs":[]},{"metadata":{"_uuid":"6b24b7649b0aa76e4f6e1d776943c14b211a4b9f","trusted":true},"cell_type":"code","source":"test_df.head()","execution_count":200,"outputs":[]},{"metadata":{"_cell_guid":"3aa6c6ee-3110-47f7-a323-699daf31de23","_uuid":"b7a503cae70ad1ba4dff9c0e1d8d2a4beeb90ad0","scrolled":false,"trusted":true},"cell_type":"code","source":"# df.plot(x='col_name_1', y='col_name_2', style='o')\n#train_df.plot(x='category_name_en', y='deal_probability', style='o')\n#a.groupby('user')['num1', 'num2'].average()\n#m1 = (df['SibSp'] > 0) | (df['Parch'] > 0)\n#m= (train_df1['deal_probability'])\n\n#grouped = df.groupby('mygroups').sum().reset_index()\n#grouped.sort_values('mygroups', ascending=False)\n\ngrouped=train_df.groupby('category_name_en')['deal_probability'].sum()\ngrouped.sort_values(ascending=False)\n#train_df.head()\n#m.head()","execution_count":201,"outputs":[]},{"metadata":{"_cell_guid":"d4f870c5-b9c6-48b4-a65e-6448f20b932f","_uuid":"3a2af96708ba393ea19a1b256e772aab29327db3","trusted":true},"cell_type":"code","source":"## Description charecter count\n# df['NAME_Count'] = df['NAME'].str.len()\ntrain_df['des_str_count']=train_df['description'].str.len()\ntest_df['des_str_count']=test_df['description'].str.len()\ntrain_df.head()","execution_count":202,"outputs":[]},{"metadata":{"_cell_guid":"0d0cbe6a-2196-44c5-ac1a-c4bca5aad646","_uuid":"81738b4d69748eae345db06e0d607c0528309d25","scrolled":true,"trusted":true},"cell_type":"code","source":"## Title charecter count\n# df['NAME_Count'] = df['NAME'].str.len()\ntrain_df['title_str_count']=train_df['title'].str.len()\ntest_df['title_str_count']=test_df['title'].str.len()\ntrain_df.head()","execution_count":203,"outputs":[]},{"metadata":{"collapsed":true,"_cell_guid":"209c553e-181f-4e0d-8d43-5802163241be","_uuid":"d59d4029092fa5f38a46f5b520871a141d225d65","trusted":true},"cell_type":"code","source":"#encoding text columns\n#column = column.astype('category')\n#column_encoded = column.cat.codes\n\ntrain_df['region_en1'] = train_df['region_en'].astype('category')\ntrain_df['region_en_encoded']=train_df['region_en1'].cat.codes\n\n\ntrain_df['parent_category_name_en1'] = train_df['parent_category_name_en'].astype('category')\ntrain_df['parent_category_name_en_encoded']=train_df['parent_category_name_en1'].cat.codes\n\ntrain_df['category_name_en1'] = train_df['category_name_en'].astype('category')\ntrain_df['category_name_en_encoded']=train_df['category_name_en1'].cat.codes\n\n\ntest_df['region_en1'] = test_df['region_en'].astype('category')\ntest_df['region_en_encoded']=test_df['region_en1'].cat.codes\n\n\ntest_df['parent_category_name_en1'] = test_df['parent_category_name_en'].astype('category')\ntest_df['parent_category_name_en_encoded']=test_df['parent_category_name_en1'].cat.codes\n\ntest_df['category_name_en1'] = test_df['category_name_en'].astype('category')\ntest_df['category_name_en_encoded']=test_df['category_name_en1'].cat.codes","execution_count":204,"outputs":[]},{"metadata":{"_cell_guid":"497e378e-fd27-4c0e-b8f9-51337199f855","_uuid":"8600a455f5ff0034cb2563bd2f18e366dbf4def7","trusted":true},"cell_type":"code","source":"test_df.head()","execution_count":205,"outputs":[]},{"metadata":{"collapsed":true,"_cell_guid":"6000d7b4-3785-40b1-b5c6-3709b5752b81","_uuid":"78bbc75efd62e9ac8bf90c3ee120a694e3f62319","trusted":true},"cell_type":"code","source":"#new table with selected columns\ntrain_df1=train_df[['title_str_count','des_str_count','region_en_encoded','parent_category_name_en_encoded','category_name_en_encoded','deal_probability']]\n\ntest_df1=test_df[['title_str_count','des_str_count','region_en_encoded','parent_category_name_en_encoded','category_name_en_encoded']]","execution_count":206,"outputs":[]},{"metadata":{"_cell_guid":"1fb925fd-3c12-44b4-887a-b7950d7829a7","_uuid":"5f8daab2e72de3ef7e2ccc6aab119e4330b3ccf6","trusted":true},"cell_type":"code","source":"train_df1.head()","execution_count":207,"outputs":[]},{"metadata":{"_cell_guid":"6a5c7bdd-1b9e-44ad-a1de-9b5e5a1f3ecc","_uuid":"34ae4364ed2dae1e4ea32235c329cec1c52dec8c","trusted":true},"cell_type":"code","source":"test_df1.head()","execution_count":208,"outputs":[]},{"metadata":{"_cell_guid":"afb6b0cc-d6fe-4bc0-8f92-6cb7423b8f51","_uuid":"f3099d1fdb3e32bc3d95468b369c32bd41c1535c","trusted":true},"cell_type":"code","source":"#df.isnull().any().any() - This returns a boolean value\ntrain_df1.isnull().any()","execution_count":209,"outputs":[]},{"metadata":{"collapsed":true,"_cell_guid":"e511ce24-a8bd-42a4-b654-d5dd5c0fb10c","_uuid":"453d19b958b45b4c6c64a27da2db9c17e743da22","trusted":true},"cell_type":"code","source":"#df = df[np.isfinite(df['EPS'])]\n#dat.dropna()\n#train_df1=train_df1[np.isfinite(train_df1['des_str_count'])]\n#train_df1=train_df1.dropna()\n#train_df1.dropna(subset=train_df1['deal_probability'], how='all')\n\ntrain_df1 = train_df1.dropna(how='any',axis=0) \ntest_df1 = test_df1.dropna(how='any',axis=0) ","execution_count":210,"outputs":[]},{"metadata":{"collapsed":true,"_cell_guid":"3df0d76b-71cd-4fa8-b698-57703f5a9232","_uuid":"d997c1ee5753f9d168c45c3c45d2bd30ff142ce1","trusted":true},"cell_type":"code","source":"#train_df1.loc[:, train_df1.isna().any()]","execution_count":211,"outputs":[]},{"metadata":{"_cell_guid":"4e8cfdc1-49b4-4498-a83e-ad453c499af7","_uuid":"33842a9aaae453156ed6237e17a21379d5118f06","scrolled":true,"trusted":true},"cell_type":"code","source":"train_df1.info()","execution_count":212,"outputs":[]},{"metadata":{"_cell_guid":"51ec412e-d070-49bd-8069-e1218e74325c","_uuid":"a11182d6271d9417d8c5a380c0f241c646719be9","trusted":true},"cell_type":"code","source":"train_df1.head()","execution_count":213,"outputs":[]},{"metadata":{"collapsed":true,"_cell_guid":"eb232d87-81d2-4611-9a97-6e1be0b09b13","_uuid":"a6852419330d30f6d9c1863731e04fb213fd87c6","trusted":true},"cell_type":"code","source":"#from sklearn import preprocessing\n#from sklearn import utils\n\n#lab_enc = preprocessing.LabelEncoder()\n#encoded = lab_enc.fit_transform(train_df1['deal_probability'])\n\n#train_df1['deal_probability'] = train_df1['deal_probability'].astype(int)\n#train_df1['deal_probability'] = train_df1['deal_probability'].astype(float)","execution_count":214,"outputs":[]},{"metadata":{"collapsed":true,"_cell_guid":"8c1f378b-8213-4327-b25d-82ce0879e278","_uuid":"9cab16bd8691c52060796cd377f704764d98ce4b","scrolled":true,"trusted":true},"cell_type":"code","source":"#print(utils.multiclass.type_of_target(train_df1['deal_probability']))","execution_count":215,"outputs":[]},{"metadata":{"collapsed":true,"_cell_guid":"b7b891d5-dee3-4741-b7de-ee27d3b56b02","_uuid":"6161fd346dc389979c487ae07f4fc363f0a18ff6","trusted":true},"cell_type":"code","source":"train_df1['deal_probability']=train_df1['deal_probability']*100","execution_count":216,"outputs":[]},{"metadata":{"_cell_guid":"f9ad1e54-6480-4bce-bcaa-ab3ee42a0b5f","_uuid":"711d33798301ae56b58645ed04ca99e7a48fad61","trusted":true},"cell_type":"code","source":"train_df1['deal_probability']","execution_count":217,"outputs":[]},{"metadata":{"collapsed":true,"_cell_guid":"090a2ae8-da5f-44f9-a1e9-09889928dc9f","_uuid":"0b74a898bffe1497311a4d95260413bb4bbc6719","trusted":true},"cell_type":"code","source":"train_df1['deal_probability'] = train_df1['deal_probability'].astype(int)\n#df1['c2'] = df1.c2.astype(np.int64)\ntrain_df1['des_str_count'] = train_df1['des_str_count'].astype(np.int64)","execution_count":218,"outputs":[]},{"metadata":{"_cell_guid":"4f67780b-fe5a-4f35-b255-37dda2177100","_uuid":"602baab426c7969dc87c236f58808965d53b4b5f","trusted":true},"cell_type":"code","source":"train_df1['deal_probability']","execution_count":219,"outputs":[]},{"metadata":{"collapsed":true,"_cell_guid":"b1fe0c2a-c256-400e-8dac-0666d01d6142","_uuid":"536e1f6b09eb1946d90c4f835e5536caa60dbee7","trusted":true},"cell_type":"code","source":"#Splitting the Training Data\nfrom sklearn.model_selection import train_test_split\n\npredictors = train_df1[['title_str_count','des_str_count','region_en_encoded','parent_category_name_en_encoded','category_name_en_encoded']]\n#predictors = train_df1[['title_str_count','des_str_count','parent_category_name_en_encoded','category_name_en_encoded']]\n\n\n\ntarget = train_df1['deal_probability']\n#y=y.astype('int')\n#target=target.astype('float64')\nx_train, x_val, y_train, y_val = train_test_split(predictors, target, test_size = 0.22, random_state = 0)\n#y_train=y_train.astype('float64')","execution_count":220,"outputs":[]},{"metadata":{"collapsed":true,"_uuid":"407e938c17d5d4901a996643b0c86145370581f2","trusted":true},"cell_type":"code","source":"x_test=test_df1","execution_count":221,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0b226501afb557108d26ed797e0349ebe6831e23"},"cell_type":"code","source":"#x_train","execution_count":222,"outputs":[]},{"metadata":{"_cell_guid":"640ef02c-81f0-412d-af36-de12c8a2ea4e","_uuid":"a7d41933bcc60dcfc762f3b7433fc53602c4f9b2","trusted":true},"cell_type":"code","source":"# Gaussian Naive Bayes\nfrom sklearn.naive_bayes import GaussianNB\nfrom sklearn.metrics import accuracy_score\n\ngaussian = GaussianNB()\ngaussian.fit(x_train, y_train)\ny_pred = gaussian.predict(x_val)\nacc_gaussian = round(accuracy_score(y_pred, y_val) * 100, 2)\nprint(acc_gaussian)\n# decesion tree\n#from sklearn.tree import DecisionTreeClassifier\n#tree = DecisionTreeClassifier(max_depth = 10, random_state = 0)\n#tree.fit(x_train, y_train)\n\n\n# Logistic reg\n#from sklearn.linear_model import LogisticRegression\n# Create logistic regression object\n#model = LogisticRegression()\n# Train the model using the training sets and check score\n#model.fit(x_train, y_train)\n#model.score(x_train, y_train)\n#Equation coefficient and Intercept\n#print('Coefficient: \\n', model.coef_)\n#print('Intercept: \\n', model.intercept_)\n#Predict Output\n#predicted= model.predict(x_val)","execution_count":223,"outputs":[]},{"metadata":{"_cell_guid":"7faca4f3-73b2-4bfb-83c3-092db6df9c28","_uuid":"f15d3ae98e12dab0730cacef9b1fec84ddb1c18a","trusted":true},"cell_type":"code","source":"#x_val","execution_count":224,"outputs":[]},{"metadata":{"_cell_guid":"ef23ee6f-683a-4b2e-8567-efb32887f380","_uuid":"2e77fe9205a78d79e9a75a5ffd11b69ba77128d3","trusted":true},"cell_type":"code","source":"#predicted\ny_pred","execution_count":225,"outputs":[]},{"metadata":{"collapsed":true,"_cell_guid":"bc5c4183-73e0-4136-b268-107ac826a8a0","_uuid":"76438f2c7180c5ac739df77831227fc8759e3595","trusted":true},"cell_type":"code","source":"# Gaussian Naive Bayes\n#from sklearn.naive_bayes import GaussianNB\n#from sklearn.metrics import accuracy_score\n\n#gaussian = GaussianNB()\n#gaussian.fit(x_train, y_train)\n#y_pred = gaussian.predict(x_val)\nacc_gaussian = round(accuracy_score(y_pred, y_val) * 100, 2)\n#print(acc_gaussian)\n# decesion tree\n#from sklearn.tree import DecisionTreeClassifier\n#tree = DecisionTreeClassifier(max_depth = 10, random_state = 0)\n#tree.fit(x_train, y_train)","execution_count":226,"outputs":[]},{"metadata":{"_cell_guid":"7dab89c3-327e-429e-bffd-9e9ccb84389e","_uuid":"d56bc447fc325bfa3be7e0cc357a33e376eabcec","trusted":true},"cell_type":"code","source":"y_pred","execution_count":227,"outputs":[]},{"metadata":{"collapsed":true,"_cell_guid":"223528bb-c2da-4b07-a4f9-5d2641dc8e7d","_uuid":"e5409b11bde1d554813695ba57a19b25b5b19044","trusted":true},"cell_type":"code","source":"##np.set_printoptions(threshold=np.inf)","execution_count":228,"outputs":[]},{"metadata":{"collapsed":true,"_uuid":"22f3d0f5e15e24b9cab2ebbae8eea4d3f4f77dcb","trusted":true},"cell_type":"code","source":"y_pred=y_pred/100","execution_count":229,"outputs":[]},{"metadata":{"_uuid":"51bb67e4db0bee311cc1501b05e2e6bcd2bf614d","trusted":true},"cell_type":"code","source":"test_df1.head()","execution_count":230,"outputs":[]},{"metadata":{"collapsed":true,"_uuid":"ca3372f00f52d4cc65fd91a354e605cf88b45c16","trusted":true},"cell_type":"code","source":"y_test_pred = gaussian.predict(test_df1)","execution_count":231,"outputs":[]},{"metadata":{"collapsed":true,"_uuid":"1a2ed7f6d6a40599cf0e2f719540aef16ee597e6","trusted":true},"cell_type":"code","source":"y_test_pred=y_test_pred/100","execution_count":232,"outputs":[]},{"metadata":{"_uuid":"5e83c8187352b4118bb2063a04f35d9da23f617e","trusted":true},"cell_type":"code","source":"test_df1.head()","execution_count":233,"outputs":[]},{"metadata":{"_uuid":"ec7278c6078adca57bceeb94bb45e70738e80362","trusted":true},"cell_type":"code","source":"test_df.head()","execution_count":234,"outputs":[]},{"metadata":{"collapsed":true,"_uuid":"6edfd5781e2480cb6e541d2adccf29770c220d51","trusted":true},"cell_type":"code","source":"# pd.concat([df1['c'], df2['c']], axis=1, keys=['df1', 'df2'])\nsubmit_data= pd.concat([test_df['item_id'], pd.DataFrame(y_test_pred)], axis=1)","execution_count":235,"outputs":[]},{"metadata":{"_uuid":"7b6fa305f1d0f5a2212b090c8ab1d86323b9fd84","trusted":true},"cell_type":"code","source":"#submit_data","execution_count":236,"outputs":[]},{"metadata":{"collapsed":true,"_uuid":"957e4251c8ab82e44e58b445c7f6985cee00c92a","trusted":true},"cell_type":"code","source":"# data.rename(columns={'gdp':'log(gdp)'}, inplace=True)\n#submit_data.rename(columns={0:'deal_probablity'}, inplace=True)  D:\\personal\\kaggle\\Avito  funded.to_csv(path+'greenl.csv')\n# import os\n# funded.to_csv(os.path.join(path,r'green1.csv'))","execution_count":237,"outputs":[]},{"metadata":{"collapsed":true,"_uuid":"8c5be7001a901441492269fb19d527d6eeb88d63","trusted":true},"cell_type":"code","source":"submit_data.rename(columns={0:'deal_probability'}, inplace=True)","execution_count":238,"outputs":[]},{"metadata":{"_uuid":"09df170f053356978aea75609d8d970b777e5d5d","trusted":true},"cell_type":"code","source":"submit_data.head()","execution_count":239,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"fb5f5a2ce622d01f94839640b9895d1bf0165a8e"},"cell_type":"code","source":"#train_df1.head()","execution_count":240,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"98dfaedf644915dd8b601195d68bc21579bc0290"},"cell_type":"code","source":"#df1['c2'] = df1.c2.astype(np.int64)\n#train_df1['des_str_count'] = train_df1['des_str_count'].astype(np.int64)","execution_count":241,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"39122a19e6cec624132b9e09457d613ad0e2452c"},"cell_type":"code","source":"train_df1.head()","execution_count":242,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"dae84393b5d5d8bd1dc0e59ce78be88ce75c6a35"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f5b32d6de2b51e812cbc4be8ab66280e412abb56"},"cell_type":"code","source":"#x_train, x_val, y_train, y_val = train_test_split(predictors, target, test_size = 0.22, random_state = 0)\n\nimport lightgbm as lgb\n\nd_train = lgb.Dataset(x_train, label=y_train)\n\nparams = {}\nparams['learning_rate'] = 0.003\nparams['boosting_type'] = 'gbdt'\nparams['objective'] = 'regression'\nparams['metric'] = 'rmse'\nparams['sub_feature'] = 0.5\nparams['num_leaves'] = 10\nparams['min_data'] = 50\nparams['max_depth'] = 10\n\nclf = lgb.train(params, d_train, 100)\n\n","execution_count":243,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e1a70ab3583ae90c3c386703377a4c2e1b71d8c4"},"cell_type":"code","source":"#x_train","execution_count":244,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"5f6778430fcaf7d073674272bf538265e7499359"},"cell_type":"code","source":"#Prediction\ny_pred=clf.predict(x_val)","execution_count":245,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f41bd9ffc58881ca35367f532594daf237b39d19"},"cell_type":"code","source":"#y_val","execution_count":246,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4295d35d1c6e514115d62d7a6c0f6ba679732d8a"},"cell_type":"code","source":"#Accuracy\n\n#from sklearn.metrics import accuracy_score\n#accuracy=accuracy_score(y_pred,y_val)","execution_count":247,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"4a4bcaac0f47814c62bf2994731a29f2f3aa8ad3"},"cell_type":"code","source":"#test prediction\ny_test_pred_lgbm = clf.predict(test_df1)\ny_test_pred_lgbm = y_test_pred_lgbm/100","execution_count":248,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"7989922a5242c494730c37207babd2c77b8a0db9"},"cell_type":"code","source":"# pd.concat([df1['c'], df2['c']], axis=1, keys=['df1', 'df2'])\nsubmit_data_lgbm= pd.concat([test_df['item_id'], pd.DataFrame(y_test_pred_lgbm)], axis=1)","execution_count":249,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"961d5059b868a290fc05329511e5ea7ce203f6cc"},"cell_type":"code","source":"submit_data_lgbm.rename(columns={0:'deal_probability'}, inplace=True)","execution_count":250,"outputs":[]},{"metadata":{"collapsed":true,"_uuid":"93a95ca2ddf2a2c34509492487cb2cd04820de29","trusted":true},"cell_type":"code","source":"#path='D:\\\\personal\\\\kaggle\\\\Avito\\\\'\n#import os\n#submit_data.to_csv(os.path.join(path,r'submission.csv'))\n#submit_data.to_csv(path+\"submission.csv\")\n#submit_data.to_csv(\"D:\\\\personal\\\\kaggle\\\\Avito\\\\submission.csv\", index=False)\n\n#submit_data.to_csv(\"submission.csv\", index=False)\nsubmit_data_lgbm.to_csv(\"submission.csv\", index=False)","execution_count":251,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"b6dfe1d0cdf0c6b95823e758ed139535aa8e1ec5"},"cell_type":"code","source":"#submit_data_lgbm.head()","execution_count":252,"outputs":[]},{"metadata":{"_uuid":"365fa92745759d19bcf786e956d70acd19a58cae","trusted":true,"collapsed":true},"cell_type":"code","source":"#kaggle competitions submit -c avito-demand-prediction -f submission.csv -m \"Message\"\n\n#print('Saved file: ' + \"submission.csv\")","execution_count":253,"outputs":[]},{"metadata":{"_uuid":"00fdf95d3b4cbe5bef1eea1407a23ec4aca5a8a9","trusted":true,"collapsed":true},"cell_type":"code","source":"#ls","execution_count":254,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"file_extension":".py","mimetype":"text/x-python","version":"3.6.5","pygments_lexer":"ipython3","name":"python","codemirror_mode":{"version":3,"name":"ipython"},"nbconvert_exporter":"python"}},"nbformat":4,"nbformat_minor":1}