{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import os\nimport random\nimport numpy as np\nimport pandas as pd\nfrom sklearn.cluster import KMeans\nfrom sklearn.mixture import BayesianGaussianMixture\nfrom sklearn.preprocessing import RobustScaler\nfrom yellowbrick.cluster import KElbowVisualizer","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-07-07T12:44:10.612094Z","iopub.execute_input":"2022-07-07T12:44:10.612502Z","iopub.status.idle":"2022-07-07T12:44:11.669150Z","shell.execute_reply.started":"2022-07-07T12:44:10.612469Z","shell.execute_reply":"2022-07-07T12:44:11.668195Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = pd.read_csv(\"../input/tabular-playground-series-jul-2022/data.csv\")\nsubmission = pd.read_csv(\"../input/tabular-playground-series-jul-2022/sample_submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-07-07T12:44:11.670709Z","iopub.execute_input":"2022-07-07T12:44:11.671124Z","iopub.status.idle":"2022-07-07T12:44:12.950756Z","shell.execute_reply.started":"2022-07-07T12:44:11.671092Z","shell.execute_reply":"2022-07-07T12:44:12.949699Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-07T12:44:18.933528Z","iopub.execute_input":"2022-07-07T12:44:18.934079Z","iopub.status.idle":"2022-07-07T12:44:18.977294Z","shell.execute_reply.started":"2022-07-07T12:44:18.934033Z","shell.execute_reply":"2022-07-07T12:44:18.976087Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-07T12:51:13.896961Z","iopub.execute_input":"2022-07-07T12:51:13.897789Z","iopub.status.idle":"2022-07-07T12:51:13.905672Z","shell.execute_reply.started":"2022-07-07T12:51:13.897748Z","shell.execute_reply":"2022-07-07T12:51:13.904032Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"scaler = RobustScaler()\nX_scaled = scaler.fit_transform(data)","metadata":{"execution":{"iopub.status.busy":"2022-07-07T12:46:18.244412Z","iopub.execute_input":"2022-07-07T12:46:18.245146Z","iopub.status.idle":"2022-07-07T12:46:18.399898Z","shell.execute_reply.started":"2022-07-07T12:46:18.245105Z","shell.execute_reply":"2022-07-07T12:46:18.398729Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"km = KMeans()\nvisualizer = KElbowVisualizer(km, k=(1,15), timings=True)\nvisualizer.fit(X_scaled)\nvisualizer.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-07T13:08:51.811646Z","iopub.execute_input":"2022-07-07T13:08:51.812039Z","iopub.status.idle":"2022-07-07T13:10:39.032010Z","shell.execute_reply.started":"2022-07-07T13:08:51.812008Z","shell.execute_reply":"2022-07-07T13:10:39.030577Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"gmm = BayesianGaussianMixture(n_components=5, covariance_type='full', random_state=1)\npreds = gmm.fit_predict(X_scaled)","metadata":{"execution":{"iopub.status.busy":"2022-07-07T13:10:55.342341Z","iopub.execute_input":"2022-07-07T13:10:55.342770Z","iopub.status.idle":"2022-07-07T13:11:46.772496Z","shell.execute_reply.started":"2022-07-07T13:10:55.342733Z","shell.execute_reply":"2022-07-07T13:11:46.771107Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('submission1.csv', index=False)\n","metadata":{"execution":{"iopub.status.busy":"2022-07-07T13:12:29.860948Z","iopub.execute_input":"2022-07-07T13:12:29.861335Z","iopub.status.idle":"2022-07-07T13:12:30.022078Z","shell.execute_reply.started":"2022-07-07T13:12:29.861305Z","shell.execute_reply":"2022-07-07T13:12:30.020939Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}