{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "5f4b2151-be17-c212-316d-89457e1ea5de"
      },
      "outputs": [],
      "source": [
        "# This Python 3 environment comes with many helpful analytics libraries installed\n",
        "# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n",
        "# For example, here's several helpful packages to load in \n",
        "\n",
        "import numpy as np # linear algebra\n",
        "import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n",
        "\n",
        "# Input data files are available in the \"../input/\" directory.\n",
        "# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n",
        "\n",
        "from subprocess import check_output\n",
        "print(check_output([\"ls\", \"../input\",\"-l\"]).decode(\"utf8\"))\n",
        "\n",
        "# Any results you write to the current directory are saved as output."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "7e64028d-1c2f-8159-ad93-19469cd504a5"
      },
      "outputs": [],
      "source": [
        "df_train=pd.read_csv('../input/train.csv')\n",
        "#df_train.head()\n",
        "#df_test=pd.read_csv('../input/test.csv')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "f0fffe89-edfa-0b77-39ef-d02bf5586ad6"
      },
      "outputs": [],
      "source": [
        "df_train = np.array(df_train)\n",
        "print(df_train[0])\n",
        "i=0\n",
        "for line in df_train:\n",
        "    #print(line)\n",
        "    if line[5]==1:\n",
        "        i+=1\n",
        "print(i/len(df_train))\n",
        "print(\"train length:\",len(df_train))\n",
        "allque_list=[]\n",
        "for line in df_train:\n",
        "    allque_list.append(line[3])\n",
        "    allque_list.append(line[4])\n",
        "print('que length:',len(allque_list))\n",
        "print(allque_list[0],allque_list[1])\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "04fcb34f-fa0c-fce9-b74a-df6f42dea4d7"
      },
      "outputs": [],
      "source": [
        "from sklearn.feature_extraction.text import TfidfVectorizer\n",
        "  \n",
        "tfidf_vectorizer = TfidfVectorizer(min_df = 2)\n",
        "tfidf_matrix = tfidf_vectorizer.fit_transform(np.array(allque_list,dtype='U'))\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "db7fb635-a40b-3b81-f6eb-45dfe655b0f2"
      },
      "outputs": [],
      "source": [
        "print(tfidf_matrix[1:2])"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "0ffa90d8-df26-e2e2-1ec3-a3ae1b042fb5"
      },
      "outputs": [],
      "source": [
        "from gensim.models import word2vec"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "49e2f80f-0874-2356-eb78-0c558b8f87ae"
      },
      "outputs": [],
      "source": [
        "model = word2vec.Word2Vec(tfidf_matrix,size=200)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "b2abd2fb-1761-2ab1-ffd5-089f15a67f4c"
      },
      "outputs": [],
      "source": ""
    }
  ],
  "metadata": {
    "_change_revision": 0,
    "_is_fork": false,
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.6.0"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}