{"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":"markdown","source":"# Text-Classification with BagOfWords \n\noutline : \n- Download and Explore the data\n- Apply text preprocessing techniques \n- implement the bag of words model \n- Train ML model for text classification \n- Make Prediction and Submit to Kaggle ","metadata":{"id":"bzKM7vlglsqP"}},{"cell_type":"markdown","source":"## Download and Explore the Data\n\noutline :     \n1. Download the Dataset from kaggle \n2. Explore the data using Pandas\n3. Create a small working sample","metadata":{"id":"BjgiyNAF3u40"}},{"cell_type":"code","source":"!ls","metadata":{"id":"Vsb3Y9YPouAT","outputId":"ef4c9c92-9b31-4e08-dc86-105a320453e4","execution":{"iopub.status.busy":"2023-01-30T18:37:27.249410Z","iopub.execute_input":"2023-01-30T18:37:27.249793Z","iopub.status.idle":"2023-01-30T18:37:27.520179Z","shell.execute_reply.started":"2023-01-30T18:37:27.249758Z","shell.execute_reply":"2023-01-30T18:37:27.519154Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install kaggle","metadata":{"id":"o32aK5mppK-5","outputId":"027f839e-6315-4610-af5c-e0325c6fbac8","execution":{"iopub.status.busy":"2023-01-30T18:37:27.522336Z","iopub.execute_input":"2023-01-30T18:37:27.522680Z","iopub.status.idle":"2023-01-30T18:37:36.072955Z","shell.execute_reply.started":"2023-01-30T18:37:27.522654Z","shell.execute_reply":"2023-01-30T18:37:36.071633Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#import os","metadata":{"id":"60wquC5zgGkT","execution":{"iopub.status.busy":"2023-01-30T18:37:36.074832Z","iopub.execute_input":"2023-01-30T18:37:36.075163Z","iopub.status.idle":"2023-01-30T18:37:36.078967Z","shell.execute_reply.started":"2023-01-30T18:37:36.075136Z","shell.execute_reply":"2023-01-30T18:37:36.078124Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#os.environ['KAGGLE_CONFIG_DIR']='.'","metadata":{"id":"Uppo5dRngIyO","execution":{"iopub.status.busy":"2023-01-30T18:37:36.081191Z","iopub.execute_input":"2023-01-30T18:37:36.081424Z","iopub.status.idle":"2023-01-30T18:37:36.089424Z","shell.execute_reply.started":"2023-01-30T18:37:36.081401Z","shell.execute_reply":"2023-01-30T18:37:36.088576Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"id":"OVZs6mRjgQ1g"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{"id":"UuFiPhYUgGMY"}},{"cell_type":"code","source":"#!kaggle competitions download -c quora-insincere-questions-classification -f test.csv -p data","metadata":{"id":"nI_EibPHoOx8","outputId":"b1b705c1-6b2d-46f5-f69b-886d24dafd5c","execution":{"iopub.status.busy":"2023-01-30T18:37:36.090410Z","iopub.execute_input":"2023-01-30T18:37:36.090620Z","iopub.status.idle":"2023-01-30T18:37:36.099589Z","shell.execute_reply.started":"2023-01-30T18:37:36.090598Z","shell.execute_reply":"2023-01-30T18:37:36.098699Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#!kaggle competitions download -c quora-insincere-questions-classification -f train.csv -p data\n#!kaggle competitions download -c quora-insincere-questions-classification -f sample_submission.csv -p data","metadata":{"id":"i2RVas8ZoY_G","outputId":"ea1940c4-8f0e-4341-b5c3-604e89abcf14","execution":{"iopub.status.busy":"2023-01-30T18:37:36.100346Z","iopub.execute_input":"2023-01-30T18:37:36.100589Z","iopub.status.idle":"2023-01-30T18:37:36.109345Z","shell.execute_reply.started":"2023-01-30T18:37:36.100567Z","shell.execute_reply":"2023-01-30T18:37:36.108141Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# train = 'data/train.csv.zip'\n# test = 'data/test.csv.zip'\n# sample = 'data/sample_submission.csv.zip' ","metadata":{"id":"hMww3sdnrNiy","execution":{"iopub.status.busy":"2023-01-30T18:37:36.110743Z","iopub.execute_input":"2023-01-30T18:37:36.111072Z","iopub.status.idle":"2023-01-30T18:37:36.123255Z","shell.execute_reply.started":"2023-01-30T18:37:36.111049Z","shell.execute_reply":"2023-01-30T18:37:36.122106Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data_dir = '/kaggle/input/quora-insincere-questions-classification'\ntrain = data_dir + '/train.csv'\ntest = data_dir + '/test.csv'\nsample = data_dir + '/sample_submission.csv'","metadata":{"execution":{"iopub.status.busy":"2023-01-30T18:37:36.124742Z","iopub.execute_input":"2023-01-30T18:37:36.125110Z","iopub.status.idle":"2023-01-30T18:37:36.133453Z","shell.execute_reply.started":"2023-01-30T18:37:36.125078Z","shell.execute_reply":"2023-01-30T18:37:36.132382Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd","metadata":{"id":"YtrA-3TKtPdK","execution":{"iopub.status.busy":"2023-01-30T18:37:36.134726Z","iopub.execute_input":"2023-01-30T18:37:36.135036Z","iopub.status.idle":"2023-01-30T18:37:36.143119Z","shell.execute_reply.started":"2023-01-30T18:37:36.135011Z","shell.execute_reply":"2023-01-30T18:37:36.142277Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"raw_df = pd.read_csv(train)","metadata":{"id":"NltgZ3Umteej","execution":{"iopub.status.busy":"2023-01-30T18:37:36.146892Z","iopub.execute_input":"2023-01-30T18:37:36.147348Z","iopub.status.idle":"2023-01-30T18:37:38.528350Z","shell.execute_reply.started":"2023-01-30T18:37:36.147322Z","shell.execute_reply":"2023-01-30T18:37:38.527338Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"raw_df","metadata":{"id":"OuUSP7eUtoft","outputId":"62f38ef8-8bb7-4050-ad43-ec044f1739ac","execution":{"iopub.status.busy":"2023-01-30T18:37:38.529499Z","iopub.execute_input":"2023-01-30T18:37:38.529778Z","iopub.status.idle":"2023-01-30T18:37:38.542322Z","shell.execute_reply.started":"2023-01-30T18:37:38.529752Z","shell.execute_reply":"2023-01-30T18:37:38.541372Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sincere_df = raw_df[raw_df.target==0]","metadata":{"id":"IMKDf--ttrPS","execution":{"iopub.status.busy":"2023-01-30T18:37:38.543390Z","iopub.execute_input":"2023-01-30T18:37:38.543657Z","iopub.status.idle":"2023-01-30T18:37:38.615090Z","shell.execute_reply.started":"2023-01-30T18:37:38.543633Z","shell.execute_reply":"2023-01-30T18:37:38.613901Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sincere_df.question_text.values[:10]","metadata":{"id":"v_lfKFp_uG3h","outputId":"49f9a5aa-a7ee-4691-a884-25d4e4bd802c","execution":{"iopub.status.busy":"2023-01-30T18:37:38.616488Z","iopub.execute_input":"2023-01-30T18:37:38.617702Z","iopub.status.idle":"2023-01-30T18:37:38.626622Z","shell.execute_reply.started":"2023-01-30T18:37:38.617660Z","shell.execute_reply":"2023-01-30T18:37:38.625405Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"insincere_df = raw_df[raw_df.target==1]","metadata":{"id":"BmZ-CBkeuMEJ","execution":{"iopub.status.busy":"2023-01-30T18:37:38.627956Z","iopub.execute_input":"2023-01-30T18:37:38.628251Z","iopub.status.idle":"2023-01-30T18:37:38.643786Z","shell.execute_reply.started":"2023-01-30T18:37:38.628225Z","shell.execute_reply":"2023-01-30T18:37:38.642860Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"insincere_df.question_text.values[:10]","metadata":{"id":"T0DHNZ19ueKU","outputId":"9f8a812f-0bcf-4277-c4e8-e9757869741b","execution":{"iopub.status.busy":"2023-01-30T18:37:38.645242Z","iopub.execute_input":"2023-01-30T18:37:38.645526Z","iopub.status.idle":"2023-01-30T18:37:38.652571Z","shell.execute_reply.started":"2023-01-30T18:37:38.645501Z","shell.execute_reply":"2023-01-30T18:37:38.651468Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"raw_df.target.value_counts(normalize=True)","metadata":{"id":"jl64eMKJuhbS","outputId":"bdd5e6a9-3207-4bd9-fce7-cdc7108f1dcc","execution":{"iopub.status.busy":"2023-01-30T18:37:38.654100Z","iopub.execute_input":"2023-01-30T18:37:38.654375Z","iopub.status.idle":"2023-01-30T18:37:38.674985Z","shell.execute_reply.started":"2023-01-30T18:37:38.654351Z","shell.execute_reply":"2023-01-30T18:37:38.673915Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"raw_df.target.value_counts(normalize=True).plot(kind='bar')","metadata":{"id":"fuueu_FZut-K","outputId":"66f10f91-2a91-4373-c9b0-5248b6d6db72","execution":{"iopub.status.busy":"2023-01-30T18:37:38.676602Z","iopub.execute_input":"2023-01-30T18:37:38.677647Z","iopub.status.idle":"2023-01-30T18:37:38.793680Z","shell.execute_reply.started":"2023-01-30T18:37:38.677608Z","shell.execute_reply":"2023-01-30T18:37:38.792954Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df = pd.read_csv(test)","metadata":{"id":"EucIB2sFvLxz","execution":{"iopub.status.busy":"2023-01-30T18:37:38.794930Z","iopub.execute_input":"2023-01-30T18:37:38.796027Z","iopub.status.idle":"2023-01-30T18:37:39.496822Z","shell.execute_reply.started":"2023-01-30T18:37:38.795994Z","shell.execute_reply":"2023-01-30T18:37:39.495813Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df","metadata":{"id":"pAQDhJ-uvZCq","outputId":"dc0466b3-02ad-4e24-af9f-b60fc4ae7351","execution":{"iopub.status.busy":"2023-01-30T18:37:39.498265Z","iopub.execute_input":"2023-01-30T18:37:39.499376Z","iopub.status.idle":"2023-01-30T18:37:39.510195Z","shell.execute_reply.started":"2023-01-30T18:37:39.499325Z","shell.execute_reply":"2023-01-30T18:37:39.509224Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df = pd.read_csv(sample)","metadata":{"id":"smJiVOsSvaJZ","execution":{"iopub.status.busy":"2023-01-30T18:37:39.511309Z","iopub.execute_input":"2023-01-30T18:37:39.512067Z","iopub.status.idle":"2023-01-30T18:37:39.712711Z","shell.execute_reply.started":"2023-01-30T18:37:39.512039Z","shell.execute_reply":"2023-01-30T18:37:39.712001Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df","metadata":{"id":"n-ma5ujwvqPf","outputId":"70792920-3077-4325-b7e9-8cb73d85fa06","execution":{"iopub.status.busy":"2023-01-30T18:37:39.714196Z","iopub.execute_input":"2023-01-30T18:37:39.714505Z","iopub.status.idle":"2023-01-30T18:37:39.724750Z","shell.execute_reply.started":"2023-01-30T18:37:39.714477Z","shell.execute_reply":"2023-01-30T18:37:39.724118Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df.prediction.value_counts()","metadata":{"id":"M1JYreBwvrFD","outputId":"a2a1777c-694a-48b1-cd0d-fcc29059965a","execution":{"iopub.status.busy":"2023-01-30T18:37:39.726200Z","iopub.execute_input":"2023-01-30T18:37:39.726602Z","iopub.status.idle":"2023-01-30T18:37:39.742384Z","shell.execute_reply.started":"2023-01-30T18:37:39.726575Z","shell.execute_reply":"2023-01-30T18:37:39.740984Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"SAMPLE_SIZE = 100_000","metadata":{"id":"O5CAyCbUwHzJ","execution":{"iopub.status.busy":"2023-01-30T18:37:39.744186Z","iopub.execute_input":"2023-01-30T18:37:39.744552Z","iopub.status.idle":"2023-01-30T18:37:39.751785Z","shell.execute_reply.started":"2023-01-30T18:37:39.744519Z","shell.execute_reply":"2023-01-30T18:37:39.751096Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_df = raw_df.sample(SAMPLE_SIZE,random_state=42)","metadata":{"id":"nICcWQwev-5r","execution":{"iopub.status.busy":"2023-01-30T18:37:39.752800Z","iopub.execute_input":"2023-01-30T18:37:39.753653Z","iopub.status.idle":"2023-01-30T18:37:39.830438Z","shell.execute_reply.started":"2023-01-30T18:37:39.753617Z","shell.execute_reply":"2023-01-30T18:37:39.829348Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nsample_df","metadata":{"id":"NXGzUSM3wawg","outputId":"167c8132-0163-42ab-893b-381e732493a7","execution":{"iopub.status.busy":"2023-01-30T18:37:39.831754Z","iopub.execute_input":"2023-01-30T18:37:39.832059Z","iopub.status.idle":"2023-01-30T18:37:39.843395Z","shell.execute_reply.started":"2023-01-30T18:37:39.832034Z","shell.execute_reply":"2023-01-30T18:37:39.842392Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"q0 = sincere_df.question_text.values[1]","metadata":{"id":"Qd7FwQYBwcW7","execution":{"iopub.status.busy":"2023-01-30T18:37:39.844795Z","iopub.execute_input":"2023-01-30T18:37:39.845086Z","iopub.status.idle":"2023-01-30T18:37:39.852051Z","shell.execute_reply.started":"2023-01-30T18:37:39.845061Z","shell.execute_reply":"2023-01-30T18:37:39.851025Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"q0","metadata":{"id":"0rdQeJL4zNnb","outputId":"94c6ee6b-0f8d-4c94-d8d0-715794e89303","execution":{"iopub.status.busy":"2023-01-30T18:37:39.853432Z","iopub.execute_input":"2023-01-30T18:37:39.854430Z","iopub.status.idle":"2023-01-30T18:37:39.862917Z","shell.execute_reply.started":"2023-01-30T18:37:39.854353Z","shell.execute_reply":"2023-01-30T18:37:39.862037Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"q1 = raw_df[raw_df.target==1].question_text.values[0]\nq1","metadata":{"id":"EVw_NizCzObL","outputId":"31b4149a-92a8-4edf-c7e8-5466ccd24139","execution":{"iopub.status.busy":"2023-01-30T18:37:39.873261Z","iopub.execute_input":"2023-01-30T18:37:39.873585Z","iopub.status.idle":"2023-01-30T18:37:39.894607Z","shell.execute_reply.started":"2023-01-30T18:37:39.873561Z","shell.execute_reply":"2023-01-30T18:37:39.893697Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Text Preprocessing Techniques \noutline :     \n- Tokenization \n- stopwords \n- stemmanization \n- lemmanization","metadata":{"id":"UAJzpukT5Jsi"}},{"cell_type":"markdown","source":"# Tokenization \nsplitting a documents into words and separators","metadata":{"id":"Z_2xdfd50lrV"}},{"cell_type":"code","source":"from nltk.tokenize import word_tokenize","metadata":{"id":"zq2PvKCm0tLt","execution":{"iopub.status.busy":"2023-01-30T18:37:39.895609Z","iopub.execute_input":"2023-01-30T18:37:39.895885Z","iopub.status.idle":"2023-01-30T18:37:39.900003Z","shell.execute_reply.started":"2023-01-30T18:37:39.895860Z","shell.execute_reply":"2023-01-30T18:37:39.899134Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"q0","metadata":{"id":"YRjWSC1m1dhw","outputId":"61c3104f-30ad-4611-c436-b31465c07da7","execution":{"iopub.status.busy":"2023-01-30T18:37:39.901522Z","iopub.execute_input":"2023-01-30T18:37:39.901903Z","iopub.status.idle":"2023-01-30T18:37:39.911783Z","shell.execute_reply.started":"2023-01-30T18:37:39.901869Z","shell.execute_reply":"2023-01-30T18:37:39.910670Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import nltk","metadata":{"id":"JEPbl-o2g-pH","execution":{"iopub.status.busy":"2023-01-30T18:37:39.913520Z","iopub.execute_input":"2023-01-30T18:37:39.913982Z","iopub.status.idle":"2023-01-30T18:37:39.920687Z","shell.execute_reply.started":"2023-01-30T18:37:39.913944Z","shell.execute_reply":"2023-01-30T18:37:39.919723Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nltk.download('punkt')","metadata":{"id":"YwPBWtjmg6JB","outputId":"f0797452-2bc7-484f-88c1-d0ed48fcd326","execution":{"iopub.status.busy":"2023-01-30T18:37:39.922301Z","iopub.execute_input":"2023-01-30T18:37:39.923036Z","iopub.status.idle":"2023-01-30T18:37:39.933710Z","shell.execute_reply.started":"2023-01-30T18:37:39.922993Z","shell.execute_reply":"2023-01-30T18:37:39.933023Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"word_tokenize(q0)","metadata":{"id":"s1JjXOvKg1xN","outputId":"2942437f-bd1c-417d-8f35-48171324a283","execution":{"iopub.status.busy":"2023-01-30T18:37:39.934470Z","iopub.execute_input":"2023-01-30T18:37:39.934712Z","iopub.status.idle":"2023-01-30T18:37:39.944219Z","shell.execute_reply.started":"2023-01-30T18:37:39.934688Z","shell.execute_reply":"2023-01-30T18:37:39.943175Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"q0_tok = word_tokenize(q0)\nq1_tok = word_tokenize(q1)","metadata":{"id":"cYv-vj7Lg36e","execution":{"iopub.status.busy":"2023-01-30T18:37:39.945284Z","iopub.execute_input":"2023-01-30T18:37:39.946110Z","iopub.status.idle":"2023-01-30T18:37:39.953550Z","shell.execute_reply.started":"2023-01-30T18:37:39.946084Z","shell.execute_reply":"2023-01-30T18:37:39.952911Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## stopwords ","metadata":{"id":"kPuX-HpO5iij"}},{"cell_type":"code","source":"from nltk.corpus import stopwords ","metadata":{"id":"u16kcDhnhUoH","execution":{"iopub.status.busy":"2023-01-30T18:37:39.954671Z","iopub.execute_input":"2023-01-30T18:37:39.955119Z","iopub.status.idle":"2023-01-30T18:37:39.962939Z","shell.execute_reply.started":"2023-01-30T18:37:39.955094Z","shell.execute_reply":"2023-01-30T18:37:39.962195Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nltk.download('stopwords')","metadata":{"id":"Iwz01Xx4hkcb","outputId":"a4bff210-cd8c-43bd-cf01-c8028ce7b23e","execution":{"iopub.status.busy":"2023-01-30T18:37:39.964098Z","iopub.execute_input":"2023-01-30T18:37:39.964544Z","iopub.status.idle":"2023-01-30T18:37:39.977826Z","shell.execute_reply.started":"2023-01-30T18:37:39.964516Z","shell.execute_reply":"2023-01-30T18:37:39.976771Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"english_words = stopwords.words('english')","metadata":{"id":"jcYeus3KhZzv","execution":{"iopub.status.busy":"2023-01-30T18:37:39.979143Z","iopub.execute_input":"2023-01-30T18:37:39.980136Z","iopub.status.idle":"2023-01-30T18:37:39.985455Z","shell.execute_reply.started":"2023-01-30T18:37:39.980087Z","shell.execute_reply":"2023-01-30T18:37:39.984485Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"english_words","metadata":{"id":"nM7Zv19KhoAS","outputId":"3a082477-7c6b-4027-c183-d3e91463d093","execution":{"iopub.status.busy":"2023-01-30T18:37:39.986752Z","iopub.execute_input":"2023-01-30T18:37:39.987655Z","iopub.status.idle":"2023-01-30T18:37:40.000441Z","shell.execute_reply.started":"2023-01-30T18:37:39.987567Z","shell.execute_reply":"2023-01-30T18:37:39.999617Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\",\".join(english_words)","metadata":{"id":"c9arS5LJhplq","outputId":"ce6f1c52-645c-4b15-fbaf-81842f909754","execution":{"iopub.status.busy":"2023-01-30T18:37:40.001613Z","iopub.execute_input":"2023-01-30T18:37:40.002709Z","iopub.status.idle":"2023-01-30T18:37:40.012442Z","shell.execute_reply.started":"2023-01-30T18:37:40.002677Z","shell.execute_reply":"2023-01-30T18:37:40.011555Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def remove_stopwords(tokens):\n  return [word for word in tokens if word.lower() not in english_words]\n","metadata":{"id":"ZfomluOEhvXy","execution":{"iopub.status.busy":"2023-01-30T18:37:40.013610Z","iopub.execute_input":"2023-01-30T18:37:40.013928Z","iopub.status.idle":"2023-01-30T18:37:40.022285Z","shell.execute_reply.started":"2023-01-30T18:37:40.013900Z","shell.execute_reply":"2023-01-30T18:37:40.021261Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"q0_stp = remove_stopwords(q0_tok)","metadata":{"id":"qlEVE7YSiPDO","execution":{"iopub.status.busy":"2023-01-30T18:37:40.023682Z","iopub.execute_input":"2023-01-30T18:37:40.024707Z","iopub.status.idle":"2023-01-30T18:37:40.030925Z","shell.execute_reply.started":"2023-01-30T18:37:40.024669Z","shell.execute_reply":"2023-01-30T18:37:40.030287Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"q0_tok","metadata":{"id":"gEly0Bo9igof","outputId":"8c76f246-380c-45ac-b369-dac2628e267c","execution":{"iopub.status.busy":"2023-01-30T18:37:40.032093Z","iopub.execute_input":"2023-01-30T18:37:40.032838Z","iopub.status.idle":"2023-01-30T18:37:40.043335Z","shell.execute_reply.started":"2023-01-30T18:37:40.032805Z","shell.execute_reply":"2023-01-30T18:37:40.042397Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"q0_stp","metadata":{"id":"2Rpa1mAYiV8K","outputId":"1468eb3b-1c28-44c3-b7b8-fa2b1504c114","execution":{"iopub.status.busy":"2023-01-30T18:37:40.044411Z","iopub.execute_input":"2023-01-30T18:37:40.044695Z","iopub.status.idle":"2023-01-30T18:37:40.054336Z","shell.execute_reply.started":"2023-01-30T18:37:40.044670Z","shell.execute_reply":"2023-01-30T18:37:40.053351Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"q1_stp = remove_stopwords(q1_tok)","metadata":{"id":"3Vlgixm1iZpa","execution":{"iopub.status.busy":"2023-01-30T18:37:40.055438Z","iopub.execute_input":"2023-01-30T18:37:40.055906Z","iopub.status.idle":"2023-01-30T18:37:40.062423Z","shell.execute_reply.started":"2023-01-30T18:37:40.055871Z","shell.execute_reply":"2023-01-30T18:37:40.061546Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"q1_tok","metadata":{"id":"MAjtKE1giqnJ","outputId":"f4c47da6-1606-49f9-8ade-caad798feab0","execution":{"iopub.status.busy":"2023-01-30T18:37:40.063607Z","iopub.execute_input":"2023-01-30T18:37:40.063880Z","iopub.status.idle":"2023-01-30T18:37:40.074490Z","shell.execute_reply.started":"2023-01-30T18:37:40.063833Z","shell.execute_reply":"2023-01-30T18:37:40.073649Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"q1_stp","metadata":{"id":"KvCFWdP4ir-M","outputId":"cad25ffc-141f-4a75-c6f3-ef13637fcde7","execution":{"iopub.status.busy":"2023-01-30T18:37:40.075521Z","iopub.execute_input":"2023-01-30T18:37:40.076122Z","iopub.status.idle":"2023-01-30T18:37:40.085594Z","shell.execute_reply.started":"2023-01-30T18:37:40.076067Z","shell.execute_reply":"2023-01-30T18:37:40.084858Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Stemmanization","metadata":{"id":"_EXnu0K25oHr"}},{"cell_type":"code","source":"from nltk.stem.snowball import SnowballStemmer","metadata":{"id":"it5QuqnbiuqV","execution":{"iopub.status.busy":"2023-01-30T18:37:40.086611Z","iopub.execute_input":"2023-01-30T18:37:40.087128Z","iopub.status.idle":"2023-01-30T18:37:40.094275Z","shell.execute_reply.started":"2023-01-30T18:37:40.087100Z","shell.execute_reply":"2023-01-30T18:37:40.093316Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"stemmer = SnowballStemmer(language='english')","metadata":{"id":"d5x1ICphi79o","execution":{"iopub.status.busy":"2023-01-30T18:37:40.095233Z","iopub.execute_input":"2023-01-30T18:37:40.095873Z","iopub.status.idle":"2023-01-30T18:37:40.104725Z","shell.execute_reply.started":"2023-01-30T18:37:40.095815Z","shell.execute_reply":"2023-01-30T18:37:40.103786Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"stemmer.stem('going')","metadata":{"id":"nTU9mJVQjClw","outputId":"641261c3-5159-4cc8-ea76-9b8cccf0ec28","execution":{"iopub.status.busy":"2023-01-30T18:37:40.105968Z","iopub.execute_input":"2023-01-30T18:37:40.106299Z","iopub.status.idle":"2023-01-30T18:37:40.116790Z","shell.execute_reply.started":"2023-01-30T18:37:40.106272Z","shell.execute_reply":"2023-01-30T18:37:40.115894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"stemmer.stem('supposedly')","metadata":{"id":"j_EJfCDTjEug","outputId":"73f5231b-6b3b-4de2-bd6a-52fc9e0a3f9a","execution":{"iopub.status.busy":"2023-01-30T18:37:40.117947Z","iopub.execute_input":"2023-01-30T18:37:40.118220Z","iopub.status.idle":"2023-01-30T18:37:40.127137Z","shell.execute_reply.started":"2023-01-30T18:37:40.118196Z","shell.execute_reply":"2023-01-30T18:37:40.125973Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"q0_stm = [stemmer.stem(word) for word in q0_stp]","metadata":{"id":"xD6RyUhNjHqN","execution":{"iopub.status.busy":"2023-01-30T18:37:40.128391Z","iopub.execute_input":"2023-01-30T18:37:40.129149Z","iopub.status.idle":"2023-01-30T18:37:40.137029Z","shell.execute_reply.started":"2023-01-30T18:37:40.129116Z","shell.execute_reply":"2023-01-30T18:37:40.136316Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"q0_stm","metadata":{"id":"h5sCfV4TjYiC","outputId":"173535ad-2896-43f4-9ebd-d58dfb8c9d57","execution":{"iopub.status.busy":"2023-01-30T18:37:40.138034Z","iopub.execute_input":"2023-01-30T18:37:40.138960Z","iopub.status.idle":"2023-01-30T18:37:40.148736Z","shell.execute_reply.started":"2023-01-30T18:37:40.138914Z","shell.execute_reply":"2023-01-30T18:37:40.147562Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"q1_stm = [stemmer.stem(word) for word in q1_stp]","metadata":{"id":"WTPYmJIrjlGk","execution":{"iopub.status.busy":"2023-01-30T18:37:40.150277Z","iopub.execute_input":"2023-01-30T18:37:40.150880Z","iopub.status.idle":"2023-01-30T18:37:40.158468Z","shell.execute_reply.started":"2023-01-30T18:37:40.150828Z","shell.execute_reply":"2023-01-30T18:37:40.157618Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"q1_stm","metadata":{"id":"GaQEiv93jquR","outputId":"8c76cfa4-e2f3-4472-dd5e-4bf0e84e7be7","execution":{"iopub.status.busy":"2023-01-30T18:37:40.159705Z","iopub.execute_input":"2023-01-30T18:37:40.160467Z","iopub.status.idle":"2023-01-30T18:37:40.172911Z","shell.execute_reply.started":"2023-01-30T18:37:40.160430Z","shell.execute_reply":"2023-01-30T18:37:40.172147Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Lemanization \n 'love'->'love'\n 'lovely'->'love'\n 'loved'->'love'","metadata":{"id":"jdGF0x0v5rVM"}},{"cell_type":"markdown","source":"## Implementation BagOfheader\n\n1. Create a vocubulary using CountVectorizer \n2. transform text to vectior using CountVectorizer\n3.Configure text preprocessing using CountVectorizer","metadata":{"id":"lPvxvemwjz0t"}},{"cell_type":"code","source":"small_df = sample_df[:5]","metadata":{"id":"Baq5FYwRjsYq","execution":{"iopub.status.busy":"2023-01-30T18:37:40.174253Z","iopub.execute_input":"2023-01-30T18:37:40.174679Z","iopub.status.idle":"2023-01-30T18:37:40.181655Z","shell.execute_reply.started":"2023-01-30T18:37:40.174652Z","shell.execute_reply":"2023-01-30T18:37:40.181011Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"small_df","metadata":{"id":"-5Yvxjtfkgaw","outputId":"1cc91d9b-8792-4b34-f2b2-80c75b16763b","execution":{"iopub.status.busy":"2023-01-30T18:37:40.182721Z","iopub.execute_input":"2023-01-30T18:37:40.182998Z","iopub.status.idle":"2023-01-30T18:37:40.198567Z","shell.execute_reply.started":"2023-01-30T18:37:40.182973Z","shell.execute_reply":"2023-01-30T18:37:40.197837Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"small_df.question_text.values","metadata":{"id":"gGzWxE8LkUsV","outputId":"ceb86626-50dd-44e3-d36f-af3e9ec1cd32","execution":{"iopub.status.busy":"2023-01-30T18:37:40.199675Z","iopub.execute_input":"2023-01-30T18:37:40.200415Z","iopub.status.idle":"2023-01-30T18:37:40.209468Z","shell.execute_reply.started":"2023-01-30T18:37:40.200386Z","shell.execute_reply":"2023-01-30T18:37:40.208458Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Create a vocubulary","metadata":{"id":"Aqnd1Cs0kohQ"}},{"cell_type":"code","source":"from sklearn.feature_extraction.text import CountVectorizer","metadata":{"id":"4AkQxKm5kn5n","execution":{"iopub.status.busy":"2023-01-30T18:37:40.211677Z","iopub.execute_input":"2023-01-30T18:37:40.212491Z","iopub.status.idle":"2023-01-30T18:37:40.218594Z","shell.execute_reply.started":"2023-01-30T18:37:40.212456Z","shell.execute_reply":"2023-01-30T18:37:40.217825Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"small_vect=CountVectorizer()","metadata":{"id":"pQKg_hz7klly","execution":{"iopub.status.busy":"2023-01-30T18:37:40.219772Z","iopub.execute_input":"2023-01-30T18:37:40.220618Z","iopub.status.idle":"2023-01-30T18:37:40.230353Z","shell.execute_reply.started":"2023-01-30T18:37:40.220582Z","shell.execute_reply":"2023-01-30T18:37:40.229569Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"small_vect.fit(small_df.question_text)","metadata":{"id":"Lmi7B2mokbyo","outputId":"7e04a011-4410-4947-8e3a-51c8c1e56f33","execution":{"iopub.status.busy":"2023-01-30T18:37:40.231822Z","iopub.execute_input":"2023-01-30T18:37:40.232419Z","iopub.status.idle":"2023-01-30T18:37:40.243925Z","shell.execute_reply.started":"2023-01-30T18:37:40.232388Z","shell.execute_reply":"2023-01-30T18:37:40.243008Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"small_vect.vocabulary_","metadata":{"id":"5knRSZ7PlCOS","outputId":"1d02a185-9e0d-4393-8a75-9b1f1757e212","execution":{"iopub.status.busy":"2023-01-30T18:37:40.245455Z","iopub.execute_input":"2023-01-30T18:37:40.245878Z","iopub.status.idle":"2023-01-30T18:37:40.253672Z","shell.execute_reply.started":"2023-01-30T18:37:40.245827Z","shell.execute_reply":"2023-01-30T18:37:40.253015Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"small_vect.get_feature_names_out()","metadata":{"id":"eF_g7sZilFg8","outputId":"82e5bb03-2fa7-4737-dab2-1168801161f3","execution":{"iopub.status.busy":"2023-01-30T18:37:40.254609Z","iopub.execute_input":"2023-01-30T18:37:40.255331Z","iopub.status.idle":"2023-01-30T18:37:40.266358Z","shell.execute_reply.started":"2023-01-30T18:37:40.255302Z","shell.execute_reply":"2023-01-30T18:37:40.265210Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Transform documents into Vectors","metadata":{"id":"FYD_Sw6Klej_"}},{"cell_type":"code","source":"vectors = small_vect.transform(small_df.question_text)","metadata":{"id":"krsjspjtlatk","execution":{"iopub.status.busy":"2023-01-30T18:37:40.267337Z","iopub.execute_input":"2023-01-30T18:37:40.268235Z","iopub.status.idle":"2023-01-30T18:37:40.276622Z","shell.execute_reply.started":"2023-01-30T18:37:40.268206Z","shell.execute_reply":"2023-01-30T18:37:40.275882Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"vectors","metadata":{"id":"KjQnnIG7lsW4","outputId":"ff84e52a-88b7-4af5-d04c-1ab61ecedeb0","execution":{"iopub.status.busy":"2023-01-30T18:37:40.277738Z","iopub.execute_input":"2023-01-30T18:37:40.278584Z","iopub.status.idle":"2023-01-30T18:37:40.288015Z","shell.execute_reply.started":"2023-01-30T18:37:40.278556Z","shell.execute_reply":"2023-01-30T18:37:40.287089Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"vectors.shape","metadata":{"id":"MBY4JlqZltK1","outputId":"940341c9-27b7-4bc3-fb2d-82f2ba306f46","execution":{"iopub.status.busy":"2023-01-30T18:37:40.289200Z","iopub.execute_input":"2023-01-30T18:37:40.289622Z","iopub.status.idle":"2023-01-30T18:37:40.299737Z","shell.execute_reply.started":"2023-01-30T18:37:40.289595Z","shell.execute_reply":"2023-01-30T18:37:40.298903Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"vectors.toarray()","metadata":{"id":"vFF4dPW2lvjo","outputId":"eca22234-58b2-4ce6-c3fa-b370b142745d","execution":{"iopub.status.busy":"2023-01-30T18:37:40.300907Z","iopub.execute_input":"2023-01-30T18:37:40.301173Z","iopub.status.idle":"2023-01-30T18:37:40.312306Z","shell.execute_reply.started":"2023-01-30T18:37:40.301149Z","shell.execute_reply":"2023-01-30T18:37:40.311471Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"small_df.question_text.values[0]","metadata":{"id":"on1er2tOl9zy","outputId":"26d2a993-8443-45a0-e864-c17ea6762074","execution":{"iopub.status.busy":"2023-01-30T18:37:40.313413Z","iopub.execute_input":"2023-01-30T18:37:40.313813Z","iopub.status.idle":"2023-01-30T18:37:40.323025Z","shell.execute_reply.started":"2023-01-30T18:37:40.313785Z","shell.execute_reply":"2023-01-30T18:37:40.322002Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"vectors[0].toarray()","metadata":{"id":"KltfqKTPlxig","outputId":"86d1abb5-b982-49ad-9e28-bd8232ee6180","execution":{"iopub.status.busy":"2023-01-30T18:37:40.324318Z","iopub.execute_input":"2023-01-30T18:37:40.324955Z","iopub.status.idle":"2023-01-30T18:37:40.335364Z","shell.execute_reply.started":"2023-01-30T18:37:40.324926Z","shell.execute_reply":"2023-01-30T18:37:40.334641Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Configure Count Vectorizewr in Parameter","metadata":{"id":"SnyrP6FwmHM0"}},{"cell_type":"code","source":"stemmer = SnowballStemmer(language='english')","metadata":{"id":"Lzk8MR91n-xe","execution":{"iopub.status.busy":"2023-01-30T18:37:40.336658Z","iopub.execute_input":"2023-01-30T18:37:40.337099Z","iopub.status.idle":"2023-01-30T18:37:40.343795Z","shell.execute_reply.started":"2023-01-30T18:37:40.337072Z","shell.execute_reply":"2023-01-30T18:37:40.343172Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def tokenizer(text):\n  return [stemmer.stem(word) for word in word_tokenize(text) ]","metadata":{"id":"OJOQRLiQl1d_","execution":{"iopub.status.busy":"2023-01-30T18:37:40.344692Z","iopub.execute_input":"2023-01-30T18:37:40.345413Z","iopub.status.idle":"2023-01-30T18:37:40.352717Z","shell.execute_reply.started":"2023-01-30T18:37:40.345388Z","shell.execute_reply":"2023-01-30T18:37:40.352099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tokenizer('What is the really (dealing) here?')","metadata":{"id":"LBA0LF30nGNY","outputId":"99d98aa9-6e46-4fc4-89c6-9995fd6c49b5","execution":{"iopub.status.busy":"2023-01-30T18:37:40.353568Z","iopub.execute_input":"2023-01-30T18:37:40.354259Z","iopub.status.idle":"2023-01-30T18:37:40.363464Z","shell.execute_reply.started":"2023-01-30T18:37:40.354234Z","shell.execute_reply":"2023-01-30T18:37:40.362863Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"vectorizer = CountVectorizer(lowercase=True,tokenizer=tokenizer,stop_words=english_words,max_features=1000)","metadata":{"id":"pBrQeH0HmtQO","execution":{"iopub.status.busy":"2023-01-30T18:37:40.364366Z","iopub.execute_input":"2023-01-30T18:37:40.364935Z","iopub.status.idle":"2023-01-30T18:37:40.372368Z","shell.execute_reply.started":"2023-01-30T18:37:40.364909Z","shell.execute_reply":"2023-01-30T18:37:40.371454Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\nvectorizer.fit(sample_df.question_text)","metadata":{"id":"g6quoLSCm7n6","outputId":"b3b52194-244a-45ef-982c-8aaf4b18fb05","execution":{"iopub.status.busy":"2023-01-30T18:37:40.373652Z","iopub.execute_input":"2023-01-30T18:37:40.374570Z","iopub.status.idle":"2023-01-30T18:38:08.055720Z","shell.execute_reply.started":"2023-01-30T18:37:40.374536Z","shell.execute_reply":"2023-01-30T18:38:08.054889Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(vectorizer.vocabulary_)","metadata":{"id":"tY2wsKSho_v-","outputId":"1e6ce7ab-2c07-4189-9068-109b30739384","execution":{"iopub.status.busy":"2023-01-30T18:38:08.056895Z","iopub.execute_input":"2023-01-30T18:38:08.057235Z","iopub.status.idle":"2023-01-30T18:38:08.064947Z","shell.execute_reply.started":"2023-01-30T18:38:08.057202Z","shell.execute_reply":"2023-01-30T18:38:08.063696Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"vectorizer.get_feature_names_out()[:100]","metadata":{"id":"t6f5Wwiyp4gO","outputId":"4d47cdcb-6502-406f-8332-9fffb1d701a2","execution":{"iopub.status.busy":"2023-01-30T18:38:08.066203Z","iopub.execute_input":"2023-01-30T18:38:08.066517Z","iopub.status.idle":"2023-01-30T18:38:08.079197Z","shell.execute_reply.started":"2023-01-30T18:38:08.066494Z","shell.execute_reply":"2023-01-30T18:38:08.077936Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\ninputs = vectorizer.transform(sample_df.question_text)","metadata":{"id":"09_duJxcqERj","outputId":"b66f4e46-6e35-4ffe-d383-6b3cbe452f6a","execution":{"iopub.status.busy":"2023-01-30T18:38:08.080507Z","iopub.execute_input":"2023-01-30T18:38:08.080970Z","iopub.status.idle":"2023-01-30T18:38:35.676666Z","shell.execute_reply.started":"2023-01-30T18:38:08.080942Z","shell.execute_reply":"2023-01-30T18:38:35.675460Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"inputs.shape","metadata":{"id":"hlqMe0_Dqjn4","outputId":"428a3b0c-7e6d-4d02-d88b-b87e4a23f627","execution":{"iopub.status.busy":"2023-01-30T18:38:35.679499Z","iopub.execute_input":"2023-01-30T18:38:35.679836Z","iopub.status.idle":"2023-01-30T18:38:35.687915Z","shell.execute_reply.started":"2023-01-30T18:38:35.679806Z","shell.execute_reply":"2023-01-30T18:38:35.686545Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"inputs","metadata":{"id":"Pgb8L-lfquCf","outputId":"ffa1066a-cfcf-4800-8618-c983da358c46","execution":{"iopub.status.busy":"2023-01-30T18:38:35.689310Z","iopub.execute_input":"2023-01-30T18:38:35.689683Z","iopub.status.idle":"2023-01-30T18:38:35.699128Z","shell.execute_reply.started":"2023-01-30T18:38:35.689649Z","shell.execute_reply":"2023-01-30T18:38:35.698250Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_df.question_text.values[0]","metadata":{"id":"DwB6FUfkq4St","outputId":"a51399e9-79fe-4e3c-f27f-d815ffee8889","execution":{"iopub.status.busy":"2023-01-30T18:38:35.700279Z","iopub.execute_input":"2023-01-30T18:38:35.700792Z","iopub.status.idle":"2023-01-30T18:38:35.708793Z","shell.execute_reply.started":"2023-01-30T18:38:35.700765Z","shell.execute_reply":"2023-01-30T18:38:35.707653Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df","metadata":{"id":"nkTUdJLAq1P9","outputId":"11274f14-d25d-4d03-aa72-37710bb641d3","execution":{"iopub.status.busy":"2023-01-30T18:38:35.710584Z","iopub.execute_input":"2023-01-30T18:38:35.710944Z","iopub.status.idle":"2023-01-30T18:38:35.725223Z","shell.execute_reply.started":"2023-01-30T18:38:35.710915Z","shell.execute_reply":"2023-01-30T18:38:35.724167Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\ntest_inputs = vectorizer.transform(test_df.question_text)","metadata":{"id":"7EsCX1iCrLNC","outputId":"db52d047-5f03-440f-b63f-595afa881983","execution":{"iopub.status.busy":"2023-01-30T18:38:35.726069Z","iopub.execute_input":"2023-01-30T18:38:35.726299Z","iopub.status.idle":"2023-01-30T18:39:04.281232Z","shell.execute_reply.started":"2023-01-30T18:38:35.726276Z","shell.execute_reply":"2023-01-30T18:39:04.280340Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_inputs.shape","metadata":{"id":"-8moKM9vrZ3t","outputId":"f332222d-4f5f-4c18-cd9b-a0fee2e9af81","execution":{"iopub.status.busy":"2023-01-30T18:39:04.292419Z","iopub.execute_input":"2023-01-30T18:39:04.292902Z","iopub.status.idle":"2023-01-30T18:39:04.299471Z","shell.execute_reply.started":"2023-01-30T18:39:04.292873Z","shell.execute_reply":"2023-01-30T18:39:04.298203Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## ML Model for text Classification\n\noutline :\n - Create a training & validation set \n - Train a logistic regression model \n - make  prediction on training    validation & test data ","metadata":{"id":"enKnnIuzsGVs"}},{"cell_type":"code","source":"sample_df","metadata":{"id":"P7rgplFUr3UF","outputId":"b29f4588-e873-49ff-fefc-9e0e7eb0f815","execution":{"iopub.status.busy":"2023-01-30T18:39:04.301024Z","iopub.execute_input":"2023-01-30T18:39:04.301305Z","iopub.status.idle":"2023-01-30T18:39:04.317596Z","shell.execute_reply.started":"2023-01-30T18:39:04.301280Z","shell.execute_reply":"2023-01-30T18:39:04.316580Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"inputs.shape","metadata":{"id":"xaXbBZmqslA5","outputId":"c6507987-7673-4608-fe1d-36eaa40c9971","execution":{"iopub.status.busy":"2023-01-30T18:39:04.319127Z","iopub.execute_input":"2023-01-30T18:39:04.319386Z","iopub.status.idle":"2023-01-30T18:39:04.328608Z","shell.execute_reply.started":"2023-01-30T18:39:04.319364Z","shell.execute_reply":"2023-01-30T18:39:04.327631Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split","metadata":{"id":"ZYO3xnvvs5fH","execution":{"iopub.status.busy":"2023-01-30T18:39:04.329661Z","iopub.execute_input":"2023-01-30T18:39:04.330359Z","iopub.status.idle":"2023-01-30T18:39:04.337595Z","shell.execute_reply.started":"2023-01-30T18:39:04.330329Z","shell.execute_reply":"2023-01-30T18:39:04.336721Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_inputs , val_inputs , train_targets , val_targets = train_test_split(inputs,sample_df.target,test_size=0.3,random_state=42)","metadata":{"id":"Yy-uixkFsnil","execution":{"iopub.status.busy":"2023-01-30T18:39:04.339213Z","iopub.execute_input":"2023-01-30T18:39:04.339808Z","iopub.status.idle":"2023-01-30T18:39:04.359504Z","shell.execute_reply.started":"2023-01-30T18:39:04.339777Z","shell.execute_reply":"2023-01-30T18:39:04.358800Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_inputs.shape","metadata":{"id":"BFyqqt09tOUl","outputId":"1939bb19-cfca-4f34-9162-b31c225ab030","execution":{"iopub.status.busy":"2023-01-30T18:39:04.360740Z","iopub.execute_input":"2023-01-30T18:39:04.361024Z","iopub.status.idle":"2023-01-30T18:39:04.366832Z","shell.execute_reply.started":"2023-01-30T18:39:04.360999Z","shell.execute_reply":"2023-01-30T18:39:04.365868Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_targets.shape","metadata":{"id":"YzoJUX6_tUSE","outputId":"001b24e5-340f-4179-e787-b2dff0ec3a8d","execution":{"iopub.status.busy":"2023-01-30T18:39:04.368235Z","iopub.execute_input":"2023-01-30T18:39:04.368521Z","iopub.status.idle":"2023-01-30T18:39:04.378453Z","shell.execute_reply.started":"2023-01-30T18:39:04.368493Z","shell.execute_reply":"2023-01-30T18:39:04.377540Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"val_inputs.shape","metadata":{"id":"dBDKjsNrtZFw","outputId":"df396293-ce7a-4d3a-f59b-23dde2bcbbaa","execution":{"iopub.status.busy":"2023-01-30T18:39:04.379870Z","iopub.execute_input":"2023-01-30T18:39:04.380360Z","iopub.status.idle":"2023-01-30T18:39:04.388488Z","shell.execute_reply.started":"2023-01-30T18:39:04.380326Z","shell.execute_reply":"2023-01-30T18:39:04.387693Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"val_targets.shape","metadata":{"id":"1s3CDniUthzM","outputId":"f35f475b-78da-4c1a-f841-d08dc943bc1e","execution":{"iopub.status.busy":"2023-01-30T18:39:04.390147Z","iopub.execute_input":"2023-01-30T18:39:04.390472Z","iopub.status.idle":"2023-01-30T18:39:04.399727Z","shell.execute_reply.started":"2023-01-30T18:39:04.390445Z","shell.execute_reply":"2023-01-30T18:39:04.398777Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"##Logistic Regression ","metadata":{"id":"BE5J1tNgtxcZ"}},{"cell_type":"code","source":"from sklearn.linear_model import LogisticRegression","metadata":{"id":"43BlZ6umt15p","execution":{"iopub.status.busy":"2023-01-30T18:39:04.401090Z","iopub.execute_input":"2023-01-30T18:39:04.401356Z","iopub.status.idle":"2023-01-30T18:39:04.407889Z","shell.execute_reply.started":"2023-01-30T18:39:04.401333Z","shell.execute_reply":"2023-01-30T18:39:04.407066Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"MAX_ITER = 1000","metadata":{"id":"wcimA6PEuhfg","execution":{"iopub.status.busy":"2023-01-30T18:39:04.408790Z","iopub.execute_input":"2023-01-30T18:39:04.409468Z","iopub.status.idle":"2023-01-30T18:39:04.420538Z","shell.execute_reply.started":"2023-01-30T18:39:04.409440Z","shell.execute_reply":"2023-01-30T18:39:04.418956Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = LogisticRegression(max_iter=1000,solver='sag')","metadata":{"id":"xsQrpMNkt-Vn","execution":{"iopub.status.busy":"2023-01-30T18:39:04.424592Z","iopub.execute_input":"2023-01-30T18:39:04.425351Z","iopub.status.idle":"2023-01-30T18:39:04.431235Z","shell.execute_reply.started":"2023-01-30T18:39:04.425303Z","shell.execute_reply":"2023-01-30T18:39:04.430357Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\nmodel.fit(train_inputs,train_targets)","metadata":{"id":"UNtKUzYmuBP2","outputId":"cf2d5305-7ee9-4639-9f63-1e3d513fc34a","execution":{"iopub.status.busy":"2023-01-30T18:39:04.432331Z","iopub.execute_input":"2023-01-30T18:39:04.432764Z","iopub.status.idle":"2023-01-30T18:39:26.458634Z","shell.execute_reply.started":"2023-01-30T18:39:04.432738Z","shell.execute_reply":"2023-01-30T18:39:26.457744Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Make Prediction and Submit to kaggle ","metadata":{"id":"d1efo1_-tqh9"}},{"cell_type":"code","source":"train_pred = model.predict(train_inputs)","metadata":{"id":"aVIt78HhtjdS","execution":{"iopub.status.busy":"2023-01-30T18:39:26.459639Z","iopub.execute_input":"2023-01-30T18:39:26.459952Z","iopub.status.idle":"2023-01-30T18:39:26.466041Z","shell.execute_reply.started":"2023-01-30T18:39:26.459924Z","shell.execute_reply":"2023-01-30T18:39:26.464687Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.Series(train_pred).value_counts()","metadata":{"id":"SwwSr9jLvJ2K","outputId":"e88970f6-df3a-48af-f0cc-3587ad6dbf99","execution":{"iopub.status.busy":"2023-01-30T18:39:26.467255Z","iopub.execute_input":"2023-01-30T18:39:26.467559Z","iopub.status.idle":"2023-01-30T18:39:26.492398Z","shell.execute_reply.started":"2023-01-30T18:39:26.467528Z","shell.execute_reply":"2023-01-30T18:39:26.490959Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.Series(train_targets).value_counts()","metadata":{"id":"UrrNSXY6vL4A","outputId":"962adc69-5948-4be1-b97d-68c6df4dfe1c","execution":{"iopub.status.busy":"2023-01-30T18:39:26.493967Z","iopub.execute_input":"2023-01-30T18:39:26.494246Z","iopub.status.idle":"2023-01-30T18:39:26.506006Z","shell.execute_reply.started":"2023-01-30T18:39:26.494221Z","shell.execute_reply":"2023-01-30T18:39:26.504857Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import accuracy_score","metadata":{"id":"r5oRcFYmvh9z","execution":{"iopub.status.busy":"2023-01-30T18:39:26.507661Z","iopub.execute_input":"2023-01-30T18:39:26.507971Z","iopub.status.idle":"2023-01-30T18:39:26.512984Z","shell.execute_reply.started":"2023-01-30T18:39:26.507945Z","shell.execute_reply":"2023-01-30T18:39:26.511812Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"accuracy_score(train_targets,train_pred)","metadata":{"id":"6xVPZYIFvut5","outputId":"83c3007f-2737-40b5-97d8-375b150d879a","execution":{"iopub.status.busy":"2023-01-30T18:39:26.514542Z","iopub.execute_input":"2023-01-30T18:39:26.514823Z","iopub.status.idle":"2023-01-30T18:39:26.529638Z","shell.execute_reply.started":"2023-01-30T18:39:26.514798Z","shell.execute_reply":"2023-01-30T18:39:26.528757Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np","metadata":{"id":"WA3X3Wc_wIu9","execution":{"iopub.status.busy":"2023-01-30T18:39:26.530763Z","iopub.execute_input":"2023-01-30T18:39:26.531728Z","iopub.status.idle":"2023-01-30T18:39:26.535799Z","shell.execute_reply.started":"2023-01-30T18:39:26.531695Z","shell.execute_reply":"2023-01-30T18:39:26.534998Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"accuracy_score(train_targets,np.zeros(len(train_targets)))","metadata":{"id":"9IZRd41Wv2og","outputId":"8a90a4b0-901d-4aba-c8fc-bffc6284432d","execution":{"iopub.status.busy":"2023-01-30T18:39:26.536906Z","iopub.execute_input":"2023-01-30T18:39:26.538063Z","iopub.status.idle":"2023-01-30T18:39:26.555081Z","shell.execute_reply.started":"2023-01-30T18:39:26.537894Z","shell.execute_reply":"2023-01-30T18:39:26.554417Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import f1_score","metadata":{"id":"g66ANaDrwR-P","execution":{"iopub.status.busy":"2023-01-30T18:39:26.556125Z","iopub.execute_input":"2023-01-30T18:39:26.556519Z","iopub.status.idle":"2023-01-30T18:39:26.559593Z","shell.execute_reply.started":"2023-01-30T18:39:26.556493Z","shell.execute_reply":"2023-01-30T18:39:26.559001Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"f1_score(train_targets,train_pred)","metadata":{"id":"fGyRLOVYwfdW","outputId":"e497e9bb-760e-4395-ba93-50712896bfe5","execution":{"iopub.status.busy":"2023-01-30T18:39:26.560526Z","iopub.execute_input":"2023-01-30T18:39:26.560954Z","iopub.status.idle":"2023-01-30T18:39:26.583602Z","shell.execute_reply.started":"2023-01-30T18:39:26.560930Z","shell.execute_reply":"2023-01-30T18:39:26.583009Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"f1_score(train_targets,np.zeros(len(train_targets)))","metadata":{"id":"YOH2JERXwogR","outputId":"8a73375e-7bf2-454c-a75a-d96488ef0848","execution":{"iopub.status.busy":"2023-01-30T18:39:26.584635Z","iopub.execute_input":"2023-01-30T18:39:26.585033Z","iopub.status.idle":"2023-01-30T18:39:26.618072Z","shell.execute_reply.started":"2023-01-30T18:39:26.585008Z","shell.execute_reply":"2023-01-30T18:39:26.616963Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"random_pred = np.random.choice((0,1),len(train_targets))\nf1_score(train_targets,random_pred)","metadata":{"id":"h6CDMCRswvdV","outputId":"54301070-e98d-454d-c5d9-bb826c7ad856","execution":{"iopub.status.busy":"2023-01-30T18:39:26.619357Z","iopub.execute_input":"2023-01-30T18:39:26.619689Z","iopub.status.idle":"2023-01-30T18:39:26.644633Z","shell.execute_reply.started":"2023-01-30T18:39:26.619658Z","shell.execute_reply":"2023-01-30T18:39:26.643534Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"val_pred = model.predict(val_inputs)","metadata":{"id":"Z9qh_X1IxN8t","execution":{"iopub.status.busy":"2023-01-30T18:39:26.645877Z","iopub.execute_input":"2023-01-30T18:39:26.646223Z","iopub.status.idle":"2023-01-30T18:39:26.652094Z","shell.execute_reply.started":"2023-01-30T18:39:26.646191Z","shell.execute_reply":"2023-01-30T18:39:26.650991Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"accuracy_score(val_targets,val_pred)","metadata":{"id":"-d8Embexx-LT","outputId":"98eaf92a-9758-4caa-e655-9888f02a0714","execution":{"iopub.status.busy":"2023-01-30T18:39:26.653175Z","iopub.execute_input":"2023-01-30T18:39:26.653421Z","iopub.status.idle":"2023-01-30T18:39:26.664708Z","shell.execute_reply.started":"2023-01-30T18:39:26.653398Z","shell.execute_reply":"2023-01-30T18:39:26.663632Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"f1_score(val_targets,val_pred)","metadata":{"id":"BCzoBwwryF0z","outputId":"ccab4f14-978c-4f74-fef2-b84ae562bf83","execution":{"iopub.status.busy":"2023-01-30T18:39:26.666011Z","iopub.execute_input":"2023-01-30T18:39:26.666323Z","iopub.status.idle":"2023-01-30T18:39:26.681035Z","shell.execute_reply.started":"2023-01-30T18:39:26.666292Z","shell.execute_reply":"2023-01-30T18:39:26.680051Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sincere_df.question_text.values[:10]","metadata":{"id":"TZOPl7yiySwt","outputId":"71777658-97e5-41f1-bc4f-50ce1d3867e9","execution":{"iopub.status.busy":"2023-01-30T18:39:26.684243Z","iopub.execute_input":"2023-01-30T18:39:26.684501Z","iopub.status.idle":"2023-01-30T18:39:26.691382Z","shell.execute_reply.started":"2023-01-30T18:39:26.684477Z","shell.execute_reply":"2023-01-30T18:39:26.690561Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sincere_df","metadata":{"id":"Za5bauuoyj0I","outputId":"b016427d-0ccf-49be-f2e4-1f5c83866c6e","execution":{"iopub.status.busy":"2023-01-30T18:39:26.692683Z","iopub.execute_input":"2023-01-30T18:39:26.693357Z","iopub.status.idle":"2023-01-30T18:39:26.708527Z","shell.execute_reply.started":"2023-01-30T18:39:26.693323Z","shell.execute_reply":"2023-01-30T18:39:26.707597Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sincere_df.target.values[:10]","metadata":{"id":"1OrewcqeymTr","outputId":"52cad250-d757-4147-eafa-70a5c5b0cfe7","execution":{"iopub.status.busy":"2023-01-30T18:39:26.709760Z","iopub.execute_input":"2023-01-30T18:39:26.710282Z","iopub.status.idle":"2023-01-30T18:39:26.717704Z","shell.execute_reply.started":"2023-01-30T18:39:26.710250Z","shell.execute_reply":"2023-01-30T18:39:26.717071Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.predict(vectorizer.transform(sincere_df.question_text.values[:10]))","metadata":{"id":"yzvHhDggys_1","outputId":"a162d234-65c0-4ce6-aa69-0495be1fcef8","execution":{"iopub.status.busy":"2023-01-30T18:39:26.719899Z","iopub.execute_input":"2023-01-30T18:39:26.722037Z","iopub.status.idle":"2023-01-30T18:39:26.734508Z","shell.execute_reply.started":"2023-01-30T18:39:26.722009Z","shell.execute_reply":"2023-01-30T18:39:26.733563Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"insincere_df.target.values[:10]","metadata":{"id":"l7-3KICiy_PI","outputId":"8fee354c-6c8c-4396-f1f4-579fbc9ca623","execution":{"iopub.status.busy":"2023-01-30T18:39:26.736798Z","iopub.execute_input":"2023-01-30T18:39:26.737740Z","iopub.status.idle":"2023-01-30T18:39:26.745770Z","shell.execute_reply.started":"2023-01-30T18:39:26.737698Z","shell.execute_reply":"2023-01-30T18:39:26.744746Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.predict(vectorizer.transform(insincere_df.question_text.values[:10]))","metadata":{"id":"-I6nK76QzncK","outputId":"da045255-1d9b-49b2-e41b-b63e59b46467","execution":{"iopub.status.busy":"2023-01-30T18:39:26.747012Z","iopub.execute_input":"2023-01-30T18:39:26.747274Z","iopub.status.idle":"2023-01-30T18:39:26.763082Z","shell.execute_reply.started":"2023-01-30T18:39:26.747250Z","shell.execute_reply":"2023-01-30T18:39:26.761785Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df","metadata":{"id":"4x6vUZ1bzqp2","outputId":"7467878c-be11-4f19-d7e0-068bb395b526","execution":{"iopub.status.busy":"2023-01-30T18:39:26.764513Z","iopub.execute_input":"2023-01-30T18:39:26.764834Z","iopub.status.idle":"2023-01-30T18:39:26.776476Z","shell.execute_reply.started":"2023-01-30T18:39:26.764807Z","shell.execute_reply":"2023-01-30T18:39:26.775623Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_inputs.shape","metadata":{"id":"axUELBON0UdE","outputId":"1827e086-5f60-46ca-d70b-2c58ca676320","execution":{"iopub.status.busy":"2023-01-30T18:39:26.779616Z","iopub.execute_input":"2023-01-30T18:39:26.779917Z","iopub.status.idle":"2023-01-30T18:39:26.785397Z","shell.execute_reply.started":"2023-01-30T18:39:26.779893Z","shell.execute_reply":"2023-01-30T18:39:26.784320Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_pred = model.predict(test_inputs)","metadata":{"id":"_qF6koSE0XBB","execution":{"iopub.status.busy":"2023-01-30T18:39:26.786814Z","iopub.execute_input":"2023-01-30T18:39:26.787207Z","iopub.status.idle":"2023-01-30T18:39:26.803517Z","shell.execute_reply.started":"2023-01-30T18:39:26.787171Z","shell.execute_reply":"2023-01-30T18:39:26.802659Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df","metadata":{"id":"jA-o5d0N0hIG","outputId":"4d15ca15-5153-4baf-8edd-ebbae77e67e0","execution":{"iopub.status.busy":"2023-01-30T18:39:26.804666Z","iopub.execute_input":"2023-01-30T18:39:26.804999Z","iopub.status.idle":"2023-01-30T18:39:26.815975Z","shell.execute_reply.started":"2023-01-30T18:39:26.804966Z","shell.execute_reply":"2023-01-30T18:39:26.815136Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df.prediction = test_pred","metadata":{"id":"RPO__nzx0lxH","execution":{"iopub.status.busy":"2023-01-30T18:39:26.817303Z","iopub.execute_input":"2023-01-30T18:39:26.817617Z","iopub.status.idle":"2023-01-30T18:39:26.825393Z","shell.execute_reply.started":"2023-01-30T18:39:26.817586Z","shell.execute_reply":"2023-01-30T18:39:26.824759Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df.prediction.value_counts()","metadata":{"id":"eZmMSk1x0vGC","outputId":"2b0d143a-a4e5-4cfc-81f3-14c96d0bbba6","execution":{"iopub.status.busy":"2023-01-30T18:39:26.826695Z","iopub.execute_input":"2023-01-30T18:39:26.826983Z","iopub.status.idle":"2023-01-30T18:39:26.843769Z","shell.execute_reply.started":"2023-01-30T18:39:26.826956Z","shell.execute_reply":"2023-01-30T18:39:26.842934Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df.to_csv('submission.csv',index=None)","metadata":{"id":"EXdUC08w01C7","execution":{"iopub.status.busy":"2023-01-30T18:39:26.844875Z","iopub.execute_input":"2023-01-30T18:39:26.845739Z","iopub.status.idle":"2023-01-30T18:39:27.212720Z","shell.execute_reply.started":"2023-01-30T18:39:26.845694Z","shell.execute_reply":"2023-01-30T18:39:27.211747Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"!head submission.csv","metadata":{"id":"74i4jU3e1I53","outputId":"4c5fa8bf-60e8-4023-9237-206660c541c0","execution":{"iopub.status.busy":"2023-01-30T18:39:27.213916Z","iopub.execute_input":"2023-01-30T18:39:27.214329Z","iopub.status.idle":"2023-01-30T18:39:27.500417Z","shell.execute_reply.started":"2023-01-30T18:39:27.214304Z","shell.execute_reply":"2023-01-30T18:39:27.499315Z"},"trusted":true},"execution_count":null,"outputs":[]}]}