{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":84493,"databundleVersionId":9871156,"sourceType":"competition"}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"This is a modification of the https://www.kaggle.com/code/michau96/jane-street-features-by-financial-instruments notebook, but density computed on all dataset. ","metadata":{}},{"cell_type":"code","source":"%pip install -q seaborn==0.13.2","metadata":{"execution":{"iopub.status.busy":"2024-10-24T16:26:58.772949Z","iopub.execute_input":"2024-10-24T16:26:58.775961Z","iopub.status.idle":"2024-10-24T16:27:18.522250Z","shell.execute_reply.started":"2024-10-24T16:26:58.775810Z","shell.execute_reply":"2024-10-24T16:27:18.520344Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport polars as pl\nimport gc\nimport seaborn as sns\nimport warnings\nimport random\n\nwarnings.filterwarnings('ignore')","metadata":{"execution":{"iopub.status.busy":"2024-10-24T16:27:18.526437Z","iopub.execute_input":"2024-10-24T16:27:18.527030Z","iopub.status.idle":"2024-10-24T16:27:18.533876Z","shell.execute_reply.started":"2024-10-24T16:27:18.526954Z","shell.execute_reply":"2024-10-24T16:27:18.532582Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data = (\n    pl.read_parquet(\"../input/jane-street-real-time-market-data-forecasting/train.parquet/\")\n)\ntrain_data.shape","metadata":{"execution":{"iopub.status.busy":"2024-10-24T16:27:18.535151Z","iopub.execute_input":"2024-10-24T16:27:18.535538Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def create_plot(df, feature, grouping_feature):\n    title = 'Density by symbol_id for feature: ' + str(feature)\n    g = sns.FacetGrid(df, col=grouping_feature, sharex=False, sharey=False, col_wrap=6)\n    g.map_dataframe(sns.kdeplot, x = feature, fill = True, color=random.choice(['#66c2a5', '#fc8d62', '#8da0cb', '#e78ac3', '#a6d854', '#ffd92f', '#e5c494', '#b3b3b3']))\n    g.set(xlabel=None, ylabel=None)\n    g.fig.subplots_adjust(top=0.92)\n    g.fig.suptitle(title, fontweight='bold')","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"list_of_features_part_1 = [i for i in train_data.columns if i.startswith('feature')]\nlist_of_features_part_2 = [i for i in train_data.columns if i.startswith('responder')]\n\nlist_of_features = list_of_features_part_1 + list_of_features_part_2 + ['weight']\n\nfor col in list_of_features:\n    train_data_col = train_data.select([col, 'symbol_id'])\n    create_plot(train_data_col, col, 'symbol_id')\n    gc.collect()","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}