File tree Expand file tree Collapse file tree 6 files changed +6656
-19
lines changed Expand file tree Collapse file tree 6 files changed +6656
-19
lines changed Original file line number Diff line number Diff line change 47
47
plt .show ()
48
48
#先檢視各艙位存活人數,此時可以使用groupby函數進行分類,
49
49
#其中 survived=1表示存活,survived=0表示死亡,將survived加總即為各艙等生存人數。
50
-
51
50
df .groupby ('pclass' ).survived .sum ()
52
-
53
51
#加上性別
54
52
survived = df .groupby (['pclass' ,'sex' ]).survived .sum ()
55
53
survived .plot (kind = 'bar' )
69
67
g .map (plt .hist ,"pclass" )
70
68
plt .show ()
71
69
72
- h = sns .FacetGrid (df , col = "survived" )
73
- h .map (plt .hist ,"sex" )
74
- plt .show ()
70
+ # 可以嘗試其他的參數對照組合
71
+
72
+ # 0 survived
73
+ # 1 pclass
74
+ # 2 sex
75
+ # 3 age
76
+ # 5 parch
77
+ # 6 fare
78
+ # 7 embarked
79
+ # 8 class
80
+ # 9 who
81
+ # 10 adult_male
82
+ # 11 deck
83
+ # 12 embark_town
84
+ # 13 alive
85
+ # 14 alone
Original file line number Diff line number Diff line change
1
+ import pandas as pd
2
+ import numpy as np
3
+ import seaborn as sns
4
+ import matplotlib as mpl
5
+ import matplotlib .pyplot as plt
6
+ from mpl_toolkits .mplot3d import Axes3D
7
+
8
+ # install tensorflow and keras
9
+ # https://medium.com/@virginiakm1988/%E5%9C%A8-anaconda-%E8%99%9B%E6%93%AC%E7%92%B0%E5%A2%83%E4%B8%8B%E5%AE%89%E8%A3%9D-tensorflow%E8%88%87-keras-c2c5aed98fef
10
+ # 需要使用 Colab 請注意一下
11
+ # 先行確認 Colab 上面的版本
12
+ import keras
13
+ print ("keras:" ,keras .__version__ )
14
+ import tensorflow as tf
15
+ print ("tf:" ,tf .__version__ )
16
+ # 需要使用 Colab 請注意一下
17
+ # Training code
18
+ # 新增網路硬碟
19
+ from google .colab import drive
20
+ drive .mount ("/gdrive" , force_remount = True )
21
+ #drive.mount('/gdrive')
22
+
23
+
24
+ # # 瞭解有關資料集屬性
25
+ # # 我們可以使用 info()或是 descript() 方法瞭解有關資料集屬性的更多資訊。特別是行和列的數量、列名稱、它們的數據類型和空值數。
26
+ # # 記錄數、平均值、標準差、最小值和最大值,我們使用 describe()
27
+ # df. describe()
28
+ # # 瞭解有關資料集屬性的更多資訊。特別是行和列的數量、列名稱、它們的數據類型和空值數。
29
+ # df.info()
30
+ # # 處理缺失值
31
+ # df = pd.get_dummies
32
+ # 資料集的處理
33
+ # 有時候無法從資料集明確的看出資料的屬性與因子的相互關係,要針對資料做處理
34
+
35
+ # https://kknews.cc/code/lnnxmr9.html
36
+
You can’t perform that action at this time.
0 commit comments