Skip to content

Commit

Permalink
노트북 번역
Browse files Browse the repository at this point in the history
  • Loading branch information
rickiepark committed Jul 17, 2021
1 parent 302c78b commit 27d6a2d
Showing 1 changed file with 36 additions and 37 deletions.
73 changes: 36 additions & 37 deletions notebooks/exploring_data_to_generate_features.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Using vectorization to generate features"
"# 벡터화로 특성 생성하기"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To train a useful model, we first need to identify relevant features for it to use.\n",
"유용한 모델을 훈련하게 위해 먼저 모델이 사용할 관련성이 있는 특성을 찾아야 합니다.\n",
"\n",
"Let's explore the data and try to find patterns and features that could be useful. First, we'll embed our data so we can explore different areas of the vector space."
"데이터를 탐색하여 유용한 패턴과 특성을 찾아 보겠습니다. 먼저 데이터를 벡터 공간에 임베딩하겠습니다."
]
},
{
Expand Down Expand Up @@ -53,15 +53,15 @@
"raw_text = questions[\"body_text\"]\n",
"sent_labels = questions[\"AcceptedAnswerId\"].notna()\n",
"\n",
"# Load a large model, and disable pipeline unnecessary parts for our task\n",
"# This speeds up the vectorization process significantly\n",
"# See https://spacy.io/models/en#en_core_web_lg for details about the model\n",
"# 라지 모델을 로드하고 불필요한 기능을 비활성화 합니다.\n",
"# 이렇게 하면 벡터화 처리 속도를 크게 높입니다.\n",
"# 모델에 관한 자세한 정보는 https://spacy.io/models/en#en_core_web_lg 를 참고하세요.\n",
"nlp = spacy.load('en_core_web_lg', disable=[\"parser\", \"tagger\", \"ner\", \n",
" \"textcat\", \"lemmatizer\"])\n",
"\n",
"# Get the vector for each of our questions\n",
"# By default, the vector returned is the average of all vectors in the sentence\n",
"# See https://spacy.io/usage/vectors-similarity for more\n",
"# 각 질문에 대한 벡터를 만듭니다\n",
"# 기본적으로 반환된 벡터는 문장에 있는 모든 벡터의 평균입니다.\n",
"# 자세한 정보는 https://spacy.io/usage/vectors-similarity 를 참고하세요.\n",
"spacy_emb = train_author[train_author[\"is_question\"]][\"body_text\"].apply(lambda x: nlp(x).vector)\n",
"embeddings = np.vstack(spacy_emb)\n",
"\n",
Expand All @@ -73,11 +73,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Interactive plot\n",
"## 인터랙티브 플롯\n",
"\n",
"Next, we use [Bokeh](https://docs.bokeh.org/en/latest/index.html) to explore embeddings interactively.\n",
"[보케(Bokeh)](https://docs.bokeh.org/en/latest/index.html)를 사용해 임베딩을 인터랙티브하게 살펴 보겠습니다.\n",
"\n",
"You can pan left and right, and zoom in to any particular zone of interest. Hover over a question to see its associated text and label."
"왼쪽과 오른쪽으로 회전하고 관심 영역을 줌인 할 수 있습니다. 질문 위에 마우스를 올리면 연결된 텍스트와 레이블이 나타납니다."
]
},
{
Expand Down Expand Up @@ -531,7 +531,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"As you look through the data, it can be useful to build helper functions to allow you to locate specific examples that you've hovered over. Below, I write a quick function to find examples containing a given string and display relevant fields."
"데이터를 살펴 볼 때 마우스로 가리킨 특정 샘플 위치를 알 수 있도록 헬퍼 함수를 만들겠습니다. 아래 함수는 주어진 문자열을 담고 있는 샘플을 찾고 관련 특성을 출력합니다."
]
},
{
Expand Down Expand Up @@ -707,38 +707,38 @@
}
],
"source": [
"# Fill empty rows to allow search to still perform\n",
"# 검색을 위해서 빈 문자열로 만듭니다.\n",
"df[\"body_text_question\"].fillna(\"\", inplace=True)\n",
"\n",
"def show_question_features_containing(text):\n",
" return df[df[\"body_text_question\"].str.contains(text)][[\"body_text\", \"CommentCount\",\n",
" \"body_text_question\",\n",
" \"Score_question\", \"AcceptedAnswerId_question\"]]\n",
"\n",
"# Good example of two similar questions\n",
"# 비슷한 질문을 찾는 좋은 예\n",
"show_question_features_containing(\"I'm an amateur writer\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Potential features\n",
"## 가능성있는 특성\n",
"\n",
"Looking through the embeddings and associated rows of data above, it seemed like a few features were predictive of the target class of a question. The ones I idntified were:\n",
"임베딩과 관련된 데이터 행을 살펴 보니 질문의 타깃 클래스를 예측하는데 유용한 몇 개의 특성을 볼 수 있습니다. 그 중 몇 개는 다음과 같습니다:\n",
"\n",
"- question length: very short questions tended to not get answers\n",
"- presence of question mark: the absence of a question mark seemed to lower the chance of an answer\n",
"- vocabulary associated with a clear question (action verbs, etc...): unanswered questions seemed to be missing those\n",
"- 질문 길이: 매우 짧은 질문은 대답을 받지 못하는 것 같습니다.\n",
"- 물음표 여부: 물음표가 없으면 답변을 받을 가능성이 낮아 보입니다.\n",
"- 명확한 질문에 관련된 어휘(동작 동사 등...): 대답을 받지 못한 질문에 빠져 있는 것 같습니다.\n",
"\n",
"Did you identify any others? If so, feel free to add them as well."
"이외에 다른 것을 찾은 게 있나요? 그렇다면 마음껏 추가해도 좋습니다."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We start by creating a feature for the presence of question marks and action verbs"
"먼저 물음표와 동작 동사의 존재 여부를 특성으로 만들겠습니다."
]
},
{
Expand All @@ -756,7 +756,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's take a quick look at how often each feature is `True`."
"각 특성이 `True`인 개수를 확인해 보죠."
]
},
{
Expand Down Expand Up @@ -807,7 +807,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Since we already have a measure of text length, let's simply preprocess it by normalizing it. Because we added features to df itself and not the train split, we recreate a train split here."
"텍스트 길이는 이미 측정했기 때문에 이를 정규화하는 것으로 간단히 전처리하겠습니다. 훈련 세트가 아니라 데이터프레임에 특성을 추가했기 때문에 훈련 세트를 다시 만듭니다."
]
},
{
Expand All @@ -832,7 +832,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now that we've added features to our model, we append the generated features to the existing vectors to create new embeddings, and visualize the embedding space again. Our hope is that as we add more features, the embeddings will be more separated."
"이제 특성을 추가했으므로 새로운 임베딩을 만들기 위해 기존 벡터에 생성된 특성을 추가하고 임베딩 공간에 다시 시각화합니다. 특성이 많이 추가될수록 임베딩이 잘 구분되어야 합니다."
]
},
{
Expand Down Expand Up @@ -862,7 +862,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Since the embeddings have changed, we calculate updated UMAP projections before plotting."
"임베딩이 바뀌었으므로 그래프를 그리기 전에 UMAP 투영을 다시 계산합니다."
]
},
{
Expand Down Expand Up @@ -901,10 +901,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We can see that the features seem to have contributed to shaping the landscape of our dataset. In particular, it seems like we've separated some clusters containing a majority of unanswered questions. This is encouraging, and a potential symptom of a feature being helpful. The only way to know for sure, however, is to use it in a model.\n",
"이 특성들이 데이터셋의 지형을 형성하는데 기여한 것으로 보입니다. 특히 대답을 받지 못한 질문의 대부분을 포함한 클러스터를 만든 것 같습니다. 이는 고무적이며 도움이 되는 특성이라는 신호입니다. 하지만 확신을 가지려면 모델에 사용해봐야 합니다.\n",
"\n",
"\n",
"Let's go through the dataset once more and see what other features we can come up with. To do so, please uncomment the cell below. It is left commented here simply to speed up the loading of the notebook. Feel free to use the show_question_features_containing function to help you validate hypotheses"
"데이터 세트를 다시 한 번 살펴보고 다른 특성을 도출할 수 있는지 살펴보겠습니다. 이렇게 하려면 아래 셀의 주석을 제거하세요. 노트북 로딩 속도를 높이기 위해 주석 처리한 상태로 둡니다. 자유롭게 `show_question_features_keeping` 함수를 사용해 가설을 검증해 보세요."
]
},
{
Expand All @@ -921,7 +920,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"One quick additional feature that seemed predictive in my exploration was whether a question was about the english language. Below is a feature that attempts to capture just that"
"이번 탐색에서 찾은 예측 성능을 가진 다른 특성은 질문이 영어에 관한 것인지 여부였습니다. 아래는 바로 캡처를 시도하는 기능입니다. 다음은 이런 질문을 잡아내는 특성입니다."
]
},
{
Expand All @@ -937,7 +936,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"When looking through the data again, I also discovered that a lot of the relevant information was contained in the title of the question, which we have been ignoring so far. Below is an example of a title describing most of the information "
"데이터를 다시 살펴 볼 때 질문의 제목에 관련성 있는 정보가 많다는 것을 알았습니다. 지금까지는 이를 무시했습니다. 다음은 많은 정보를 드러내는 제목을 가진 샘플입니다."
]
},
{
Expand Down Expand Up @@ -1008,7 +1007,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's incorporate the title by concatenating it with the body and then embedding the concatenated version."
"제목과 본문을 연결한 다음 이를 다시 임베딩하겠습니다."
]
},
{
Expand All @@ -1024,7 +1023,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We recompute the features described above in the same manner, but using the full text this time. Feel free to see the ml_editor source to see details."
"동일한 방식으로 전체 텍스트를 사용해 특성을 다시 만듭니다. 자세한 내용은 `ml_editor` 폴더를 참고하세요."
]
},
{
Expand Down Expand Up @@ -1072,7 +1071,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's visualize the embeddings once more"
"임베딩을 다시 시각화해 보겠습니다."
]
},
{
Expand Down Expand Up @@ -1111,9 +1110,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Above, you can see that we've isolated a few clusters at the top which seem to contain mostly unanswered questions. The features we've added are helping to separate classes, and thus should make the task easier for our model.\n",
"위 그림에서 대부분 대답을 얻지 못한 질문을 담고 있는 몇 개의 클러스터가 상단에 고립되어 있는 것을 볼 수 있습니다. 추가된 특성이 클래스를 분할하는데 도움이 되기 때문에 모델의 작업을 쉽게 만들 것입니다.\n",
"\n",
"To explore the data more, feel free to uncomment the lines below."
"데이터를 더 탐색하고 싶다면 아래 코드의 주석을 제거하고 실행하세요."
]
},
{
Expand Down Expand Up @@ -1206,7 +1205,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We have created an initial set of candidate features that we hope to be predictive. Now, we can train a model on them, and examine its performance to iterate further!"
"예측 성능을 기대하는 후보 특성으로 초기 데이터셋을 만들었습니다. 이제 이 데이터셋에 모델을 훈련하고 성능을 조사하여 반복할 수 있습니다!"
]
}
],
Expand Down

0 comments on commit 27d6a2d

Please sign in to comment.