0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

kaggleでtitanic問題をやってみた

Posted at

はじめに

なにやらkaggleというデータ分析コンペが面白いらしいぞ?というミーハーな興味から出発し、とりあえずチュートリアルとして有名なtitanic問題を決定木で解いて提出してみた記録です。全く以って、玄人向けではありませんのでご容赦ください。

titanic問題?

kaggleというデータ分析コンペサイトに載っている問題は、いくつかのレベル分けがされているようで、そのなかのチュートリアルの1つにtitanic問題があるようです。(https://www.kaggle.com/c/titanic)
まずはここからtrain.csv,test.csvの2つのデータをDLします。
分析の流れとしては次のようなことをしていきます。

  • train.csv,test.csvのデータの中身を覗き、大体どういうデータなのか把握する
  • 欠損値、定性値があればそれを処理する
  • train.csvを使って決定木モデルを作成する
  • test.csvを使って評価
  • kaggleに提出し、スコアを確認する

データの中身を覗き、大体どういうデータなのか把握する

まずは必要なライブラリをインポートします

import numpy as np
import pandas as pd
import sklearn as sk
import matplotlib.pyplot as plt
import seaborn as sns

DLしたデータを格納します

train=pd.read_csv("~~~/train.csv")
test=pd.read_csv("~~~/test.csv")

どんな感じのデータかというと、、、

train.head()

スクリーンショット 2019-02-23 18.09.17.png

欠損値があるかどうか

train.isnull().sum()

スクリーンショット 2019-02-23 18.11.57.png

"Age"の欠損値はとりあえず除き、"Embarked"の欠損はSで埋める方向でやってみる

train["Age"]=train["Age"].dropna
train["Embarked"]=train["Embarked"].fillna("S")

次は決定木モデルの作成をします。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?