{"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":"# 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\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 read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-07-07T01:33:02.939855Z","iopub.execute_input":"2022-07-07T01:33:02.940508Z","iopub.status.idle":"2022-07-07T01:33:02.972147Z","shell.execute_reply.started":"2022-07-07T01:33:02.940398Z","shell.execute_reply":"2022-07-07T01:33:02.970834Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.mixture import BayesianGaussianMixture","metadata":{"execution":{"iopub.status.busy":"2022-07-07T01:33:02.974532Z","iopub.execute_input":"2022-07-07T01:33:02.975277Z","iopub.status.idle":"2022-07-07T01:33:04.417799Z","shell.execute_reply.started":"2022-07-07T01:33:02.975228Z","shell.execute_reply":"2022-07-07T01:33:04.416333Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv('../input/tabular-playground-series-jul-2022/data.csv')","metadata":{"execution":{"iopub.status.busy":"2022-07-07T01:33:04.419381Z","iopub.execute_input":"2022-07-07T01:33:04.419879Z","iopub.status.idle":"2022-07-07T01:33:05.726475Z","shell.execute_reply.started":"2022-07-07T01:33:04.419832Z","shell.execute_reply":"2022-07-07T01:33:05.725023Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.describe()","metadata":{"execution":{"iopub.status.busy":"2022-07-07T01:33:05.729366Z","iopub.execute_input":"2022-07-07T01:33:05.729757Z","iopub.status.idle":"2022-07-07T01:33:06.072001Z","shell.execute_reply.started":"2022-07-07T01:33:05.729722Z","shell.execute_reply":"2022-07-07T01:33:06.070835Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-07T01:33:06.073572Z","iopub.execute_input":"2022-07-07T01:33:06.073967Z","iopub.status.idle":"2022-07-07T01:33:06.100239Z","shell.execute_reply.started":"2022-07-07T01:33:06.073931Z","shell.execute_reply":"2022-07-07T01:33:06.098878Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.isnull().sum().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-07T01:33:06.101674Z","iopub.execute_input":"2022-07-07T01:33:06.102132Z","iopub.status.idle":"2022-07-07T01:33:06.120478Z","shell.execute_reply.started":"2022-07-07T01:33:06.102085Z","shell.execute_reply":"2022-07-07T01:33:06.118342Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = train.drop('id', axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-07-07T01:33:06.122521Z","iopub.execute_input":"2022-07-07T01:33:06.122859Z","iopub.status.idle":"2022-07-07T01:33:06.135047Z","shell.execute_reply.started":"2022-07-07T01:33:06.122829Z","shell.execute_reply":"2022-07-07T01:33:06.133349Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import RobustScaler, PowerTransformer\nr=RobustScaler()\ndata=r.fit_transform(data)\ndata=PowerTransformer().fit_transform(data)","metadata":{"execution":{"iopub.status.busy":"2022-07-07T01:33:06.136982Z","iopub.execute_input":"2022-07-07T01:33:06.137761Z","iopub.status.idle":"2022-07-07T01:33:10.337036Z","shell.execute_reply.started":"2022-07-07T01:33:06.137711Z","shell.execute_reply":"2022-07-07T01:33:10.335962Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class CFG:\n    path = \"../input/tabular-playground-series-jul-2022/\"\n    drop_columns = ['id']\n    n_components = 7\n    n_init = 3\n    \n    target = 'Predicted'\n    pred = 'pred'","metadata":{"execution":{"iopub.status.busy":"2022-07-07T01:33:10.341015Z","iopub.execute_input":"2022-07-07T01:33:10.341887Z","iopub.status.idle":"2022-07-07T01:33:10.34747Z","shell.execute_reply.started":"2022-07-07T01:33:10.341831Z","shell.execute_reply":"2022-07-07T01:33:10.346539Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = BayesianGaussianMixture(n_components=CFG.n_components,\n                                covariance_type='full',\n                                max_iter=300,\n                                n_init=CFG.n_init,\n                                random_state=9)\n\nmodel.fit(data)\npred = model.predict(data)","metadata":{"execution":{"iopub.status.busy":"2022-07-07T01:33:10.349003Z","iopub.execute_input":"2022-07-07T01:33:10.349494Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# from sklearn.mixture import GaussianMixture\n\n# model = GaussianMixture(n_components=CFG.n_components,\n#                                 covariance_type='full',\n#                                 max_iter=100,\n#                                 n_init=CFG.n_init,\n#                                 random_state=3)\n\n# model.fit(data)\n# pred = model.predict(data)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.read_csv('../input/tabular-playground-series-jul-2022/sample_submission.csv')","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.Predicted = pred\nsubmission.to_csv('submission.csv', index=False)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.head()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}