{"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 pandas as pd\nimport numpy as np\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport os\n\nimport nltk\nnltk.download('stopwords')\nnltk.download('wordnet')\nnltk.download('punkt')\nnltk.download('averaged_perceptron_tagger') \nfrom nltk.corpus import stopwords\nfrom nltk.tokenize import word_tokenize  \nimport re,unicodedata\nfrom nltk.corpus import wordnet\nfrom wordcloud import WordCloud\nimport contractions\n\nfrom sklearn.model_selection import train_test_split","metadata":{"id":"asn4mH3RMSso","outputId":"6064835f-b487-429d-a3dd-6fb7719ad273","execution":{"iopub.status.busy":"2022-07-08T03:48:36.713694Z","iopub.execute_input":"2022-07-08T03:48:36.714047Z","iopub.status.idle":"2022-07-08T03:48:36.722909Z","shell.execute_reply.started":"2022-07-08T03:48:36.714017Z","shell.execute_reply":"2022-07-08T03:48:36.721614Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import tensorflow\nfrom tensorflow.keras.preprocessing.text import  Tokenizer\nfrom tensorflow.keras.preprocessing.sequence import pad_sequences\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.callbacks import EarlyStopping,ReduceLROnPlateau\nfrom tensorflow.keras.layers import Embedding,Dense,Bidirectional,LSTM, Dropout,SeparableConv1D,Flatten\nfrom tensorflow.keras.utils import  plot_model\nfrom tensorflow.keras.utils import to_categorical","metadata":{"id":"FSBDtMCJOeL7","execution":{"iopub.status.busy":"2022-07-08T03:48:38.127238Z","iopub.execute_input":"2022-07-08T03:48:38.127924Z","iopub.status.idle":"2022-07-08T03:48:38.134044Z","shell.execute_reply.started":"2022-07-08T03:48:38.127887Z","shell.execute_reply":"2022-07-08T03:48:38.132965Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"base_path = '../input/nlp-getting-started/'\nglove_file_path  = '../input/glovedata/glove.6B.200d.txt'\ntrain_data = pd.read_csv('../input/nlp-getting-started/train.csv')\ntest_data = pd.read_csv('../input/nlp-getting-started/test.csv')\n\ntrain_data['isTrain'] = ['True']* len(train_data)\ntest_data['isTrain'] = ['False'] * len(test_data)\n","metadata":{"id":"2tUE4FHbMjbb","execution":{"iopub.status.busy":"2022-07-08T03:48:38.521129Z","iopub.execute_input":"2022-07-08T03:48:38.521989Z","iopub.status.idle":"2022-07-08T03:48:38.557028Z","shell.execute_reply.started":"2022-07-08T03:48:38.521951Z","shell.execute_reply":"2022-07-08T03:48:38.556038Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combined_data = pd.concat([train_data,test_data])\n\n# tweets from top 10 locations\nlocaition_value_counts = combined_data['location'].dropna().value_counts().to_frame()\nvalue_counts_top = locaition_value_counts.iloc[0:10]\nplt.pie(labels=value_counts_top.index,x=value_counts_top.location,autopct='%.0f%%')","metadata":{"id":"ZIJfwOaSNRdb","outputId":"228d942e-e031-47e4-e39e-a7be92e1dc51","execution":{"iopub.status.busy":"2022-07-08T03:48:39.812234Z","iopub.execute_input":"2022-07-08T03:48:39.812924Z","iopub.status.idle":"2022-07-08T03:48:39.973381Z","shell.execute_reply.started":"2022-07-08T03:48:39.812888Z","shell.execute_reply":"2022-07-08T03:48:39.972305Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# target label data distribution\nsns.countplot(combined_data.target[combined_data.isTrain == 'True'])","metadata":{"id":"Fmf8NOD8NURY","outputId":"f345858b-8a1a-4372-fd31-9804954110ca","execution":{"iopub.status.busy":"2022-07-08T03:48:40.009946Z","iopub.execute_input":"2022-07-08T03:48:40.010453Z","iopub.status.idle":"2022-07-08T03:48:40.155661Z","shell.execute_reply.started":"2022-07-08T03:48:40.010409Z","shell.execute_reply":"2022-07-08T03:48:40.15448Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# =============================================================================\n# cleaning data\n# =============================================================================\n\ndef remove_urls(line):\n    urlPattern = '\\s*https?:\\/\\/.*[\\r\\n]*'\n    sample =  re.sub(urlPattern,'',line,flags=re.MULTILINE)\n    return sample\n\ndef remove_non_ascii(words):\n    \"\"\"Remove non-ASCII characters from list of tokenized words\"\"\"\n    new_words = []\n    for word in words:\n        new_word = unicodedata.normalize('NFKD', word).encode('ascii', 'ignore').decode('utf-8', 'ignore')\n        new_words.append(new_word)\n    return new_words\n\ndef remove_tagged_users(words):    \n    pattern = '(@\\w+)'\n    filtered_users = []\n    for word in words:\n        sample =  re.sub(pattern,'',word)\n        if sample != '':\n            filtered_users.append(sample)\n    return filtered_users\n\ndef filter_stop_words(words,stop_words):\n    no_stop_words = []\n    full_sentence = ' '.join(words)\n    for word in word_tokenize(full_sentence):\n        if word not in stop_words:\n            no_stop_words.append(word)\n    return no_stop_words\n\ndef word_contractions(words):\n    contractions_words = []\n    pattern = '^&\\w+\\s*;$'\n    for word in words:\n        sample =  re.sub(pattern,'',word)\n        if sample != '':\n            contractions_words.append(contractions.fix(sample))\n    return contractions_words\n\ndef remove_punctuations(words):\n    non_punc_words = []\n    pattern = '[^a-zA-Z\\s]'\n    for word in words:\n        new_word = re.sub(pattern,'',word)\n        if new_word != '':\n            non_punc_words.append(new_word)\n    return non_punc_words\n\ndef get_wordnet_pos(treebank_tag):\n    if treebank_tag.startswith('J'):\n        return wordnet.ADJ\n    elif treebank_tag.startswith('V'):\n        return wordnet.VERB\n    elif treebank_tag.startswith('N'):\n        return wordnet.NOUN\n    elif treebank_tag.startswith('R'):\n        return wordnet.ADV\n    else:\n        return None # for easy if-statement \n\ndef lemmatize_word(words):\n    lem_words = []\n    lem = nltk.stem.WordNetLemmatizer()\n    pos_of_words = nltk.pos_tag(words)\n    for word,tag in pos_of_words:\n        word = word.lower()\n        if get_wordnet_pos(tag) != None:\n            lem_word = lem.lemmatize(word=word,pos=get_wordnet_pos(tag))\n            lem_words.append(lem_word)\n        else:\n            lem_word = lem.lemmatize(word=word)\n            lem_words.append(lem_word)\n    return lem_words\n\ndef correct_spellings(words):\n    spell = SpellChecker()\n    corrected_text = []\n    misspelled_words = spell.unknown(words)\n    for word in words:\n        if word in misspelled_words:\n            corrected_text.append(spell.correction(word))\n        else:\n            corrected_text.append(word)\n    return corrected_text\n        \n\ndef clean_tweets(df):\n    df = df.copy()\n    final_tweet = []\n    stop_words = stopwords.words('english')\n    for sentence in df['text']:\n        ulr_removed_sentence = remove_urls(sentence)\n        words = ulr_removed_sentence.split(' ')\n        new_words = remove_non_ascii(words)\n        non_usr_tagged_words = remove_tagged_users(new_words)\n        contraction_words = word_contractions(non_usr_tagged_words)       \n        no_stop_words = filter_stop_words(contraction_words,stop_words)\n        non_punc_words = remove_punctuations(no_stop_words)\n        # spell_check_words = correct_spellings(non_punc_words)\n        lem_words = lemmatize_word(non_punc_words)\n        pre_clean_sentence = ' '.join(lem_words)\n        final_tweet.append(pre_clean_sentence)\n    return final_tweet","metadata":{"id":"oXwlQpC1NYaP","execution":{"iopub.status.busy":"2022-07-08T03:48:40.185849Z","iopub.execute_input":"2022-07-08T03:48:40.186418Z","iopub.status.idle":"2022-07-08T03:48:40.2073Z","shell.execute_reply.started":"2022-07-08T03:48:40.186373Z","shell.execute_reply":"2022-07-08T03:48:40.206297Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cleaned_tweets = clean_tweets(combined_data)\ncombined_data['cleaned_tweets'] = cleaned_tweets","metadata":{"id":"Lfq8gDv-Nbut","execution":{"iopub.status.busy":"2022-07-08T03:48:40.384598Z","iopub.execute_input":"2022-07-08T03:48:40.38527Z","iopub.status.idle":"2022-07-08T03:48:53.768136Z","shell.execute_reply.started":"2022-07-08T03:48:40.385217Z","shell.execute_reply":"2022-07-08T03:48:53.76716Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# filter tweets length has to to be greater than 1\n# filtered_data = combined_data[combined_data.cleaned_tweets.str.len() > 1]\nfiltered_data = combined_data.copy()\nfiltered_data.drop(columns=['text','keyword','location'],inplace=True)\nfiltered_data.head()","metadata":{"id":"VSyuL3dDNsxo","execution":{"iopub.status.busy":"2022-07-08T03:48:53.770029Z","iopub.execute_input":"2022-07-08T03:48:53.770373Z","iopub.status.idle":"2022-07-08T03:48:53.789655Z","shell.execute_reply.started":"2022-07-08T03:48:53.770346Z","shell.execute_reply":"2022-07-08T03:48:53.788525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cleaned_train_data = filtered_data[filtered_data.isTrain == 'True'].drop(columns='isTrain')\ncleaned_test_data = filtered_data[filtered_data.isTrain == 'False'].drop(columns=['isTrain','target'])","metadata":{"id":"e0iK9XjFNzk2","execution":{"iopub.status.busy":"2022-07-08T03:48:53.791556Z","iopub.execute_input":"2022-07-08T03:48:53.792927Z","iopub.status.idle":"2022-07-08T03:48:53.808304Z","shell.execute_reply.started":"2022-07-08T03:48:53.792884Z","shell.execute_reply":"2022-07-08T03:48:53.807372Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"wc = WordCloud(max_words = 1000 , width = 1600 , height = 800,\n               collocations=False).generate(\" \".join(filtered_data['cleaned_tweets']))\nplt.imshow(wc)\nplt.title('filtered_data')","metadata":{"id":"zcowd0haN1Jz","outputId":"29e8eb7e-8c71-4873-9259-6f8e98a331c1","execution":{"iopub.status.busy":"2022-07-08T03:48:53.811327Z","iopub.execute_input":"2022-07-08T03:48:53.811715Z","iopub.status.idle":"2022-07-08T03:49:02.75517Z","shell.execute_reply.started":"2022-07-08T03:48:53.811679Z","shell.execute_reply":"2022-07-08T03:49:02.754195Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"wc = WordCloud(max_words = 1000 , width = 1600 , height = 800,\n               collocations=False).generate(\" \".join(cleaned_train_data['cleaned_tweets']))\nplt.imshow(wc)\nplt.title('cleaned_train_data')","metadata":{"id":"iRO3sIn1N3CY","outputId":"4b0f7fc2-43ca-431c-b50c-ab94eae13746","execution":{"iopub.status.busy":"2022-07-08T03:49:02.756555Z","iopub.execute_input":"2022-07-08T03:49:02.757501Z","iopub.status.idle":"2022-07-08T03:49:11.155978Z","shell.execute_reply.started":"2022-07-08T03:49:02.757456Z","shell.execute_reply":"2022-07-08T03:49:11.155079Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"wc = WordCloud(max_words = 1000 , width = 1600 , height = 1600,\n               collocations=False).generate(\" \".join(cleaned_test_data['cleaned_tweets']))\nplt.imshow(wc)\nplt.title('cleaned_test_data')","metadata":{"id":"4F_-5KWwN5m1","outputId":"9e4db849-c688-47d9-a484-a4a3900e1c11","execution":{"iopub.status.busy":"2022-07-08T03:49:11.157681Z","iopub.execute_input":"2022-07-08T03:49:11.158436Z","iopub.status.idle":"2022-07-08T03:49:28.107168Z","shell.execute_reply.started":"2022-07-08T03:49:11.158396Z","shell.execute_reply":"2022-07-08T03:49:28.106257Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**---------**","metadata":{"id":"Hf_TYTiKOx6S"}},{"cell_type":"code","source":"max_features = 10000\nmaxlen = 50\nembedding_size = 200","metadata":{"id":"8x8rZS_cOxcw","execution":{"iopub.status.busy":"2022-07-08T03:49:28.10944Z","iopub.execute_input":"2022-07-08T03:49:28.110522Z","iopub.status.idle":"2022-07-08T03:49:28.115192Z","shell.execute_reply.started":"2022-07-08T03:49:28.110473Z","shell.execute_reply":"2022-07-08T03:49:28.114308Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def prepareSequences(df):\n  data = df.copy()\n  tokenizer = Tokenizer(num_words=max_features,split=' ')\n  tokenizer.fit_on_texts(data['cleaned_tweets'].values)\n  sequences = tokenizer.texts_to_sequences(data['cleaned_tweets'].values)\n  return (sequences,tokenizer)","metadata":{"id":"7fIumN3kOBR2","execution":{"iopub.status.busy":"2022-07-08T03:49:32.530347Z","iopub.execute_input":"2022-07-08T03:49:32.530715Z","iopub.status.idle":"2022-07-08T03:49:32.539035Z","shell.execute_reply.started":"2022-07-08T03:49:32.530684Z","shell.execute_reply":"2022-07-08T03:49:32.537998Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sequence_train_data,tokenizer = prepareSequences(cleaned_train_data)","metadata":{"id":"LvrOCuL2Oq-b","execution":{"iopub.status.busy":"2022-07-08T03:49:33.567676Z","iopub.execute_input":"2022-07-08T03:49:33.568033Z","iopub.status.idle":"2022-07-08T03:49:33.780848Z","shell.execute_reply.started":"2022-07-08T03:49:33.568004Z","shell.execute_reply":"2022-07-08T03:49:33.779823Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"after_padding_sequence = pad_sequences(sequence_train_data,maxlen=maxlen,padding='post',truncating='post')","metadata":{"id":"sXHEPdH2O3hn","execution":{"iopub.status.busy":"2022-07-08T03:49:48.458238Z","iopub.execute_input":"2022-07-08T03:49:48.458939Z","iopub.status.idle":"2022-07-08T03:49:48.497233Z","shell.execute_reply.started":"2022-07-08T03:49:48.458903Z","shell.execute_reply":"2022-07-08T03:49:48.496297Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"after_padding_sequence[0]","metadata":{"id":"YrETwAY3PfvM","outputId":"56a6ca25-9af5-42f6-d4e4-0b22f1889738","execution":{"iopub.status.busy":"2022-07-08T03:49:50.319121Z","iopub.execute_input":"2022-07-08T03:49:50.319869Z","iopub.status.idle":"2022-07-08T03:49:50.327693Z","shell.execute_reply.started":"2022-07-08T03:49:50.319828Z","shell.execute_reply":"2022-07-08T03:49:50.326437Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"num_words = len(tokenizer.word_index)+1\nnum_words","metadata":{"id":"26v7OfLDPktw","outputId":"31999ef9-a7fd-4519-f8c2-0142301245ef","execution":{"iopub.status.busy":"2022-07-08T03:49:51.109128Z","iopub.execute_input":"2022-07-08T03:49:51.109872Z","iopub.status.idle":"2022-07-08T03:49:51.117039Z","shell.execute_reply.started":"2022-07-08T03:49:51.109831Z","shell.execute_reply":"2022-07-08T03:49:51.115854Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\"\"\" Prepare embeding matrix using glove 200\"\"\"\n\nembeddings = {}\nfor  w in open(glove_file_path):\n  word  = w.split(\" \")[0]\n  emdb = w.split(\" \")[1:]\n  emdb = np.asarray(emdb,dtype='float32')\n  embeddings[word] = emdb\n\nembedding_matrx = np.zeros((num_words,embedding_size))\nfor word,i in tokenizer.word_index.items():\n  if i < num_words:\n    embdg_vector = embeddings.get(word)\n    if embdg_vector is not None:\n      embedding_matrx[i] = embdg_vector","metadata":{"id":"n8zy2QPTPnaG","execution":{"iopub.status.busy":"2022-07-08T03:49:51.95888Z","iopub.execute_input":"2022-07-08T03:49:51.959568Z","iopub.status.idle":"2022-07-08T03:50:16.951967Z","shell.execute_reply.started":"2022-07-08T03:49:51.959531Z","shell.execute_reply":"2022-07-08T03:50:16.950917Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y =  cleaned_train_data.target.values\ny = to_categorical(y,dtype='int32')","metadata":{"id":"RhVGa3ehQKL_","execution":{"iopub.status.busy":"2022-07-08T03:50:16.953868Z","iopub.execute_input":"2022-07-08T03:50:16.954262Z","iopub.status.idle":"2022-07-08T03:50:16.960175Z","shell.execute_reply.started":"2022-07-08T03:50:16.954208Z","shell.execute_reply":"2022-07-08T03:50:16.958977Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# X_train,X_test,y_train,y_test = train_test_split(after_padding_sequence,y,test_size=0.2,random_state=42)","metadata":{"id":"xeHMTmUsQaaz","execution":{"iopub.status.busy":"2022-07-07T18:49:16.068605Z","iopub.execute_input":"2022-07-07T18:49:16.069297Z","iopub.status.idle":"2022-07-07T18:49:16.074028Z","shell.execute_reply.started":"2022-07-07T18:49:16.069258Z","shell.execute_reply":"2022-07-07T18:49:16.072975Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# print(X_train.shape,y_train.shape)\n# print(X_test.shape,y_test.shape)\nprint(after_padding_sequence.shape)\nprint(y.shape)","metadata":{"id":"Xcbjg4_7Qcez","outputId":"30eba775-56ab-4420-9fe8-c356fe2cecce","execution":{"iopub.status.busy":"2022-07-08T03:50:59.947859Z","iopub.execute_input":"2022-07-08T03:50:59.948998Z","iopub.status.idle":"2022-07-08T03:50:59.954633Z","shell.execute_reply.started":"2022-07-08T03:50:59.948943Z","shell.execute_reply":"2022-07-08T03:50:59.953601Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# model building\ndef build_model():\n  model = Sequential()\n  model.add(Embedding(embedding_matrx.shape[0],embedding_size,input_length=maxlen,weights=[embedding_matrx]))\n  model.add(Bidirectional(LSTM(12,dropout=0.2,return_sequences=False)))\n  model.add(Flatten())\n  model.add(Dense(10,activation='relu'))\n  model.add(Dropout(0.5))\n  model.add(Dense(2,activation='softmax'))\n  return model","metadata":{"id":"iTNA9podQe_c","execution":{"iopub.status.busy":"2022-07-08T03:51:00.286841Z","iopub.execute_input":"2022-07-08T03:51:00.287833Z","iopub.status.idle":"2022-07-08T03:51:00.295107Z","shell.execute_reply.started":"2022-07-08T03:51:00.287777Z","shell.execute_reply":"2022-07-08T03:51:00.294012Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = build_model()\nmodel.summary()","metadata":{"id":"v9e_yIwrQqna","outputId":"17851aaf-78d5-42a3-a017-b02e924f8cb4","execution":{"iopub.status.busy":"2022-07-08T03:52:50.164024Z","iopub.execute_input":"2022-07-08T03:52:50.164413Z","iopub.status.idle":"2022-07-08T03:52:51.102578Z","shell.execute_reply.started":"2022-07-08T03:52:50.164381Z","shell.execute_reply":"2022-07-08T03:52:51.101519Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.compile(optimizer='adamax',loss=tensorflow.losses.categorical_crossentropy,metrics=['accuracy'])","metadata":{"id":"OSGxmNGkQthp","execution":{"iopub.status.busy":"2022-07-08T03:52:51.104518Z","iopub.execute_input":"2022-07-08T03:52:51.105451Z","iopub.status.idle":"2022-07-08T03:52:51.116885Z","shell.execute_reply.started":"2022-07-08T03:52:51.105412Z","shell.execute_reply":"2022-07-08T03:52:51.115945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"epochs = 50\nbatch_size = 32\nhistory = model.fit(x=after_padding_sequence,y=y,validation_split=0.2,epochs=epochs,batch_size=batch_size,verbose=1,callbacks=[EarlyStopping(monitor='val_loss', patience=3, min_delta=0.0001)])","metadata":{"id":"LEDHvJUTQ2LF","outputId":"e2c1fd0a-c8f5-440b-89d4-3493acba5bab","execution":{"iopub.status.busy":"2022-07-08T03:52:51.118574Z","iopub.execute_input":"2022-07-08T03:52:51.118925Z","iopub.status.idle":"2022-07-08T03:53:21.766425Z","shell.execute_reply.started":"2022-07-08T03:52:51.118892Z","shell.execute_reply":"2022-07-08T03:53:21.765266Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_seq = tokenizer.texts_to_sequences(cleaned_test_data['cleaned_tweets'])\npadded =  pad_sequences(test_seq,maxlen=maxlen,padding='post',truncating='post')\npred = model.predict(padded)","metadata":{"id":"jvjmOXvVQ_Qh","execution":{"iopub.status.busy":"2022-07-08T03:53:25.905287Z","iopub.execute_input":"2022-07-08T03:53:25.906369Z","iopub.status.idle":"2022-07-08T03:53:35.697731Z","shell.execute_reply.started":"2022-07-08T03:53:25.906319Z","shell.execute_reply":"2022-07-08T03:53:35.69669Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds = []\nfor p in pred:\n  preds.append(np.argmax(p))\n","metadata":{"id":"7gvuMJgOb2Bd","execution":{"iopub.status.busy":"2022-07-08T03:53:35.699794Z","iopub.execute_input":"2022-07-08T03:53:35.700103Z","iopub.status.idle":"2022-07-08T03:53:35.720714Z","shell.execute_reply.started":"2022-07-08T03:53:35.700078Z","shell.execute_reply":"2022-07-08T03:53:35.719739Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_csv = pd.DataFrame()\nsubmission_csv['id'] = cleaned_test_data['id']\nsubmission_csv['target'] = preds","metadata":{"id":"LNGvvmEVbnsv","execution":{"iopub.status.busy":"2022-07-08T03:53:39.097635Z","iopub.execute_input":"2022-07-08T03:53:39.098547Z","iopub.status.idle":"2022-07-08T03:53:39.110396Z","shell.execute_reply.started":"2022-07-08T03:53:39.098502Z","shell.execute_reply":"2022-07-08T03:53:39.109277Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_csv.to_csv(f'/kaggle/working/submission.csv',index=False)","metadata":{"id":"nIMqe1kTbzUD","execution":{"iopub.status.busy":"2022-07-08T04:33:17.307785Z","iopub.execute_input":"2022-07-08T04:33:17.308517Z","iopub.status.idle":"2022-07-08T04:33:17.321731Z","shell.execute_reply.started":"2022-07-08T04:33:17.308476Z","shell.execute_reply":"2022-07-08T04:33:17.320783Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_csv.head(25)","metadata":{"id":"AA8l7PNPcM76","outputId":"c37e8ceb-7a60-43ec-a337-34ab9696e47a","execution":{"iopub.status.busy":"2022-07-08T03:53:50.734773Z","iopub.execute_input":"2022-07-08T03:53:50.735126Z","iopub.status.idle":"2022-07-08T03:53:50.745617Z","shell.execute_reply.started":"2022-07-08T03:53:50.735095Z","shell.execute_reply":"2022-07-08T03:53:50.744627Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}