kaggle忘備録

kaggle参加の忘備録です
初心者の方がどのコンペに参加しようかと迷っている際の参考になれば

NLP With Disaster Tweets Prediction - BERT

2020-10-10 13:59:02 | Real or Not? NLP with Disaster Tweets

今のところ一番gpuが高かったです

ファイルを読み込み欠損値を確認

まずツイートの分類を確認しています

そしてキーワードと投稿地について確認

不必要な列と判断。行列から削除しています

このあとはテキストの補正を行なっています。

ツイートのいくつかが繰り返し投稿されており誤分類されているため

文字列補正を行なっています

こうした繰り返し文字列の削除です

id text target
5641 8044 wowo--=== 12000 Nigerian refugees repatriated ... 0
5620 8018 wowo--=== 12000 Nigerian refugees repatriated ... 1
6091 8698 that horrible sinking feeling when you‰Ûªve be... 1
6123 8739 that horrible sinking feeling when you‰Ûªve be...

1

繰り返されるツイートについてフラグを立てることに

id text target target_new
5641 8044 wowo--=== 12000 Nigerian refugees repatriated ... 0 1
5620 8018 wowo--=== 12000 Nigerian refugees repatriated ... 1 1
6091 8698 that horrible sinking feeling when you‰Ûªve be... 1 0
6123 8739 that horrible sinking feeling when you‰Ûªve be... 1 0
6103 8714 that horrible sinking feeling when you‰Ûªve be... 0 0
6094 8702 that horrible sinking feeling when you‰Ûªve be... 0

0

解析前にツイートの前処理を行います

以下の項目は不要なので削除します

  1. URL
  2. HTML tags
  3. Emojis
  4. Special characters
  5. Non-ASCII characters
  6. Expand contractions
  7. Specific corrections
  8. Other context specific corrections
  9. Abbreviations

他にも略字、スペルミスも補正します

繰り返しツイートは一つに一を立て、残りにゼロを立てます

id text target target_new
4762 6775 World War II book LIGHTNING JOE An Autobiograp... 0 0
4770 6788 World War II book LIGHTNING JOE An Autobiograp... 1 0
248 353 World Annihilation vs Self Transformation Alie... 0 0
269 390 World Annihilation vs Self Transformation Alie... 1 0
2253 3227 Why are you deluged with low self - image ? Ta... 0 0
2250 3221 Why are you deluged with low self - image ? Ta... 1 0
5180 7392 Watch Sarah Palin OBLITERATE Planned Parenthoo... 0 0

ストップワードを削除します

  1. Remove unwanted words
  2. Remove punctuations
  3. Remove stopwords
  4. Stemming words

Tweetの文字数 単語数を比較します

ツイートの文字数 災害メールの方が長いことが分かります

意味のある単語の長さ

災害ツイートとそうでないツイートの差が見えてきます

よく出てくる単語について比較します

1単語での比較

非災害ツイートは like,get,new,u wouldなどが多く

災害ツイートは1fire news year californiaなどが多いです

2単語での比較

非災害ツイート

body bag

cros body 

youtube video

liked youtube

災害ツイート

malasia airline

flight 370 

airline fright

3単語で比較します

非災害ツイート

liked youtube video 

cross body bag

災害ツイート

malasia airline flight

airline flight 370

モデル化を行います

 

 


最新の画像もっと見る

コメントを投稿