{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":31254,"databundleVersionId":3103714,"sourceType":"competition"}],"dockerImageVersionId":30918,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# import dask.dataframe as dd\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T05:26:35.91501Z","iopub.execute_input":"2025-03-09T05:26:35.915435Z","iopub.status.idle":"2025-03-09T05:26:37.335188Z","shell.execute_reply.started":"2025-03-09T05:26:35.915398Z","shell.execute_reply":"2025-03-09T05:26:37.334203Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\n\narticles = pd.read_csv(\"/kaggle/input/h-and-m-personalized-fashion-recommendations/articles.csv\")\ncustomers = pd.read_csv(\"/kaggle/input/h-and-m-personalized-fashion-recommendations/customers.csv\")\ntransactions = pd.read_csv(\"/kaggle/input/h-and-m-personalized-fashion-recommendations/transactions_train.csv\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T05:26:38.498172Z","iopub.execute_input":"2025-03-09T05:26:38.498662Z","iopub.status.idle":"2025-03-09T05:28:06.597282Z","shell.execute_reply.started":"2025-03-09T05:26:38.498629Z","shell.execute_reply":"2025-03-09T05:28:06.596407Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"articles.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:10.33104Z","iopub.execute_input":"2025-03-07T13:35:10.331606Z","iopub.status.idle":"2025-03-07T13:35:10.445062Z","shell.execute_reply.started":"2025-03-07T13:35:10.331519Z","shell.execute_reply":"2025-03-07T13:35:10.443771Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"articles.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:10.44671Z","iopub.execute_input":"2025-03-07T13:35:10.447123Z","iopub.status.idle":"2025-03-07T13:35:10.483504Z","shell.execute_reply.started":"2025-03-07T13:35:10.447081Z","shell.execute_reply":"2025-03-07T13:35:10.482193Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:10.484567Z","iopub.execute_input":"2025-03-07T13:35:10.484853Z","iopub.status.idle":"2025-03-07T13:35:10.814232Z","shell.execute_reply.started":"2025-03-07T13:35:10.484828Z","shell.execute_reply":"2025-03-07T13:35:10.812993Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:10.815334Z","iopub.execute_input":"2025-03-07T13:35:10.815717Z","iopub.status.idle":"2025-03-07T13:35:10.832737Z","shell.execute_reply.started":"2025-03-07T13:35:10.815672Z","shell.execute_reply":"2025-03-07T13:35:10.831685Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"transactions.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:10.834155Z","iopub.execute_input":"2025-03-07T13:35:10.834473Z","iopub.status.idle":"2025-03-07T13:35:10.856048Z","shell.execute_reply.started":"2025-03-07T13:35:10.834444Z","shell.execute_reply":"2025-03-07T13:35:10.854641Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Read structure of folder image ","metadata":{}},{"cell_type":"code","source":"import os\nimport cv2\nfrom PIL import Image\nimport matplotlib.pyplot as plt\nimport matplotlib.image as mpimg\n\nclass ImageFolder:\n    def __init__(self, path):\n        self.source = path\n        self.list_folder = sorted(os.listdir(path))\n        self.list_items = [[]]*(len(self.list_folder))\n        index = 0;\n        for i in self.list_folder:\n            self.list_items[index] = os.listdir(f\"/kaggle/input/h-and-m-personalized-fashion-recommendations/images/{i}\")\n            index += 1\n        pass\n\n    def getItemsInFolder(self, folder):\n        try:\n            index = int(folder) - int(self.list_folder[0])\n            if index < 0:\n                raise Exception(\"Negative index\")\n            t = self.list_items[index]\n        except Exception as e:\n            t = []\n            print(f'Error{e}')\n        finally:\n            return t\n        \n    def getNumberOfFolders(self):\n        return len(self.list_folder)\n        \n    def getItem(self, path):\n        folder = '0' + path[0:2]\n        image_path = os.path.join(self.source, folder,f\"0{path}.jpg\")\n        # print(image_path)\n        try:\n            img = mpimg.imread(image_path)\n            plt.imshow(img)\n            plt.axis('off')\n            plt.show()\n        except Exception as e:\n            print(e)\n        \n    def countNumberOfItemsNotHaveImage(self, data):\n        count = 0\n        for i in data:\n            folder = '0' + str(i)[0:2]\n            path = '0' + str(i) + '.jpg'\n            index = int(folder) - int(self.list_folder[0])\n            try:\n                if index < 0 or index >= len(self.list_folder) or path not in self.list_items[index] :\n                    count += 1\n            except:\n                count += 1\n        return count\n                \n        ","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T05:28:39.182013Z","iopub.execute_input":"2025-03-09T05:28:39.182336Z","iopub.status.idle":"2025-03-09T05:28:39.610133Z","shell.execute_reply.started":"2025-03-09T05:28:39.182309Z","shell.execute_reply":"2025-03-09T05:28:39.609417Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"image = ImageFolder('/kaggle/input/h-and-m-personalized-fashion-recommendations/images')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T05:28:41.927106Z","iopub.execute_input":"2025-03-09T05:28:41.927425Z","iopub.status.idle":"2025-03-09T05:28:47.99109Z","shell.execute_reply.started":"2025-03-09T05:28:41.927399Z","shell.execute_reply":"2025-03-09T05:28:47.990148Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Check items without images","metadata":{}},{"cell_type":"code","source":"print(f\"Number of items do not have image: {image.countNumberOfItemsNotHaveImage(articles['article_id'])}\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:12.800156Z","iopub.execute_input":"2025-03-07T13:35:12.800514Z","iopub.status.idle":"2025-03-07T13:35:15.471949Z","shell.execute_reply.started":"2025-03-07T13:35:12.80047Z","shell.execute_reply":"2025-03-07T13:35:15.470651Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Cleaning data","metadata":{}},{"cell_type":"markdown","source":"## 1. Check Dupicated & Check null value","metadata":{}},{"cell_type":"code","source":"def checkMissingData(data):\n    res = data.isnull().sum().sort_values(ascending=False);\n    res1 = (data.isnull().sum() / data.isnull().count()).sort_values(ascending=False);\n    return pd.concat([res, res1], axis=1, keys=['Total', 'Percent'])\n\ndef checkUniqueValues(data):\n    res = data.nunique()\n    res1 = data.count()\n    return pd.concat([res, res1], axis=1, keys=['Number of unique', 'Total'])\n    ","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:15.473252Z","iopub.execute_input":"2025-03-07T13:35:15.473751Z","iopub.status.idle":"2025-03-07T13:35:15.481335Z","shell.execute_reply.started":"2025-03-07T13:35:15.473699Z","shell.execute_reply":"2025-03-07T13:35:15.479648Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Missing values in each dataset","metadata":{}},{"cell_type":"code","source":"checkMissingData(articles)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:15.48258Z","iopub.execute_input":"2025-03-07T13:35:15.48296Z","iopub.status.idle":"2025-03-07T13:35:15.758709Z","shell.execute_reply.started":"2025-03-07T13:35:15.482925Z","shell.execute_reply":"2025-03-07T13:35:15.757334Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"checkMissingData(customers)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:15.760073Z","iopub.execute_input":"2025-03-07T13:35:15.76044Z","iopub.status.idle":"2025-03-07T13:35:16.758854Z","shell.execute_reply.started":"2025-03-07T13:35:15.76041Z","shell.execute_reply":"2025-03-07T13:35:16.757158Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Unique value in each dataset","metadata":{}},{"cell_type":"code","source":"checkUniqueValues(articles)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:16.760446Z","iopub.execute_input":"2025-03-07T13:35:16.760954Z","iopub.status.idle":"2025-03-07T13:35:16.983997Z","shell.execute_reply.started":"2025-03-07T13:35:16.760909Z","shell.execute_reply":"2025-03-07T13:35:16.982411Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"checkUniqueValues(customers)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:16.985343Z","iopub.execute_input":"2025-03-07T13:35:16.985703Z","iopub.status.idle":"2025-03-07T13:35:18.740044Z","shell.execute_reply.started":"2025-03-07T13:35:16.985668Z","shell.execute_reply":"2025-03-07T13:35:18.738988Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"checkUniqueValues(transactions)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:18.741111Z","iopub.execute_input":"2025-03-07T13:35:18.741458Z","iopub.status.idle":"2025-03-07T13:35:39.194191Z","shell.execute_reply.started":"2025-03-07T13:35:18.741425Z","shell.execute_reply":"2025-03-07T13:35:39.192533Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 2. Formating","metadata":{}},{"cell_type":"code","source":"articles.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:39.196258Z","iopub.execute_input":"2025-03-07T13:35:39.196714Z","iopub.status.idle":"2025-03-07T13:35:39.297523Z","shell.execute_reply.started":"2025-03-07T13:35:39.196666Z","shell.execute_reply":"2025-03-07T13:35:39.296267Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:39.298831Z","iopub.execute_input":"2025-03-07T13:35:39.299218Z","iopub.status.idle":"2025-03-07T13:35:39.684069Z","shell.execute_reply.started":"2025-03-07T13:35:39.299188Z","shell.execute_reply":"2025-03-07T13:35:39.682932Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers['age'] = customers['age'].astype('Int64')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:39.685088Z","iopub.execute_input":"2025-03-07T13:35:39.685379Z","iopub.status.idle":"2025-03-07T13:35:39.915636Z","shell.execute_reply.started":"2025-03-07T13:35:39.685351Z","shell.execute_reply":"2025-03-07T13:35:39.914525Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"transactions['t_dat'] = pd.to_datetime(transactions['t_dat'])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:39.916732Z","iopub.execute_input":"2025-03-07T13:35:39.917044Z","iopub.status.idle":"2025-03-07T13:35:44.087268Z","shell.execute_reply.started":"2025-03-07T13:35:39.917016Z","shell.execute_reply":"2025-03-07T13:35:44.08609Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"trans_sample = transactions.sample(1_000_000)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:44.088503Z","iopub.execute_input":"2025-03-07T13:35:44.088884Z","iopub.status.idle":"2025-03-07T13:35:46.485849Z","shell.execute_reply.started":"2025-03-07T13:35:44.088853Z","shell.execute_reply":"2025-03-07T13:35:46.484673Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"trans_sample","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:46.486994Z","iopub.execute_input":"2025-03-07T13:35:46.487372Z","iopub.status.idle":"2025-03-07T13:35:46.503704Z","shell.execute_reply.started":"2025-03-07T13:35:46.487324Z","shell.execute_reply":"2025-03-07T13:35:46.502491Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"trans_sample.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:46.510908Z","iopub.execute_input":"2025-03-07T13:35:46.511251Z","iopub.status.idle":"2025-03-07T13:35:46.799972Z","shell.execute_reply.started":"2025-03-07T13:35:46.511225Z","shell.execute_reply":"2025-03-07T13:35:46.798815Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Overview","metadata":{}},{"cell_type":"markdown","source":"## Articles dataset","metadata":{}},{"cell_type":"code","source":"articles.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:46.80311Z","iopub.execute_input":"2025-03-07T13:35:46.803563Z","iopub.status.idle":"2025-03-07T13:35:46.823593Z","shell.execute_reply.started":"2025-03-07T13:35:46.80351Z","shell.execute_reply":"2025-03-07T13:35:46.822133Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"articles.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:46.824915Z","iopub.execute_input":"2025-03-07T13:35:46.825198Z","iopub.status.idle":"2025-03-07T13:35:46.846394Z","shell.execute_reply.started":"2025-03-07T13:35:46.825174Z","shell.execute_reply":"2025-03-07T13:35:46.845089Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"product_group = articles.groupby('product_group_name')['product_code'].nunique().sort_values(ascending=False).reset_index();\nproduct_group.columns = ['Product Group', 'Count']\n\ngraphical_appearance = articles.groupby('graphical_appearance_name')['product_code'].nunique().sort_values(ascending=False).reset_index();\ngraphical_appearance.columns = ['Graphical appearance', 'Count']\n\ngarment_group = articles.groupby('garment_group_name')['product_code'].nunique().sort_values(ascending=False).reset_index();\ngarment_group.columns = ['Garment group', 'Count']\n\n\n\nfig, ax = plt.subplots(2, 2, figsize=(20,20))\nsns.barplot(data=product_group, y=product_group['Product Group'], x=product_group['Count'], ax=ax[0, 0]);\nsns.barplot(data=graphical_appearance, y=graphical_appearance['Graphical appearance'], x=graphical_appearance['Count'], ax=ax[0, 1]);\nsns.barplot(data=garment_group, y=garment_group['Garment group'], x=garment_group['Count'], ax=ax[1, 0]);\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:46.847744Z","iopub.execute_input":"2025-03-07T13:35:46.848079Z","iopub.status.idle":"2025-03-07T13:35:48.309427Z","shell.execute_reply.started":"2025-03-07T13:35:46.848053Z","shell.execute_reply":"2025-03-07T13:35:48.308148Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"articles.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:48.310651Z","iopub.execute_input":"2025-03-07T13:35:48.310945Z","iopub.status.idle":"2025-03-07T13:35:48.3185Z","shell.execute_reply.started":"2025-03-07T13:35:48.310921Z","shell.execute_reply":"2025-03-07T13:35:48.317209Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Customer dataset","metadata":{}},{"cell_type":"code","source":"customers.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:48.319732Z","iopub.execute_input":"2025-03-07T13:35:48.32006Z","iopub.status.idle":"2025-03-07T13:35:48.676041Z","shell.execute_reply.started":"2025-03-07T13:35:48.320032Z","shell.execute_reply":"2025-03-07T13:35:48.674779Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:48.677211Z","iopub.execute_input":"2025-03-07T13:35:48.677519Z","iopub.status.idle":"2025-03-07T13:35:48.69212Z","shell.execute_reply.started":"2025-03-07T13:35:48.67749Z","shell.execute_reply":"2025-03-07T13:35:48.69091Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"age_customer = customers.groupby('age').size().reset_index()\nage_customer.columns = ['Age', 'Count']\nage_customer","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:48.693257Z","iopub.execute_input":"2025-03-07T13:35:48.693576Z","iopub.status.idle":"2025-03-07T13:35:48.743208Z","shell.execute_reply.started":"2025-03-07T13:35:48.693521Z","shell.execute_reply":"2025-03-07T13:35:48.742169Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"age_customer.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:48.744382Z","iopub.execute_input":"2025-03-07T13:35:48.744698Z","iopub.status.idle":"2025-03-07T13:35:48.751207Z","shell.execute_reply.started":"2025-03-07T13:35:48.744671Z","shell.execute_reply":"2025-03-07T13:35:48.749944Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers['age'].isnull().sum() / customers['age'].count() * 100","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:48.752405Z","iopub.execute_input":"2025-03-07T13:35:48.75279Z","iopub.status.idle":"2025-03-07T13:35:48.784841Z","shell.execute_reply.started":"2025-03-07T13:35:48.752759Z","shell.execute_reply":"2025-03-07T13:35:48.783595Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Number of customers do not provide age is about 1.17%","metadata":{}},{"cell_type":"code","source":"customers['age'] = customers['age'].fillna(customers['age'].mean())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T08:27:13.807705Z","iopub.execute_input":"2025-03-09T08:27:13.808137Z","iopub.status.idle":"2025-03-09T08:27:13.842014Z","shell.execute_reply.started":"2025-03-09T08:27:13.808106Z","shell.execute_reply":"2025-03-09T08:27:13.841224Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers['age'].describe().astype('int')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:48.786297Z","iopub.execute_input":"2025-03-07T13:35:48.786716Z","iopub.status.idle":"2025-03-07T13:35:48.890746Z","shell.execute_reply.started":"2025-03-07T13:35:48.786684Z","shell.execute_reply":"2025-03-07T13:35:48.889644Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sns.histplot(data=age_customer, x='Age', weights='Count', bins=age_customer.shape[0])\nplt.xticks(range(10,90,10))\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:48.891994Z","iopub.execute_input":"2025-03-07T13:35:48.892408Z","iopub.status.idle":"2025-03-07T13:35:49.212418Z","shell.execute_reply.started":"2025-03-07T13:35:48.892354Z","shell.execute_reply":"2025-03-07T13:35:49.210933Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.head(5)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:49.213817Z","iopub.execute_input":"2025-03-07T13:35:49.214151Z","iopub.status.idle":"2025-03-07T13:35:49.231818Z","shell.execute_reply.started":"2025-03-07T13:35:49.214119Z","shell.execute_reply":"2025-03-07T13:35:49.230554Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers['Active'].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:49.233456Z","iopub.execute_input":"2025-03-07T13:35:49.233866Z","iopub.status.idle":"2025-03-07T13:35:49.275739Z","shell.execute_reply.started":"2025-03-07T13:35:49.233832Z","shell.execute_reply":"2025-03-07T13:35:49.274422Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Update active status","metadata":{}},{"cell_type":"code","source":"customers['club_member_status'].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:49.276907Z","iopub.execute_input":"2025-03-07T13:35:49.277201Z","iopub.status.idle":"2025-03-07T13:35:49.335236Z","shell.execute_reply.started":"2025-03-07T13:35:49.277175Z","shell.execute_reply":"2025-03-07T13:35:49.333848Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.loc[(customers['Active'].isna()) & (customers['club_member_status'] == 'ACTIVE'), 'Active'] = 1\ncustomers.loc[(customers['Active'].isna()) & (customers['club_member_status'] != 'ACTIVE'), 'Active'] = 0","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T08:27:23.131389Z","iopub.execute_input":"2025-03-09T08:27:23.131748Z","iopub.status.idle":"2025-03-09T08:27:23.379684Z","shell.execute_reply.started":"2025-03-09T08:27:23.131696Z","shell.execute_reply":"2025-03-09T08:27:23.378811Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.loc[(customers['club_member_status'].isna()) & (customers['Active'] == 1), 'club_member_status'] = 'ACTIVE'\ncustomers.loc[(customers['club_member_status'].isna()) & (customers['Active'] == 0), 'club_member_status'] = 'NONE'","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T08:27:25.10986Z","iopub.execute_input":"2025-03-09T08:27:25.11018Z","iopub.status.idle":"2025-03-09T08:27:25.258558Z","shell.execute_reply.started":"2025-03-09T08:27:25.110154Z","shell.execute_reply":"2025-03-09T08:27:25.257807Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"check whether values in both 2 rows are NaN","metadata":{}},{"cell_type":"code","source":"customers.loc[(customers['Active'].isna())]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:49.778339Z","iopub.execute_input":"2025-03-07T13:35:49.778801Z","iopub.status.idle":"2025-03-07T13:35:49.794798Z","shell.execute_reply.started":"2025-03-07T13:35:49.778757Z","shell.execute_reply":"2025-03-07T13:35:49.793538Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.loc[(customers['club_member_status'].isna())]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:49.796173Z","iopub.execute_input":"2025-03-07T13:35:49.796594Z","iopub.status.idle":"2025-03-07T13:35:49.868453Z","shell.execute_reply.started":"2025-03-07T13:35:49.79653Z","shell.execute_reply":"2025-03-07T13:35:49.867421Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Update FN status","metadata":{}},{"cell_type":"code","source":"customers['FN'].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:49.869644Z","iopub.execute_input":"2025-03-07T13:35:49.870052Z","iopub.status.idle":"2025-03-07T13:35:49.903724Z","shell.execute_reply.started":"2025-03-07T13:35:49.870006Z","shell.execute_reply":"2025-03-07T13:35:49.902771Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers['fashion_news_frequency'].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:49.904775Z","iopub.execute_input":"2025-03-07T13:35:49.905131Z","iopub.status.idle":"2025-03-07T13:35:49.962417Z","shell.execute_reply.started":"2025-03-07T13:35:49.905103Z","shell.execute_reply":"2025-03-07T13:35:49.961382Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.loc[(customers['FN'].isna()) & (customers['fashion_news_frequency'].notna()) & (customers['fashion_news_frequency'] != 'NONE'), 'FN'] = 1\ncustomers.loc[(customers['FN'].isna()) & (customers['fashion_news_frequency'] == 'NONE'), 'FN'] = 0","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T08:27:30.26643Z","iopub.execute_input":"2025-03-09T08:27:30.26682Z","iopub.status.idle":"2025-03-09T08:27:30.582772Z","shell.execute_reply.started":"2025-03-09T08:27:30.266788Z","shell.execute_reply":"2025-03-09T08:27:30.581976Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.loc[(customers['fashion_news_frequency'].isna()) & (customers['FN'] == 0), 'fashion_news_frequency'] = 'NONE'\ncustomers.loc[(customers['fashion_news_frequency'].isna()) & (customers['FN'] == 1), 'fashion_news_frequency'] = 'Regularly'","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T08:27:32.382577Z","iopub.execute_input":"2025-03-09T08:27:32.382906Z","iopub.status.idle":"2025-03-09T08:27:32.526509Z","shell.execute_reply.started":"2025-03-09T08:27:32.382881Z","shell.execute_reply":"2025-03-09T08:27:32.525494Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.loc[(customers['FN'].isna()) & (customers['fashion_news_frequency'].notna())]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:50.458078Z","iopub.execute_input":"2025-03-07T13:35:50.458448Z","iopub.status.idle":"2025-03-07T13:35:50.536131Z","shell.execute_reply.started":"2025-03-07T13:35:50.458403Z","shell.execute_reply":"2025-03-07T13:35:50.535069Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.loc[(customers['fashion_news_frequency'].isna()) & (customers['FN'].notna())]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:50.537302Z","iopub.execute_input":"2025-03-07T13:35:50.537648Z","iopub.status.idle":"2025-03-07T13:35:50.614204Z","shell.execute_reply.started":"2025-03-07T13:35:50.53762Z","shell.execute_reply":"2025-03-07T13:35:50.613005Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.loc[(customers['FN'].isna())]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:50.615501Z","iopub.execute_input":"2025-03-07T13:35:50.61594Z","iopub.status.idle":"2025-03-07T13:35:50.64897Z","shell.execute_reply.started":"2025-03-07T13:35:50.615897Z","shell.execute_reply":"2025-03-07T13:35:50.648031Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.loc[(customers['fashion_news_frequency'].isna())]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:50.65006Z","iopub.execute_input":"2025-03-07T13:35:50.65034Z","iopub.status.idle":"2025-03-07T13:35:50.742815Z","shell.execute_reply.started":"2025-03-07T13:35:50.650317Z","shell.execute_reply":"2025-03-07T13:35:50.741664Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(f\"Percent of customers being not indentified FN status is {customers.loc[(customers['fashion_news_frequency'].isna())].shape[0] / customers.shape[0] * 100} %\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:50.744042Z","iopub.execute_input":"2025-03-07T13:35:50.7444Z","iopub.status.idle":"2025-03-07T13:35:50.826102Z","shell.execute_reply.started":"2025-03-07T13:35:50.744371Z","shell.execute_reply":"2025-03-07T13:35:50.824942Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers['FN'] = customers['FN'].fillna(0)\ncustomers['fashion_news_frequency'] = customers['fashion_news_frequency'].fillna('NONE')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T08:27:41.280443Z","iopub.execute_input":"2025-03-09T08:27:41.280839Z","iopub.status.idle":"2025-03-09T08:27:41.380858Z","shell.execute_reply.started":"2025-03-09T08:27:41.280803Z","shell.execute_reply":"2025-03-09T08:27:41.37981Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.loc[(customers['FN'] == 0) & (customers['fashion_news_frequency'] != 'NONE')]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:50.953766Z","iopub.execute_input":"2025-03-07T13:35:50.954208Z","iopub.status.idle":"2025-03-07T13:35:51.119847Z","shell.execute_reply.started":"2025-03-07T13:35:50.954158Z","shell.execute_reply":"2025-03-07T13:35:51.11879Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.loc[(customers['FN'] == 1) & (customers['fashion_news_frequency'] == 'NONE')]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:51.121212Z","iopub.execute_input":"2025-03-07T13:35:51.121658Z","iopub.status.idle":"2025-03-07T13:35:51.259393Z","shell.execute_reply.started":"2025-03-07T13:35:51.121611Z","shell.execute_reply":"2025-03-07T13:35:51.257841Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.loc[(customers['Active'] == 0) & (customers['club_member_status'] != 'NONE')]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:51.26082Z","iopub.execute_input":"2025-03-07T13:35:51.261146Z","iopub.status.idle":"2025-03-07T13:35:51.404275Z","shell.execute_reply.started":"2025-03-07T13:35:51.261117Z","shell.execute_reply":"2025-03-07T13:35:51.403168Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.loc[(customers['Active'] == 1) & (customers['club_member_status'] == 'NONE')]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:51.405589Z","iopub.execute_input":"2025-03-07T13:35:51.4059Z","iopub.status.idle":"2025-03-07T13:35:51.522847Z","shell.execute_reply.started":"2025-03-07T13:35:51.405872Z","shell.execute_reply":"2025-03-07T13:35:51.521811Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers['Active'] = customers['Active'].astype('int')\ncustomers['FN'] = customers['FN'].astype('int')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:51.524043Z","iopub.execute_input":"2025-03-07T13:35:51.524323Z","iopub.status.idle":"2025-03-07T13:35:51.560528Z","shell.execute_reply.started":"2025-03-07T13:35:51.5243Z","shell.execute_reply":"2025-03-07T13:35:51.559369Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig, ax = plt.subplots(1, 2, figsize=(15, 5))\n\nactive = customers.groupby('Active').size().reset_index()\nactive.columns = ['Status', 'Count']\nactive['Status'] = active['Status'].map({0 : \"Not active\", 1 : \"Active\"})\nactive\nsns.barplot(data=active, x=active['Status'], y=active['Count'], ax=ax[0])\nax[0].set_title('Active')\n\nfn = customers.groupby('FN').size().reset_index()\nfn.columns = ['Status', 'Count']\nfn['Status'] = fn['Status'].map({0 : \"Not active\", 1 : \"Active\"})\nfn\nsns.barplot(data=fn, x=fn['Status'], y=fn['Count'], ax=ax[1])\nax[1].set_title('Frequent News')\n# plt.show()\n# plt.show()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:51.56163Z","iopub.execute_input":"2025-03-07T13:35:51.562011Z","iopub.status.idle":"2025-03-07T13:35:51.966637Z","shell.execute_reply.started":"2025-03-07T13:35:51.561971Z","shell.execute_reply":"2025-03-07T13:35:51.965469Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"active_fn = customers.pivot_table(index=customers['Active'], columns=customers['FN'], aggfunc='size', fill_value=(0))\nactive_fn.columns = active_fn.columns.map({0 : \"No\", 1 : \"Yes\"})\nactive_fn.index = active_fn.index.map({0 : \"Inactive\", 1 : \"Active\"})\nactive_fn.plot(kind='barh', stacked=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:51.96779Z","iopub.execute_input":"2025-03-07T13:35:51.968163Z","iopub.status.idle":"2025-03-07T13:35:53.089962Z","shell.execute_reply.started":"2025-03-07T13:35:51.968107Z","shell.execute_reply":"2025-03-07T13:35:53.08881Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"club = customers.groupby('club_member_status').size().reset_index()\nclub.columns = ['Status', 'Count']\nclub['Percent'] = club['Count'] / customers.shape[0]\nclub['Count'] = club['Count'] / 1000\nsns.barplot(data=club, x=club['Status'], y=club['Count'])\nplt.ylabel('Number of customer (x1000)')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:53.091067Z","iopub.execute_input":"2025-03-07T13:35:53.091353Z","iopub.status.idle":"2025-03-07T13:35:53.349954Z","shell.execute_reply.started":"2025-03-07T13:35:53.091327Z","shell.execute_reply":"2025-03-07T13:35:53.348298Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers['fashion_news_frequency'].unique()\nfashion_news = customers.groupby('fashion_news_frequency').size().reset_index()\nfashion_news.columns = ['Status', 'Count']\nsns.barplot(data=fashion_news, x=fashion_news['Status'], y=fashion_news['Count'])\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:53.350991Z","iopub.execute_input":"2025-03-07T13:35:53.351417Z","iopub.status.idle":"2025-03-07T13:35:53.649088Z","shell.execute_reply.started":"2025-03-07T13:35:53.351383Z","shell.execute_reply":"2025-03-07T13:35:53.647971Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pivot = customers.pivot_table(index=customers['club_member_status'], columns=customers['fashion_news_frequency'], aggfunc='size')\n# pivot.index = ['No', 'Yes']\npivot.plot(kind='barh', stacked=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:53.650315Z","iopub.execute_input":"2025-03-07T13:35:53.650662Z","iopub.status.idle":"2025-03-07T13:35:54.863741Z","shell.execute_reply.started":"2025-03-07T13:35:53.65063Z","shell.execute_reply":"2025-03-07T13:35:54.862677Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:54.864792Z","iopub.execute_input":"2025-03-07T13:35:54.865063Z","iopub.status.idle":"2025-03-07T13:35:54.879848Z","shell.execute_reply.started":"2025-03-07T13:35:54.86504Z","shell.execute_reply":"2025-03-07T13:35:54.87866Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Analyse ralationship between member club and fashions new","metadata":{}},{"cell_type":"code","source":"bin = [0, 25, 35, 45, 55, 65, float('inf')]\nlabel = ['0-25', '26-35', '36-45', '46-55', '56-65', '66+']\ncustomers['range_of_age'] = pd.cut(customers['age'], bins=bin, labels=label, right=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:54.88095Z","iopub.execute_input":"2025-03-07T13:35:54.881334Z","iopub.status.idle":"2025-03-07T13:35:54.957221Z","shell.execute_reply.started":"2025-03-07T13:35:54.881303Z","shell.execute_reply":"2025-03-07T13:35:54.955931Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:54.958505Z","iopub.execute_input":"2025-03-07T13:35:54.958937Z","iopub.status.idle":"2025-03-07T13:35:54.976759Z","shell.execute_reply.started":"2025-03-07T13:35:54.958906Z","shell.execute_reply":"2025-03-07T13:35:54.975407Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig, ax = plt.subplots(1, 2, figsize=(15,8))\npivot_1 = customers.pivot_table(index='range_of_age', columns='club_member_status', aggfunc='size')\npivot_1\npivot_1.plot(kind='barh', stacked=True, ax=ax[0])\n\npivot_2 = customers.pivot_table(index='range_of_age', columns='fashion_news_frequency', aggfunc='size')\npivot_2\npivot_2.plot(kind='barh', stacked=True, ax=ax[1])\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:54.978105Z","iopub.execute_input":"2025-03-07T13:35:54.978536Z","iopub.status.idle":"2025-03-07T13:35:55.787718Z","shell.execute_reply.started":"2025-03-07T13:35:54.978502Z","shell.execute_reply":"2025-03-07T13:35:55.786441Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"t = customers.groupby('range_of_age').size()\nplt.pie(t, labels = t.index, autopct='%.0f%%')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:55.788897Z","iopub.execute_input":"2025-03-07T13:35:55.7892Z","iopub.status.idle":"2025-03-07T13:35:55.945629Z","shell.execute_reply.started":"2025-03-07T13:35:55.789172Z","shell.execute_reply":"2025-03-07T13:35:55.944372Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Summary\n- Almost costumers join club member do not sign up Fashions news\n- Most of customers at the age between 20 to 35\n- ","metadata":{}},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Transaction dataset","metadata":{}},{"cell_type":"code","source":"cus = customers[['customer_id', 'range_of_age', 'Active', 'FN']]\ncus","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:55.946837Z","iopub.execute_input":"2025-03-07T13:35:55.947156Z","iopub.status.idle":"2025-03-07T13:35:56.003579Z","shell.execute_reply.started":"2025-03-07T13:35:55.94712Z","shell.execute_reply":"2025-03-07T13:35:56.002205Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"articles.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:56.013177Z","iopub.execute_input":"2025-03-07T13:35:56.01365Z","iopub.status.idle":"2025-03-07T13:35:56.120311Z","shell.execute_reply.started":"2025-03-07T13:35:56.013616Z","shell.execute_reply":"2025-03-07T13:35:56.119065Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"art = articles[['article_id', 'product_group_name', 'department_name', 'index_name', 'section_name', 'garment_group_name']]\nart","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:56.123594Z","iopub.execute_input":"2025-03-07T13:35:56.123952Z","iopub.status.idle":"2025-03-07T13:35:56.14587Z","shell.execute_reply.started":"2025-03-07T13:35:56.123922Z","shell.execute_reply":"2025-03-07T13:35:56.14469Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"transactions.sort_values('t_dat')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:56.147326Z","iopub.execute_input":"2025-03-07T13:35:56.147812Z","iopub.status.idle":"2025-03-07T13:35:59.932279Z","shell.execute_reply.started":"2025-03-07T13:35:56.147715Z","shell.execute_reply":"2025-03-07T13:35:59.931119Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"nearest_trans = transactions.tail(1000000)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:59.933389Z","iopub.execute_input":"2025-03-07T13:35:59.93372Z","iopub.status.idle":"2025-03-07T13:35:59.938875Z","shell.execute_reply.started":"2025-03-07T13:35:59.933691Z","shell.execute_reply":"2025-03-07T13:35:59.937591Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"nearest_trans","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:59.940104Z","iopub.execute_input":"2025-03-07T13:35:59.940767Z","iopub.status.idle":"2025-03-07T13:35:59.973697Z","shell.execute_reply.started":"2025-03-07T13:35:59.940731Z","shell.execute_reply":"2025-03-07T13:35:59.97203Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.dates as mdates\ncount_date = nearest_trans.groupby([\"t_dat\", \"sales_channel_id\"]).size().reset_index()\ncount_date.columns = ['date', 'channel','count']\ncount_date.sort_values(['date', 'channel'])\n\nplt.figure(figsize=(8,8))\nsns.lineplot(data=count_date, x=count_date['date'], y=count_date['count'], hue=count_date['channel'], palette=[\"blue\", \"orange\"])\n\nax = plt.gca()\nax.xaxis.set_major_locator(mdates.DayLocator(interval=2))\nax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d'))\nplt.xticks(rotation=45)\n\n# plt.xticks(rotation=90)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:35:59.975841Z","iopub.execute_input":"2025-03-07T13:35:59.976731Z","iopub.status.idle":"2025-03-07T13:36:00.506718Z","shell.execute_reply.started":"2025-03-07T13:35:59.976518Z","shell.execute_reply":"2025-03-07T13:36:00.50528Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"merge = pd.merge(nearest_trans, cus, on='customer_id', how='inner')\nmerge","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:36:00.508012Z","iopub.execute_input":"2025-03-07T13:36:00.508654Z","iopub.status.idle":"2025-03-07T13:36:01.679091Z","shell.execute_reply.started":"2025-03-07T13:36:00.508602Z","shell.execute_reply":"2025-03-07T13:36:01.677936Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"\ncount_age = merge.groupby('range_of_age').size().reset_index()\ncount_age.columns = ['Age', 'Count']\nsns.barplot(data=count_age, x='Age', y='Count')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:36:01.680265Z","iopub.execute_input":"2025-03-07T13:36:01.680693Z","iopub.status.idle":"2025-03-07T13:36:01.894859Z","shell.execute_reply.started":"2025-03-07T13:36:01.680651Z","shell.execute_reply":"2025-03-07T13:36:01.893635Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig, ax = plt.subplots(1, 2, figsize=(15, 5))\npivot1 = merge.pivot_table(index='range_of_age', columns='Active', aggfunc='size')\npivot1.plot(kind='barh', stacked=True, ax=ax[0])\nax[0].set_title('Relationship between Club membership VS Transactions')\npivot2 = merge.pivot_table(index='range_of_age', columns='FN', aggfunc='size')\npivot2.plot(kind='barh', stacked=True, ax=ax[1])\nax[1].set_title('Relationship between FN VS Transactions')\n\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:36:01.896278Z","iopub.execute_input":"2025-03-07T13:36:01.896715Z","iopub.status.idle":"2025-03-07T13:36:02.588112Z","shell.execute_reply.started":"2025-03-07T13:36:01.896672Z","shell.execute_reply":"2025-03-07T13:36:02.587007Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"merge = pd.merge(nearest_trans, art, on='article_id', how='inner')\nmerge","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:36:02.589301Z","iopub.execute_input":"2025-03-07T13:36:02.589621Z","iopub.status.idle":"2025-03-07T13:36:02.912731Z","shell.execute_reply.started":"2025-03-07T13:36:02.589592Z","shell.execute_reply":"2025-03-07T13:36:02.911661Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"target_col = ['product_group_name', 'index_name', 'section_name', 'garment_group_name']","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:36:02.913964Z","iopub.execute_input":"2025-03-07T13:36:02.91448Z","iopub.status.idle":"2025-03-07T13:36:02.919298Z","shell.execute_reply.started":"2025-03-07T13:36:02.914438Z","shell.execute_reply":"2025-03-07T13:36:02.9181Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig, ax = plt.subplots(2, 2, figsize=(20,20))\n\nindex = 0;\nfor i in target_col:\n    t = merge.groupby(i).size().nlargest(10).reset_index()\n    t.columns = [i, 'Count']\n    sns.barplot(data=t, y=i, x='Count', ax=ax[index // 2, index % 2])\n    ax[index // 2, index % 2].set_xlabel(\"\")\n    ax[index // 2, index % 2].set_ylabel(\"\")\n    ax[index // 2, index % 2].set_title(i)\n    index += 1\n# plt.show()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:36:02.920415Z","iopub.execute_input":"2025-03-07T13:36:02.920828Z","iopub.status.idle":"2025-03-07T13:36:04.372837Z","shell.execute_reply.started":"2025-03-07T13:36:02.92079Z","shell.execute_reply":"2025-03-07T13:36:04.371498Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"merge = pd.merge(nearest_trans, cus, on='customer_id', how='inner')\nmerge = pd.merge(merge, art, on='article_id', how='inner')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:36:04.37403Z","iopub.execute_input":"2025-03-07T13:36:04.374368Z","iopub.status.idle":"2025-03-07T13:36:05.653443Z","shell.execute_reply.started":"2025-03-07T13:36:04.374339Z","shell.execute_reply":"2025-03-07T13:36:05.652373Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"merge","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:36:05.654524Z","iopub.execute_input":"2025-03-07T13:36:05.6549Z","iopub.status.idle":"2025-03-07T13:36:05.673124Z","shell.execute_reply.started":"2025-03-07T13:36:05.654855Z","shell.execute_reply":"2025-03-07T13:36:05.672188Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pivot = merge.pivot_table(index='section_name', columns='range_of_age', values='price', aggfunc='sum')\nplt.figure()\npivot.plot(kind='barh', stacked=True, figsize=(15,15))\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:36:06.932851Z","iopub.execute_input":"2025-03-07T13:36:06.933139Z","iopub.status.idle":"2025-03-07T13:36:08.343258Z","shell.execute_reply.started":"2025-03-07T13:36:06.933114Z","shell.execute_reply":"2025-03-07T13:36:08.341983Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"group = merge.groupby('range_of_age')['price'].sum()\nplt.pie(group, labels = group.index, autopct='%.0f%%')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:36:08.344577Z","iopub.execute_input":"2025-03-07T13:36:08.345027Z","iopub.status.idle":"2025-03-07T13:36:08.482133Z","shell.execute_reply.started":"2025-03-07T13:36:08.344985Z","shell.execute_reply":"2025-03-07T13:36:08.480855Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"merge.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:38:33.656328Z","iopub.execute_input":"2025-03-07T13:38:33.656804Z","iopub.status.idle":"2025-03-07T13:38:34.011626Z","shell.execute_reply.started":"2025-03-07T13:38:33.656764Z","shell.execute_reply":"2025-03-07T13:38:34.010197Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"articles.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:42:21.079948Z","iopub.execute_input":"2025-03-07T13:42:21.080646Z","iopub.status.idle":"2025-03-07T13:42:21.191863Z","shell.execute_reply.started":"2025-03-07T13:42:21.080583Z","shell.execute_reply":"2025-03-07T13:42:21.190676Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"art = articles.loc[:,['article_id', 'product_code']]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:43:33.936024Z","iopub.execute_input":"2025-03-07T13:43:33.936413Z","iopub.status.idle":"2025-03-07T13:43:33.942438Z","shell.execute_reply.started":"2025-03-07T13:43:33.93638Z","shell.execute_reply":"2025-03-07T13:43:33.941126Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"art","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:43:35.331956Z","iopub.execute_input":"2025-03-07T13:43:35.332354Z","iopub.status.idle":"2025-03-07T13:43:35.345992Z","shell.execute_reply.started":"2025-03-07T13:43:35.332315Z","shell.execute_reply":"2025-03-07T13:43:35.344114Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"merge = pd.merge(nearest_trans, art, on='article_id', how='inner')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:43:53.420874Z","iopub.execute_input":"2025-03-07T13:43:53.421232Z","iopub.status.idle":"2025-03-07T13:43:53.554952Z","shell.execute_reply.started":"2025-03-07T13:43:53.421203Z","shell.execute_reply":"2025-03-07T13:43:53.553513Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"merge","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:43:58.61731Z","iopub.execute_input":"2025-03-07T13:43:58.617729Z","iopub.status.idle":"2025-03-07T13:43:58.632122Z","shell.execute_reply.started":"2025-03-07T13:43:58.617693Z","shell.execute_reply":"2025-03-07T13:43:58.630705Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"product = merge.groupby('product_code').size().sort_values(ascending=False).nlargest(20).reset_index()\nproduct.columns = ['product_code', 'count']","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:58:01.995356Z","iopub.execute_input":"2025-03-07T13:58:01.995804Z","iopub.status.idle":"2025-03-07T13:58:02.035382Z","shell.execute_reply.started":"2025-03-07T13:58:01.995772Z","shell.execute_reply":"2025-03-07T13:58:02.033853Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"img_product = pd.merge(product, art, on='product_code', how='inner')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:58:03.774186Z","iopub.execute_input":"2025-03-07T13:58:03.774668Z","iopub.status.idle":"2025-03-07T13:58:03.788228Z","shell.execute_reply.started":"2025-03-07T13:58:03.774632Z","shell.execute_reply":"2025-03-07T13:58:03.787125Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"img_product","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:58:05.541502Z","iopub.execute_input":"2025-03-07T13:58:05.541899Z","iopub.status.idle":"2025-03-07T13:58:05.554912Z","shell.execute_reply.started":"2025-03-07T13:58:05.541871Z","shell.execute_reply":"2025-03-07T13:58:05.553634Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"img_product[['product_code', 'article_id']]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T13:58:42.741962Z","iopub.execute_input":"2025-03-07T13:58:42.742507Z","iopub.status.idle":"2025-03-07T13:58:42.754179Z","shell.execute_reply.started":"2025-03-07T13:58:42.742469Z","shell.execute_reply":"2025-03-07T13:58:42.752991Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Use model","metadata":{}},{"cell_type":"markdown","source":"## ALS model","metadata":{}},{"cell_type":"code","source":"cus_uni = customers['customer_id'].unique()\ncus_uni","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T05:28:58.376674Z","iopub.execute_input":"2025-03-09T05:28:58.377055Z","iopub.status.idle":"2025-03-09T05:28:58.854985Z","shell.execute_reply.started":"2025-03-09T05:28:58.377025Z","shell.execute_reply":"2025-03-09T05:28:58.854202Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"articles\ncustomers\ntransactions\npass","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T05:31:20.427498Z","iopub.execute_input":"2025-03-09T05:31:20.429089Z","iopub.status.idle":"2025-03-09T05:31:20.43587Z","shell.execute_reply.started":"2025-03-09T05:31:20.429022Z","shell.execute_reply":"2025-03-09T05:31:20.434645Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"art = articles.loc[:, 'article_id']\ncus = customers.loc[:, 'customer_id']","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"cus_to_idx = {v: k for k, v in enumerate(cus_uni)}","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T05:29:11.406975Z","iopub.execute_input":"2025-03-09T05:29:11.40731Z","iopub.status.idle":"2025-03-09T05:29:11.891583Z","shell.execute_reply.started":"2025-03-09T05:29:11.407281Z","shell.execute_reply":"2025-03-09T05:29:11.89084Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"transactions.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T05:52:28.34221Z","iopub.execute_input":"2025-03-09T05:52:28.34456Z","iopub.status.idle":"2025-03-09T05:52:28.35122Z","shell.execute_reply.started":"2025-03-09T05:52:28.344519Z","shell.execute_reply":"2025-03-09T05:52:28.350458Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip install implicit","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T05:51:27.342851Z","iopub.execute_input":"2025-03-09T05:51:27.343157Z","iopub.status.idle":"2025-03-09T05:51:34.598897Z","shell.execute_reply.started":"2025-03-09T05:51:27.343133Z","shell.execute_reply":"2025-03-09T05:51:34.597989Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nfrom scipy.sparse import csr_matrix\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T05:51:44.523013Z","iopub.execute_input":"2025-03-09T05:51:44.523367Z","iopub.status.idle":"2025-03-09T05:51:44.579597Z","shell.execute_reply.started":"2025-03-09T05:51:44.523339Z","shell.execute_reply":"2025-03-09T05:51:44.578622Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"interaction_df = transactions.groupby(['customer_id', 'article_id']).size().reset_index(name='count')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T05:53:48.698679Z","iopub.execute_input":"2025-03-09T05:53:48.699025Z","iopub.status.idle":"2025-03-09T05:54:14.870919Z","shell.execute_reply.started":"2025-03-09T05:53:48.699Z","shell.execute_reply":"2025-03-09T05:54:14.869899Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"interaction_df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T05:54:18.251967Z","iopub.execute_input":"2025-03-09T05:54:18.252319Z","iopub.status.idle":"2025-03-09T05:54:18.260604Z","shell.execute_reply.started":"2025-03-09T05:54:18.252288Z","shell.execute_reply":"2025-03-09T05:54:18.259806Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"cus_id = np.sort(interaction_df['customer_id'].unique())\nart_id = np.sort(interaction_df['article_id'].unique())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T05:56:25.569777Z","iopub.execute_input":"2025-03-09T05:56:25.570093Z","iopub.status.idle":"2025-03-09T05:56:31.309251Z","shell.execute_reply.started":"2025-03-09T05:56:25.57007Z","shell.execute_reply":"2025-03-09T05:56:31.308496Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"cus_id_to_indx = {cid: idx for idx, cid in enumerate(cus_id)}\nart_id_to_indx = {aid: idx for idx, aid in enumerate(art_id)}","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T06:00:07.490896Z","iopub.execute_input":"2025-03-09T06:00:07.491228Z","iopub.status.idle":"2025-03-09T06:00:08.202136Z","shell.execute_reply.started":"2025-03-09T06:00:07.491202Z","shell.execute_reply":"2025-03-09T06:00:08.201303Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"len(art_id_to_indx)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T06:52:06.224077Z","iopub.execute_input":"2025-03-09T06:52:06.224399Z","iopub.status.idle":"2025-03-09T06:52:06.229736Z","shell.execute_reply.started":"2025-03-09T06:52:06.224374Z","shell.execute_reply":"2025-03-09T06:52:06.228938Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"interaction_df['customer_id'] = interaction_df['customer_id'].map(cus_id_to_indx)\ninteraction_df['article_id'] = interaction_df['article_id'].map(art_id_to_indx)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T06:00:53.551269Z","iopub.execute_input":"2025-03-09T06:00:53.551621Z","iopub.status.idle":"2025-03-09T06:00:57.582376Z","shell.execute_reply.started":"2025-03-09T06:00:53.551594Z","shell.execute_reply":"2025-03-09T06:00:57.581577Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"interaction_df['article_id'].nlargest(1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T06:52:44.223827Z","iopub.execute_input":"2025-03-09T06:52:44.224171Z","iopub.status.idle":"2025-03-09T06:52:44.72648Z","shell.execute_reply.started":"2025-03-09T06:52:44.224146Z","shell.execute_reply":"2025-03-09T06:52:44.725627Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ncus = len(cus_id)\nnart = len(art_id)\ndata = interaction_df['count'].values\nrows = interaction_df['customer_id'].values\ncols = interaction_df['article_id'].values","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T06:04:10.528552Z","iopub.execute_input":"2025-03-09T06:04:10.52894Z","iopub.status.idle":"2025-03-09T06:04:10.533388Z","shell.execute_reply.started":"2025-03-09T06:04:10.528909Z","shell.execute_reply":"2025-03-09T06:04:10.532444Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"cus_art_matrix = csr_matrix((data, (rows, cols)), shape=(ncus, nart))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T06:04:26.026683Z","iopub.execute_input":"2025-03-09T06:04:26.027054Z","iopub.status.idle":"2025-03-09T06:04:26.559633Z","shell.execute_reply.started":"2025-03-09T06:04:26.027024Z","shell.execute_reply":"2025-03-09T06:04:26.558895Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"art_cus_matrix = cus_art_matrix.T","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T06:04:40.863952Z","iopub.execute_input":"2025-03-09T06:04:40.864327Z","iopub.status.idle":"2025-03-09T06:04:40.868352Z","shell.execute_reply.started":"2025-03-09T06:04:40.864293Z","shell.execute_reply":"2025-03-09T06:04:40.867354Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"alpha = 15\nart_user_conf = (art_cus_matrix * alpha).astype('double')\nart_user_conf","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T06:05:41.905906Z","iopub.execute_input":"2025-03-09T06:05:41.906223Z","iopub.status.idle":"2025-03-09T06:05:42.203789Z","shell.execute_reply.started":"2025-03-09T06:05:41.906198Z","shell.execute_reply":"2025-03-09T06:05:42.202966Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model = implicit.als.AlternatingLeastSquares(factors=50, regularization=0.1, iterations=20)\nmodel.fit(art_user_conf)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T06:06:14.332342Z","iopub.execute_input":"2025-03-09T06:06:14.332664Z","iopub.status.idle":"2025-03-09T06:08:51.360603Z","shell.execute_reply.started":"2025-03-09T06:06:14.332639Z","shell.execute_reply":"2025-03-09T06:08:51.359763Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"popular_items = transactions['article_id'].value_counts().head(12).index.tolist()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T06:12:07.670957Z","iopub.execute_input":"2025-03-09T06:12:07.671349Z","iopub.status.idle":"2025-03-09T06:12:10.065221Z","shell.execute_reply.started":"2025-03-09T06:12:07.671322Z","shell.execute_reply":"2025-03-09T06:12:10.064445Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"popular_items","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T06:12:21.12494Z","iopub.execute_input":"2025-03-09T06:12:21.125283Z","iopub.status.idle":"2025-03-09T06:12:21.130699Z","shell.execute_reply.started":"2025-03-09T06:12:21.125247Z","shell.execute_reply":"2025-03-09T06:12:21.129742Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# N_recommend = 12\n# recommendations = {}\n\n# # We'll iterate over ALL customers in the customers DataFrame.\n# # index = 0;\n# for cid in customers['customer_id']:\n#     # if index == 10:\n#     #     break\n#     # index += 1\n#     if cid in cus_id_to_indx:\n#         user_idx = cus_id_to_indx[cid]\n#         user_row = cus_art_matrix[user_idx]\n#         try:\n#             recs = model.recommend(user_idx, user_row, N=N_recommend, filter_already_liked_items=True)\n#             recs = recs[0]\n#             rec_art_id = [art_id[item_idx] for item_idx in recs if item_idx < len(art_id)]\n#             if len(rec_art_id) < N_recommend:\n#                 # Filter out any articles that are already recommended.\n#                 fallback = [aid for aid in popular_items if aid not in rec_art_id]\n#                 needed = N_recommend - len(rec_art_id)\n#                 rec_art_id.extend(fallback[:needed])\n#             recommendations[cid] = rec_art_id\n#         except:\n#             recommendations[cid] = popular_items\n#     else:\n#         # For users with no transaction history, assign the default popular items.\n#         recommendations[cid] = popular_items\n#     res = ''\n#     for i in recommendations[cid]:\n#         res += f'0{i} '\n#     recommendations[cid] = res","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T07:32:46.826465Z","iopub.execute_input":"2025-03-09T07:32:46.826896Z","iopub.status.idle":"2025-03-09T07:58:55.573472Z","shell.execute_reply.started":"2025-03-09T07:32:46.826863Z","shell.execute_reply":"2025-03-09T07:58:55.572479Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# # ----------------------------\n# # 5. Write Output to a CSV File\n# # ----------------------------\n# output_df = pd.DataFrame({\n#     'customer_id': list(recommendations.keys()),\n#     'prediction': list(recommendations.values())\n# })\n\n# output_df.to_csv('predictions.csv', index=False)\n# print(\"Recommendations written to predictions.csv\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T08:05:55.850296Z","iopub.execute_input":"2025-03-09T08:05:55.850821Z","iopub.status.idle":"2025-03-09T08:06:02.955754Z","shell.execute_reply.started":"2025-03-09T08:05:55.850778Z","shell.execute_reply":"2025-03-09T08:06:02.954503Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# articles.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T06:45:26.30193Z","iopub.execute_input":"2025-03-09T06:45:26.302331Z","iopub.status.idle":"2025-03-09T06:45:26.414468Z","shell.execute_reply.started":"2025-03-09T06:45:26.302302Z","shell.execute_reply":"2025-03-09T06:45:26.413446Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## FMs","metadata":{}},{"cell_type":"code","source":"# articles.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T08:21:38.363106Z","iopub.execute_input":"2025-03-09T08:21:38.363453Z","iopub.status.idle":"2025-03-09T08:21:38.369839Z","shell.execute_reply.started":"2025-03-09T08:21:38.363425Z","shell.execute_reply":"2025-03-09T08:21:38.368886Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"art = articles.loc[:, ['article_id', 'product_code', 'product_code', \n                       'graphical_appearance_no', 'colour_group_code',\n                      'perceived_colour_value_id', 'perceived_colour_master_id',\n                      'department_no', 'index_code', 'index_group_no',\n                      'section_no', 'garment_group_no']]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T08:24:11.598135Z","iopub.execute_input":"2025-03-09T08:24:11.598468Z","iopub.status.idle":"2025-03-09T08:24:11.607846Z","shell.execute_reply.started":"2025-03-09T08:24:11.59844Z","shell.execute_reply":"2025-03-09T08:24:11.607034Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"customers.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T08:24:24.432833Z","iopub.execute_input":"2025-03-09T08:24:24.433157Z","iopub.status.idle":"2025-03-09T08:24:24.438546Z","shell.execute_reply.started":"2025-03-09T08:24:24.43313Z","shell.execute_reply":"2025-03-09T08:24:24.4378Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"cus = customers.loc[:, ['customer_id', 'FN', 'Active', 'age']]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T08:27:51.720131Z","iopub.execute_input":"2025-03-09T08:27:51.720556Z","iopub.status.idle":"2025-03-09T08:27:51.903711Z","shell.execute_reply.started":"2025-03-09T08:27:51.72051Z","shell.execute_reply":"2025-03-09T08:27:51.902688Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"art\ncus\npass","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T08:27:59.345227Z","iopub.execute_input":"2025-03-09T08:27:59.345607Z","iopub.status.idle":"2025-03-09T08:27:59.349517Z","shell.execute_reply.started":"2025-03-09T08:27:59.345572Z","shell.execute_reply":"2025-03-09T08:27:59.348594Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"d","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}