{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"markdown","source":"After checking some bad cases, I have found some interesting questions about math LaTeX tag. I hope it can help to preprocess or apply some regulations."},{"metadata":{"trusted":true,"_uuid":"b84121c387ae0b9a9c4d7afedda2620795883e8a"},"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport operator \nimport re\nimport matplotlib.pyplot as plt\nimport seaborn as sns\ncolor = sns.color_palette()\n%matplotlib inline\n\nfrom sklearn.model_selection import train_test_split\n\nfrom keras import backend as K\nfrom keras.layers import *\nfrom keras import initializers, regularizers, constraints, optimizers, layers\nfrom keras.models import Model\nfrom keras.preprocessing import text, sequence\nfrom keras.preprocessing.text import Tokenizer\nfrom keras.preprocessing.sequence import pad_sequences\nfrom keras.callbacks import Callback, ReduceLROnPlateau, ModelCheckpoint, EarlyStopping\nfrom keras.initializers import glorot_normal,orthogonal\n\nimport gc\nimport warnings\nwarnings.filterwarnings('ignore')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d2059d60342954534cc2b4c1d3ad807e5bb9830d"},"cell_type":"code","source":"train = pd.read_csv(\"../input/train.csv\")\ntest = pd.read_csv(\"../input/test.csv\")","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"# preprocessing: https://www.kaggle.com/theoviel/improve-your-score-with-some-text-preprocessing\ncontraction_mapping = {\"ain't\": \"is not\", \"aren't\": \"are not\",\"can't\": \"cannot\", \"'cause\": \"because\", \"could've\": \"could have\", \"couldn't\": \"could not\", \"didn't\": \"did not\",  \"doesn't\": \"does not\", \"don't\": \"do not\", \"hadn't\": \"had not\", \"hasn't\": \"has not\", \"haven't\": \"have not\", \"he'd\": \"he would\",\"he'll\": \"he will\", \"he's\": \"he is\", \"how'd\": \"how did\", \"how'd'y\": \"how do you\", \"how'll\": \"how will\", \"how's\": \"how is\",  \"I'd\": \"I would\", \"I'd've\": \"I would have\", \"I'll\": \"I will\", \"I'll've\": \"I will have\",\"I'm\": \"I am\", \"I've\": \"I have\", \"i'd\": \"i would\", \"i'd've\": \"i would have\", \"i'll\": \"i will\",  \"i'll've\": \"i will have\",\"i'm\": \"i am\", \"i've\": \"i have\", \"isn't\": \"is not\", \"it'd\": \"it would\", \"it'd've\": \"it would have\", \"it'll\": \"it will\", \"it'll've\": \"it will have\",\"it's\": \"it is\", \"let's\": \"let us\", \"ma'am\": \"madam\", \"mayn't\": \"may not\", \"might've\": \"might have\",\"mightn't\": \"might not\",\"mightn't've\": \"might not have\", \"must've\": \"must have\", \"mustn't\": \"must not\", \"mustn't've\": \"must not have\", \"needn't\": \"need not\", \"needn't've\": \"need not have\",\"o'clock\": \"of the clock\", \"oughtn't\": \"ought not\", \"oughtn't've\": \"ought not have\", \"shan't\": \"shall not\", \"sha'n't\": \"shall not\", \"shan't've\": \"shall not have\", \"she'd\": \"she would\", \"she'd've\": \"she would have\", \"she'll\": \"she will\", \"she'll've\": \"she will have\", \"she's\": \"she is\", \"should've\": \"should have\", \"shouldn't\": \"should not\", \"shouldn't've\": \"should not have\", \"so've\": \"so have\",\"so's\": \"so as\", \"this's\": \"this is\",\"that'd\": \"that would\", \"that'd've\": \"that would have\", \"that's\": \"that is\", \"there'd\": \"there would\", \"there'd've\": \"there would have\", \"there's\": \"there is\", \"here's\": \"here is\",\"they'd\": \"they would\", \"they'd've\": \"they would have\", \"they'll\": \"they will\", \"they'll've\": \"they will have\", \"they're\": \"they are\", \"they've\": \"they have\", \"to've\": \"to have\", \"wasn't\": \"was not\", \"we'd\": \"we would\", \"we'd've\": \"we would have\", \"we'll\": \"we will\", \"we'll've\": \"we will have\", \"we're\": \"we are\", \"we've\": \"we have\", \"weren't\": \"were not\", \"what'll\": \"what will\", \"what'll've\": \"what will have\", \"what're\": \"what are\",  \"what's\": \"what is\", \"what've\": \"what have\", \"when's\": \"when is\", \"when've\": \"when have\", \"where'd\": \"where did\", \"where's\": \"where is\", \"where've\": \"where have\", \"who'll\": \"who will\", \"who'll've\": \"who will have\", \"who's\": \"who is\", \"who've\": \"who have\", \"why's\": \"why is\", \"why've\": \"why have\", \"will've\": \"will have\", \"won't\": \"will not\", \"won't've\": \"will not have\", \"would've\": \"would have\", \"wouldn't\": \"would not\", \"wouldn't've\": \"would not have\", \"y'all\": \"you all\", \"y'all'd\": \"you all would\",\"y'all'd've\": \"you all would have\",\"y'all're\": \"you all are\",\"y'all've\": \"you all have\",\"you'd\": \"you would\", \"you'd've\": \"you would have\", \"you'll\": \"you will\", \"you'll've\": \"you will have\", \"you're\": \"you are\", \"you've\": \"you have\" }\n\ndef clean_contractions(text, mapping):\n    specials = [\"’\", \"‘\", \"´\", \"`\"]\n    for s in specials:\n        text = text.replace(s, \"'\")\n    text = ' '.join([mapping[t] if t in mapping else t for t in text.split(\" \")])\n    return text\n\ntrain['question_text'] = train['question_text'].apply(lambda x: clean_contractions(x, contraction_mapping))\ntest['question_text'] = test['question_text'].apply(lambda x: clean_contractions(x, contraction_mapping))\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"35707ec772bf1b9727b94d206f06069b953f1ac7"},"cell_type":"code","source":"punct = \"/-'?!.,#$%\\'()*+-/:;<=>@[\\\\]^_`{|}~\" + '\"\"“”’' + '∞θ÷α•à−β∅³π‘₹´°£€\\×™√²—–&'\npunct_mapping = {\"‘\": \"'\", \"₹\": \"e\", \"´\": \"'\", \"°\": \"\", \"€\": \"e\", \"™\": \"tm\", \"√\": \" sqrt \", \"×\": \"x\", \"²\": \"2\", \"—\": \"-\", \"–\": \"-\", \"’\": \"'\", \"_\": \"-\", \"`\": \"'\", '“': '\"', '”': '\"', '“': '\"', \"£\": \"e\", '∞': 'infinity', 'θ': 'theta', '÷': '/', 'α': 'alpha', '•': '.', 'à': 'a', '−': '-', 'β': 'beta', '∅': '', '³': '3', 'π': 'pi', }\n\ndef clean_special_chars(text, punct, mapping):\n    for p in mapping:\n        text = text.replace(p, mapping[p])\n    \n    for p in punct:\n        text = text.replace(p, f' {p} ')\n    \n    specials = {'\\u200b': ' ', '…': ' ... ', '\\ufeff': '', 'करना': '', 'है': ''}  # Other special characters that I have to deal with in last\n    for s in specials:\n        text = text.replace(s, specials[s])\n    \n    return text\n\ntrain['question_text'] = train['question_text'].apply(lambda x: clean_special_chars(x, punct, punct_mapping))\ntest['question_text'] = test['question_text'].apply(lambda x: clean_special_chars(x, punct, punct_mapping))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c1eb559d10e395683cce82ba0adad48bd4351078"},"cell_type":"code","source":"mispell_dict = {'colour': 'color', 'centre': 'center', 'favourite': 'favorite', 'travelling': 'traveling', 'counselling': 'counseling', 'theatre': 'theater', 'cancelled': 'canceled', 'labour': 'labor', 'organisation': 'organization', 'wwii': 'world war 2', 'citicise': 'criticize', 'youtu ': 'youtube ', 'Qoura': 'Quora', 'sallary': 'salary', 'Whta': 'What', 'narcisist': 'narcissist', 'howdo': 'how do', 'whatare': 'what are', 'howcan': 'how can', 'howmuch': 'how much', 'howmany': 'how many', 'whydo': 'why do', 'doI': 'do I', 'theBest': 'the best', 'howdoes': 'how does', 'mastrubation': 'masturbation', 'mastrubate': 'masturbate', \"mastrubating\": 'masturbating', 'pennis': 'penis', 'Etherium': 'Ethereum', 'narcissit': 'narcissist', 'bigdata': 'big data', '2k17': '2017', '2k18': '2018', 'qouta': 'quota', 'exboyfriend': 'ex boyfriend', 'airhostess': 'air hostess', \"whst\": 'what', 'watsapp': 'whatsapp', 'demonitisation': 'demonetization', 'demonitization': 'demonetization', 'demonetisation': 'demonetization'}\n\ndef correct_spelling(x, dic):\n    for word in dic.keys():\n        x = x.replace(word, dic[word])\n    return x\n\ntrain['question_text'] = train['question_text'].apply(lambda x: correct_spelling(x, mispell_dict))\ntest['question_text'] = test['question_text'].apply(lambda x: correct_spelling(x, mispell_dict))\n","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"a630c1bc31c22dbf309ae3ccc21e2c0395819d1d"},"cell_type":"markdown","source":"# Check LaTeX tags"},{"metadata":{"trusted":true,"_uuid":"a55b47a2e24ddaed1e30d8da219c689728729ede"},"cell_type":"code","source":"def latex_tag_in_text(text):\n    x = text.lower()\n    return ' [ math ] ' in x\n    \ntrain['latex_tag_in_text'] = train['question_text'].apply(lambda x: latex_tag_in_text(x))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"565b7d7877f2f5d4f42cfe4b46777a7d4fe909b5","scrolled":true},"cell_type":"code","source":"train['latex_tag_in_text'].value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a6e46b0aecd207ff2fd7482e7d0200ea68eb2bdf"},"cell_type":"code","source":"train1 = train[train['target'] == 1]\ntrain0 = train[train['target'] == 0]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5bf353e30e32403245b791ae2f85bbd98d14a35c"},"cell_type":"code","source":"train1['latex_tag_in_text'].value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"scrolled":false,"_uuid":"cd8c7ac3e943c7bd550c5ed4f37813202ce530c5"},"cell_type":"code","source":"train0['latex_tag_in_text'].value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"scrolled":true,"_uuid":"11b8d9d01254d79b4d5303aa3c8cdb5c559b3ec7"},"cell_type":"code","source":"train1[train1['latex_tag_in_text']]['question_text'].values.tolist()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"1dc8a2b20c433d1b7e493bc3af6c68e85c4c003e"},"cell_type":"markdown","source":"As we can see here, some normal math questions are labeled as 1, very strange to me... for example:\n```\nWhat is  [ math ]   \\\\  mathbb Z  [ x ]    /    \\\\  left   \\\\  langle 3   \\\\  right   \\\\  rangle [   /  math ]  ?\n\nWhat is the answer to  [ math ] 5   \\\\  underset {   \\\\  otimes }  {   \\\\  overset {   \\\\  oslash }  {   \\\\  otimes }  }  6  [   /  math ]  ? \n```\nAnd the most interesting finding is list below, maybe this tell us some info:\n```\n'Why cannot [ math ] \\\\ LaTeX [ / math ] be used in a Quora question ?'\n```\n\n"},{"metadata":{"trusted":true,"_uuid":"ca7c5a6f4260191b0b677361d6e9d1317d0c3c15"},"cell_type":"code","source":"train_ques_lens = train['question_text'].map(lambda x: len(x.split(' ')))\ntest_ques_lens = test['question_text'].map(lambda x: len(x.split(' ')))\nprint('Train text max len:', train_ques_lens.max())\nprint('Test text max len:', test_ques_lens.max())\nplt.figure(figsize=(10, 4))\nsns.kdeplot(train_ques_lens)\nsns.kdeplot(test_ques_lens)\nplt.legend(('train', 'test'))\nplt.show()\ndel train_ques_lens; del test_ques_lens\ngc.collect()\npass","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"ebd080d702c447ed9ecf1660346d49b841099c18"},"cell_type":"markdown","source":"# Simple math tag cleaning"},{"metadata":{"trusted":true,"_uuid":"3bc3b4403fb3e4bc0368735bec26b34ec4a5fdd0"},"cell_type":"code","source":"EMBED_SIZE = 300\nMAX_WORDS_LEN = 70\nMAX_VOCAB_FEATURES = 200000","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5dcb7cb32f3afdd0b5a0f1d887537f2bbc54da1b"},"cell_type":"code","source":"%%time\nprint('tokenize and padding')\nall_text = train['question_text'].values.tolist() + test['question_text'].values.tolist()\n\ntokenizer = Tokenizer(num_words=MAX_VOCAB_FEATURES, filters='')\ntokenizer.fit_on_texts(all_text)\n\n# tokenize\ntrain_X = tokenizer.texts_to_sequences(train['question_text'])\ntest_X = tokenizer.texts_to_sequences(test['question_text'])\n\n# Pad the sentences \ntrain_X = pad_sequences(train_X, maxlen=MAX_WORDS_LEN)\ntest_X = pad_sequences(test_X, maxlen=MAX_WORDS_LEN)\n\ntrain_y = train['target'].values\n\nword_index = tokenizer.word_index\nnb_words = min(MAX_VOCAB_FEATURES, len(word_index))\n\ndef load_glove():\n    print(\"Extracting Glove embedding\")\n    EMBEDDING_FILE = '../input/embeddings/glove.840B.300d/glove.840B.300d.txt'\n    emb_mean, emb_std = -0.005838499, 0.48782197\n\n    embedding_matrix = np.random.normal(emb_mean, emb_std, (nb_words, EMBED_SIZE))\n    with open(EMBEDDING_FILE, 'r', encoding=\"utf8\") as f:\n        for line in f:\n            word, vec = line.split(' ', 1)\n            if word not in word_index:\n                continue\n            i = word_index[word]\n\n            if i >= nb_words:\n                continue\n            embedding_vector = np.asarray(vec.split(' '), dtype='float32')[:300]\n            if len(embedding_vector) == 300:\n                embedding_matrix[i] = embedding_vector\n\n    print('Glove:', embedding_matrix.shape)\n    return embedding_matrix\n\nglove_embedding_matrix = load_glove()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"1aebd5ccd53bb05b86ca3c552cdadb9d491ab47e"},"cell_type":"code","source":"def f1(y_true, y_pred):\n    '''\n    metric from here \n    https://stackoverflow.com/questions/43547402/how-to-calculate-f1-macro-in-keras\n    '''\n    def recall(y_true, y_pred):\n        \"\"\"Recall metric.\n\n        Only computes a batch-wise average of recall.\n\n        Computes the recall, a metric for multi-label classification of\n        how many relevant items are selected.\n        \"\"\"\n        true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))\n        possible_positives = K.sum(K.round(K.clip(y_true, 0, 1)))\n        recall = true_positives / (possible_positives + K.epsilon())\n        return recall\n\n    def precision(y_true, y_pred):\n        \"\"\"Precision metric.\n\n        Only computes a batch-wise average of precision.\n\n        Computes the precision, a metric for multi-label classification of\n        how many selected items are relevant.\n        \"\"\"\n        true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))\n        predicted_positives = K.sum(K.round(K.clip(y_pred, 0, 1)))\n        precision = true_positives / (predicted_positives + K.epsilon())\n        return precision\n    \n    precision = precision(y_true, y_pred)\n    recall = recall(y_true, y_pred)\n    return 2*((precision*recall)/(precision+recall+K.epsilon()))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"1eaa62b2537b2467a4e1988b086e0cd4c67f19ef"},"cell_type":"code","source":"# https://www.kaggle.com/sudalairajkumar/a-look-at-different-embeddings/notebook\ndef simple_model(embedding_matrix):\n    inp = Input(shape=(MAX_WORDS_LEN,))\n    x = Embedding(nb_words, EMBED_SIZE, weights=[embedding_matrix], trainable=False)(inp)\n    x = Bidirectional(CuDNNGRU(64, return_sequences=True))(x)\n    x = GlobalMaxPool1D()(x)\n    x = Dense(16, activation=\"relu\")(x)\n    x = Dropout(0.1)(x)\n    x = Dense(1, activation=\"sigmoid\")(x)\n    model = Model(inputs=inp, outputs=x)\n    model.compile(loss='binary_crossentropy', optimizer='adam', metrics=[f1])\n    print(model.summary())\n    return model","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"864575c4b8977d08f7555809514f0743df684ebe"},"cell_type":"code","source":"X_train, X_valid, y_train, y_valid = train_test_split(train_X, train_y, test_size=0.1, random_state=2018)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"1a3dddbc7ce919de48ffe83d75909f9824e57cc6"},"cell_type":"code","source":"model = simple_model(glove_embedding_matrix)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"dbb21de5ee45389a3a406372ffce2eee95ba45fc"},"cell_type":"code","source":"model.fit(X_train, y_train, batch_size=512, epochs=2, validation_data=(X_valid, y_valid))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"97c9764c5415e63688d79167092b5c8a1bbd453a"},"cell_type":"markdown","source":"## simple cleaning the math tags"},{"metadata":{"trusted":true,"_uuid":"447599b781c91dcc42f4b611b049828896f0e054"},"cell_type":"code","source":"def clean_latex_tag(text):\n    corr_t = []\n    for t in text.split(\" \"):\n        t = t.strip()\n        if t != '':\n            corr_t.append(t)\n    text = ' '.join(corr_t)\n    \n    text = re.sub('(\\[ math \\]).+(\\[ / math \\])', 'mathematical formula', text)\n    return text","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a01a1dda38c691125f326a89d70efe9450154f4f"},"cell_type":"code","source":"train['question_text'] = train['question_text'].map(clean_latex_tag)\ntest['question_text'] = test['question_text'].map(clean_latex_tag)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"65788f6f5b57f4a4d572519cba184e41987c8968"},"cell_type":"code","source":"train_ques_lens = train['question_text'].map(lambda x: len(x.split(' ')))\ntest_ques_lens = test['question_text'].map(lambda x: len(x.split(' ')))\nprint('Train text max len:', train_ques_lens.max())\nprint('Test text max len:', test_ques_lens.max())\nplt.figure(figsize=(10, 4))\nsns.kdeplot(train_ques_lens)\nsns.kdeplot(test_ques_lens)\nplt.legend(('train', 'test'))\nplt.show()\ndel train_ques_lens; del test_ques_lens\ngc.collect()\npass","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4d69f7ae9826e748c2247aa878431f6fec6dcc5d"},"cell_type":"code","source":"def latex_tag_in_text(text):\n    x = text.lower()\n    return 'mathematical formula' in x\n    \ntrain['latex_tag_in_text'] = train['question_text'].apply(lambda x: latex_tag_in_text(x))\ntrain1 = train[train['target'] == 1]\ntrain0 = train[train['target'] == 0]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"00cf8b7f9896f231699c7068de5ec5956f82b883"},"cell_type":"code","source":"print(train1['latex_tag_in_text'].value_counts())\nprint(train0['latex_tag_in_text'].value_counts())","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c5c04ab5bdb9a04e96db4e66a88ced436f918b88"},"cell_type":"code","source":"train1[train1['latex_tag_in_text']]['question_text'].values.tolist()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"2adfa142d78112aa3f794605088c7fb2fd9573c6"},"cell_type":"markdown","source":"Seems more cleaning, right? Let's retrain the model."},{"metadata":{"trusted":true,"_uuid":"020b857162c19a733465d4b6fe0eec9f895c8c8d"},"cell_type":"code","source":"%%time\nprint('tokenize and padding')\nall_text = train['question_text'].values.tolist() + test['question_text'].values.tolist()\n\ntokenizer = Tokenizer(num_words=MAX_VOCAB_FEATURES, filters='')\ntokenizer.fit_on_texts(all_text)\n\n# tokenize\ntrain_X = tokenizer.texts_to_sequences(train['question_text'])\ntest_X = tokenizer.texts_to_sequences(test['question_text'])\n\n# Pad the sentences \ntrain_X = pad_sequences(train_X, maxlen=MAX_WORDS_LEN)\ntest_X = pad_sequences(test_X, maxlen=MAX_WORDS_LEN)\n\ntrain_y = train['target'].values\n\nword_index = tokenizer.word_index\nnb_words = min(MAX_VOCAB_FEATURES, len(word_index))\n\ndef load_glove():\n    print(\"Extracting Glove embedding\")\n    EMBEDDING_FILE = '../input/embeddings/glove.840B.300d/glove.840B.300d.txt'\n    emb_mean, emb_std = -0.005838499, 0.48782197\n\n    embedding_matrix = np.random.normal(emb_mean, emb_std, (nb_words, EMBED_SIZE))\n    with open(EMBEDDING_FILE, 'r', encoding=\"utf8\") as f:\n        for line in f:\n            word, vec = line.split(' ', 1)\n            if word not in word_index:\n                continue\n            i = word_index[word]\n\n            if i >= nb_words:\n                continue\n            embedding_vector = np.asarray(vec.split(' '), dtype='float32')[:300]\n            if len(embedding_vector) == 300:\n                embedding_matrix[i] = embedding_vector\n\n    print('Glove:', embedding_matrix.shape)\n    return embedding_matrix\n\nglove_embedding_matrix = load_glove()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"2427ec08702edf636690712a2b63da4ae75ea619"},"cell_type":"code","source":"X_train, X_valid, y_train, y_valid = train_test_split(train_X, train_y, test_size=0.1, random_state=2018)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"fa3138299470da809613248df6a09d5e1a5d91c0"},"cell_type":"code","source":"model = simple_model(glove_embedding_matrix)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d328bc4d6cc40de21c753cc5a72f6fb440e4c92a"},"cell_type":"code","source":"model.fit(X_train, y_train, batch_size=512, epochs=2, validation_data=(X_valid, y_valid))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"c0744b56c2b9beff2a099dc433757497e4ef110b"},"cell_type":"markdown","source":"With simple check, we can see that after cleaning math tag:\n- Valid logloss decrease from **0.0994** to **0.0992**, and f1_score increased from **0.6313** to **0.6641**. \n- The length distribution of question text becomes much more beautiful and reliable.\n\nWe need more check because the randomness. Hope this can help you! :)"},{"metadata":{"trusted":true,"_uuid":"9d226e457396f061c4ee73c42ec33691d2f022e8"},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}