{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# 04. 머신러닝 \n\n탐색적 데이터 분석 과정에서 데이터 시각화는 데이터의 특성을 드러내는 수단      \n**😎데이터 시각화를 통해 특성을 찾아보자!**\n","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np \nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\ntitanic = sns.load_dataset('titanic')\nprint(titanic.shape)\n\n#titanic = pd.read_csv(\"/kaggle/input/titanic/train.csv\")#############################\n#print(titanic.shape)\ntitanic.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:16.451084Z","iopub.execute_input":"2022-07-16T02:08:16.451581Z","iopub.status.idle":"2022-07-16T02:08:18.067547Z","shell.execute_reply.started":"2022-07-16T02:08:16.451482Z","shell.execute_reply":"2022-07-16T02:08:18.066266Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"titanic.describe()\n#info, describe 차이는?","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:18.069565Z","iopub.execute_input":"2022-07-16T02:08:18.070041Z","iopub.status.idle":"2022-07-16T02:08:18.107736Z","shell.execute_reply.started":"2022-07-16T02:08:18.070005Z","shell.execute_reply":"2022-07-16T02:08:18.106776Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data = titanic, x = 'age')#구간의 개수 auto(20개)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:18.109045Z","iopub.execute_input":"2022-07-16T02:08:18.109986Z","iopub.status.idle":"2022-07-16T02:08:18.394625Z","shell.execute_reply.started":"2022-07-16T02:08:18.109948Z","shell.execute_reply":"2022-07-16T02:08:18.393057Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data = titanic, x = 'age', bins =40)\n#여기서 bins는 구간의 개수","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:18.397439Z","iopub.execute_input":"2022-07-16T02:08:18.398564Z","iopub.status.idle":"2022-07-16T02:08:18.671362Z","shell.execute_reply.started":"2022-07-16T02:08:18.398522Z","shell.execute_reply":"2022-07-16T02:08:18.668736Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"## aa : 9명만 샘플링\naa = titanic.iloc[:9,:]\naa[aa.pclass==1].age.mean() # 42.333\naa[aa.pclass==3].age.mean() # 22.4\n\nsns.barplot(data = aa, x = 'class', y = 'age', ci=None) # ci=None 하면 신뢰구간 출력 안됨\nsns.barplot(data = aa, x = 'class', y = 'age', ci=90) # ci=None 하면 신뢰구간 출력 안됨\nsns.barplot(data = titanic, x = 'class', y = 'age',errwidth=10) # ci=None 하면 신뢰구간 출력 안됨\n\n#bootstrapping\n#https://elizavetalebedeva.com/bootstrapping-confidence-intervals-the-basics/ ","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:18.673277Z","iopub.execute_input":"2022-07-16T02:08:18.675022Z","iopub.status.idle":"2022-07-16T02:08:18.988057Z","shell.execute_reply.started":"2022-07-16T02:08:18.674967Z","shell.execute_reply":"2022-07-16T02:08:18.986739Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.barplot(data = titanic, x = 'class', y = 'age')\n#titanic\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:18.989705Z","iopub.execute_input":"2022-07-16T02:08:18.990433Z","iopub.status.idle":"2022-07-16T02:08:19.220613Z","shell.execute_reply.started":"2022-07-16T02:08:18.990386Z","shell.execute_reply":"2022-07-16T02:08:19.219704Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"titanic[titanic.age==0.42] #뭐지?","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:19.222103Z","iopub.execute_input":"2022-07-16T02:08:19.222863Z","iopub.status.idle":"2022-07-16T02:08:19.247058Z","shell.execute_reply.started":"2022-07-16T02:08:19.222817Z","shell.execute_reply":"2022-07-16T02:08:19.245363Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = titanic[titanic.age.notna()]\ndf[df.age%1!=0].shape#age가 왜 정수가 아닌지?","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:01:34.395346Z","iopub.execute_input":"2022-07-16T03:01:34.396621Z","iopub.status.idle":"2022-07-16T03:01:34.408934Z","shell.execute_reply.started":"2022-07-16T03:01:34.396572Z","shell.execute_reply":"2022-07-16T03:01:34.408030Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"titanic.age.max(), titanic.age.min()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:19.287421Z","iopub.execute_input":"2022-07-16T02:08:19.288125Z","iopub.status.idle":"2022-07-16T02:08:19.294819Z","shell.execute_reply.started":"2022-07-16T02:08:19.288092Z","shell.execute_reply":"2022-07-16T02:08:19.293735Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#추가 ### 히스토그램에서 계급의 개수가 아니라 계급의 크기를 고정하려면?\nsns.histplot(data = titanic, x = 'age', binwidth = 10, binrange = (0, 80))","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:19.299103Z","iopub.execute_input":"2022-07-16T02:08:19.299596Z","iopub.status.idle":"2022-07-16T02:08:19.472964Z","shell.execute_reply.started":"2022-07-16T02:08:19.299552Z","shell.execute_reply":"2022-07-16T02:08:19.470257Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data = titanic, x = 'age', hue = 'alive')\nplt.show()\nsns.histplot(data = titanic, x = 'age', hue = 'alive', binrange=[0,80])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:19.474319Z","iopub.execute_input":"2022-07-16T02:08:19.474938Z","iopub.status.idle":"2022-07-16T02:08:20.037602Z","shell.execute_reply.started":"2022-07-16T02:08:19.474883Z","shell.execute_reply":"2022-07-16T02:08:20.036087Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#누적으로 그리\nsns.histplot(data = titanic, x = 'age', hue = 'alive', multiple = 'stack', binrange = (0,80) )","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:20.039224Z","iopub.execute_input":"2022-07-16T02:08:20.039601Z","iopub.status.idle":"2022-07-16T02:08:20.359008Z","shell.execute_reply.started":"2022-07-16T02:08:20.039564Z","shell.execute_reply":"2022-07-16T02:08:20.357663Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data = titanic, x = \"age\", binrange = (0,80) )\nplt.show()\n# kdeplot(kernel density estimation), 커널 밀도 추정 함수 그래프, 히스토그램을 매끄럽게 연결(많이 쓰진 않음)\nsns.kdeplot(data = titanic, x = \"age\" )\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:20.360556Z","iopub.execute_input":"2022-07-16T02:08:20.360918Z","iopub.status.idle":"2022-07-16T02:08:20.801903Z","shell.execute_reply.started":"2022-07-16T02:08:20.360885Z","shell.execute_reply":"2022-07-16T02:08:20.800718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data = titanic, x = 'age', hue = 'alive', multiple = 'stack')\nplt.show()\nsns.kdeplot(data = titanic, x = 'age', hue = 'alive', multiple = 'stack')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:20.803273Z","iopub.execute_input":"2022-07-16T02:08:20.804244Z","iopub.status.idle":"2022-07-16T02:08:21.375580Z","shell.execute_reply.started":"2022-07-16T02:08:20.804207Z","shell.execute_reply":"2022-07-16T02:08:21.374379Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#displot, 분포도, 뒤에 kind = 'kde' 추가하면 kdeplot가능, 없으면 히스토그램\nsns.displot(data = titanic, x = \"age\", kind = 'kde')\nplt.show()\nsns.displot(data = titanic, x = \"age\", kde = True)\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:21.377270Z","iopub.execute_input":"2022-07-16T02:08:21.377624Z","iopub.status.idle":"2022-07-16T02:08:22.127289Z","shell.execute_reply.started":"2022-07-16T02:08:21.377592Z","shell.execute_reply":"2022-07-16T02:08:22.125745Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.kdeplot(data = titanic, x= \"age\")\nsns.rugplot(data = titanic, x= \"age\")\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:22.128523Z","iopub.execute_input":"2022-07-16T02:08:22.129316Z","iopub.status.idle":"2022-07-16T02:08:22.381135Z","shell.execute_reply.started":"2022-07-16T02:08:22.129274Z","shell.execute_reply":"2022-07-16T02:08:22.379731Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#rugplot이 뭔지 모르겠음.. 데이터 줄여서 확인해보기\ntitanic.shape # 891*12\ntitanic_s = titanic[:10] #10개 데이터만 살펴보기\nsns.countplot(data = titanic_s, x= \"age\")\nplt.show()\nsns.histplot(data = titanic_s, x= \"age\")\nplt.show()\nsns.kdeplot(data = titanic_s, x= \"age\")\nsns.rugplot(data = titanic_s, x= \"age\")\nplt.show()\ntitanic_s.age\n\n#countplot이 수치형 자료를 그냥 막대그래프로 나타내는데 비해 러그플럿은 히스토그램 상에서 그 정확한 위치를 보여주는데 의미가 있는 것 같음..","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:22.382638Z","iopub.execute_input":"2022-07-16T02:08:22.383088Z","iopub.status.idle":"2022-07-16T02:08:23.014404Z","shell.execute_reply.started":"2022-07-16T02:08:22.382996Z","shell.execute_reply":"2022-07-16T02:08:23.013129Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data = titanic_s, x= \"age\")\nplt.show()\nsns.rugplot(data = titanic_s, x= \"age\")#, expand_margins = 2)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:23.015825Z","iopub.execute_input":"2022-07-16T02:08:23.016167Z","iopub.status.idle":"2022-07-16T02:08:23.415878Z","shell.execute_reply.started":"2022-07-16T02:08:23.016136Z","shell.execute_reply":"2022-07-16T02:08:23.414683Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#barplot\nsns.barplot(x = 'class', y = 'fare', data = titanic, ci='sd')#class별 운임\nplt.show()\n#막대 높이는 평균 운임, 검은색 세로줄이 오차막대(신뢰구간)\n#등급이 높을수록 평균운임이 비싸고(당연), 신뢰구간이 넓어진다(?)\nfor i in range(3):\n    print(titanic[titanic['pclass']==i+1].fare.std())","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:23.417634Z","iopub.execute_input":"2022-07-16T02:08:23.418505Z","iopub.status.idle":"2022-07-16T02:08:23.605545Z","shell.execute_reply.started":"2022-07-16T02:08:23.418455Z","shell.execute_reply":"2022-07-16T02:08:23.604627Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data = titanic[titanic.pclass ==1], x = \"fare\")","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:23.606953Z","iopub.execute_input":"2022-07-16T02:08:23.607997Z","iopub.status.idle":"2022-07-16T02:08:23.855810Z","shell.execute_reply.started":"2022-07-16T02:08:23.607950Z","shell.execute_reply":"2022-07-16T02:08:23.854871Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"왜 신뢰구간이 등급이 높을수록 넓어지는거...","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize = (20, 4))\nsns.histplot(data = titanic,  x = \"fare\", hue = \"pclass\")\nplt.show()\n\nplt.figure(figsize = (20, 4))\nsns.kdeplot(data = titanic,  x = \"fare\", hue = \"pclass\")\nplt.show()\n\n#표준편차 영향\nfor i in range(1, 4):\n    print(\"등급 {}일 때 표준편차:{}\".format(i,round(titanic[titanic.pclass ==i].fare.std(), 2)))","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:23.856999Z","iopub.execute_input":"2022-07-16T02:08:23.857512Z","iopub.status.idle":"2022-07-16T02:08:25.083490Z","shell.execute_reply.started":"2022-07-16T02:08:23.857479Z","shell.execute_reply":"2022-07-16T02:08:25.082393Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#pointplot : 한 화면에 여러 그래프를 그릴 때 \nsns.pointplot(x = 'pclass', y = \"fare\", data = titanic)\nplt.show()\n\n#boxplot : five-number summary, 최솟값, q1, q2(median), q3, 최댓값\nsns.boxplot(x = 'pclass', y = 'age', data = titanic)\nplt.show() # 5요약수치 한번에 알고 싶을 때\n\n#violinplot : boxplot+kdeplot\nsns.violinplot(x = 'pclass', y = 'age', data = titanic)\nplt.show() # 분포 양상을 알고 싶을 떄","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:25.085196Z","iopub.execute_input":"2022-07-16T02:08:25.085642Z","iopub.status.idle":"2022-07-16T02:08:25.749644Z","shell.execute_reply.started":"2022-07-16T02:08:25.085608Z","shell.execute_reply":"2022-07-16T02:08:25.748647Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.boxplot(x = 'fare', data = titanic)\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:25.750783Z","iopub.execute_input":"2022-07-16T02:08:25.751428Z","iopub.status.idle":"2022-07-16T02:08:26.091268Z","shell.execute_reply.started":"2022-07-16T02:08:25.751387Z","shell.execute_reply":"2022-07-16T02:08:26.090071Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.violinplot(x = 'pclass', y = 'fare', data = titanic)\nplt.show() \n\nsns.violinplot(x = 'pclass', y = \"age\", hue = 'sex', data = titanic, split = True)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:26.092815Z","iopub.execute_input":"2022-07-16T02:08:26.093152Z","iopub.status.idle":"2022-07-16T02:08:26.570948Z","shell.execute_reply.started":"2022-07-16T02:08:26.093121Z","shell.execute_reply":"2022-07-16T02:08:26.569627Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#countplot : 범주형 데이터의 개수 확인\nsns.countplot(x=\"pclass\", data = titanic)\nplt.show()\n\nsns.countplot(y=\"pclass\", data = titanic)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:26.572578Z","iopub.execute_input":"2022-07-16T02:08:26.573089Z","iopub.status.idle":"2022-07-16T02:08:26.898340Z","shell.execute_reply.started":"2022-07-16T02:08:26.573041Z","shell.execute_reply":"2022-07-16T02:08:26.896991Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#pie graph, sns에서는 원그래프 지원하지 않음\nx = [10, 30, 60]\nlabels = ['A', 'B','C']\nplt.pie(x=x, labels = labels, autopct = '%.1f%%', )\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:26.900079Z","iopub.execute_input":"2022-07-16T02:08:26.901241Z","iopub.status.idle":"2022-07-16T02:08:27.000199Z","shell.execute_reply.started":"2022-07-16T02:08:26.901193Z","shell.execute_reply":"2022-07-16T02:08:26.998591Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#titanic 데이터 feature 별 비율 나타내기\nf = \"alive\"#feature 입력\n\nx = []\nlabels = titanic[f].unique()\nfor i in labels:\n    x.append(titanic[titanic[f]==i][f].count())\nplt.pie(x=x, labels = labels, autopct = '%.1f%%', )\nplt.show()\ntitanic\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:27.002150Z","iopub.execute_input":"2022-07-16T02:08:27.002816Z","iopub.status.idle":"2022-07-16T02:08:27.173470Z","shell.execute_reply.started":"2022-07-16T02:08:27.002761Z","shell.execute_reply":"2022-07-16T02:08:27.172041Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:27.183905Z","iopub.execute_input":"2022-07-16T02:08:27.185133Z","iopub.status.idle":"2022-07-16T02:08:27.191735Z","shell.execute_reply.started":"2022-07-16T02:08:27.185067Z","shell.execute_reply":"2022-07-16T02:08:27.189983Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for dirname, _, filenames in os.walk('/kaggle/input/air-passengers'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\nflights = pd.read_csv(\"//kaggle/input/air-passengers/AirPassengers.csv\")\n\nyear, month = [], []\nfor i in flights.Month:\n    year.append(i[:4])\n    month.append(i[-2:])\nflights['year'] = year\nflights['month'] = month\nflights = flights.drop('Month', axis=1)\nflights.columns = ['passengers', 'year', 'month']\nflights = flights[['year', 'month', 'passengers']]\nflights","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:27.194357Z","iopub.execute_input":"2022-07-16T02:08:27.195677Z","iopub.status.idle":"2022-07-16T02:08:27.236079Z","shell.execute_reply.started":"2022-07-16T02:08:27.195614Z","shell.execute_reply":"2022-07-16T02:08:27.235051Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"flights = sns.load_dataset('flights')","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:27.237563Z","iopub.execute_input":"2022-07-16T02:08:27.237919Z","iopub.status.idle":"2022-07-16T02:08:27.904217Z","shell.execute_reply.started":"2022-07-16T02:08:27.237889Z","shell.execute_reply":"2022-07-16T02:08:27.903158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"flights_pivot = flights.pivot(index = 'month', columns = 'year', values = 'passengers')\ndisplay(flights_pivot)\nsns.heatmap(data = flights_pivot, cmap= 'Reds')","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:27.907716Z","iopub.execute_input":"2022-07-16T02:08:27.908186Z","iopub.status.idle":"2022-07-16T02:08:28.261668Z","shell.execute_reply.started":"2022-07-16T02:08:27.908147Z","shell.execute_reply":"2022-07-16T02:08:28.260524Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"flights","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:28.263293Z","iopub.execute_input":"2022-07-16T02:08:28.264139Z","iopub.status.idle":"2022-07-16T02:08:28.279665Z","shell.execute_reply.started":"2022-07-16T02:08:28.264102Z","shell.execute_reply":"2022-07-16T02:08:28.278376Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#\nplt.scatter(flights.year, flights.passengers)\nplt.show()\n#jitter : 중첩된 점들을 흩뿌리기\nsns.scatterplot(data =flights, x=\"year\", y=\"passengers\")\nplt.show()\nsns.stripplot(data =flights, x=\"year\", y=\"passengers\", jitter=0.3, size=5)\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:28.280958Z","iopub.execute_input":"2022-07-16T02:08:28.281316Z","iopub.status.idle":"2022-07-16T02:08:28.913484Z","shell.execute_reply.started":"2022-07-16T02:08:28.281273Z","shell.execute_reply":"2022-07-16T02:08:28.912234Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"flights.pivot(columns = 'year', index = 'month').mean()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:28.914865Z","iopub.execute_input":"2022-07-16T02:08:28.915853Z","iopub.status.idle":"2022-07-16T02:08:28.931845Z","shell.execute_reply.started":"2022-07-16T02:08:28.915801Z","shell.execute_reply":"2022-07-16T02:08:28.929943Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.lineplot(x = 'year', y = 'passengers', data = flights, ci=99) #95%신뢰구간","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:28.933563Z","iopub.execute_input":"2022-07-16T02:08:28.934050Z","iopub.status.idle":"2022-07-16T02:08:29.489616Z","shell.execute_reply.started":"2022-07-16T02:08:28.934014Z","shell.execute_reply":"2022-07-16T02:08:29.488401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tips = pd.read_csv(\"//kaggle/input/tipping/tips.csv\")\ntips","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:29.490844Z","iopub.execute_input":"2022-07-16T02:08:29.491676Z","iopub.status.idle":"2022-07-16T02:08:29.520874Z","shell.execute_reply.started":"2022-07-16T02:08:29.491601Z","shell.execute_reply":"2022-07-16T02:08:29.519424Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.scatterplot(x = 'total_bill', y='tip', data = tips)\nplt.show()\n\nsns.scatterplot(x = 'total_bill', y='tip', hue = 'time',data = tips)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:29.522524Z","iopub.execute_input":"2022-07-16T02:08:29.522955Z","iopub.status.idle":"2022-07-16T02:08:29.960940Z","shell.execute_reply.started":"2022-07-16T02:08:29.522921Z","shell.execute_reply":"2022-07-16T02:08:29.959444Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#갑분 titanic\n#sns.scatterplot(x = 'age', y = 'fare', data = titanic, hue = 'class')\nplt.figure(figsize = (6, 10))\nsns.regplot(x = 'age', y = 'fare', data = titanic[titanic['class']==\"First\"])\n#sns.regplot(x = 'age', y = 'fare', data = titanic[titanic['class']==\"Second\"])\n#sns.regplot(x = 'age', y = 'fare', data = titanic[titanic['class']==\"Third\"])\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:29.962627Z","iopub.execute_input":"2022-07-16T02:08:29.963444Z","iopub.status.idle":"2022-07-16T02:08:30.293459Z","shell.execute_reply.started":"2022-07-16T02:08:29.963401Z","shell.execute_reply":"2022-07-16T02:08:30.292435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#갑분 titanic\nplt.figure(figsize = (6, 10))\nsns.regplot(x = 'age', y = 'fare', data = titanic[titanic['class']==\"Second\"])\n#sns.regplot(x = 'age', y = 'fare', data = titanic[titanic['class']==\"Third\"])\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:30.295062Z","iopub.execute_input":"2022-07-16T02:08:30.295383Z","iopub.status.idle":"2022-07-16T02:08:30.624040Z","shell.execute_reply.started":"2022-07-16T02:08:30.295354Z","shell.execute_reply":"2022-07-16T02:08:30.622739Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#갑분 titanic\nplt.figure(figsize = (6, 10))\nsns.regplot(x = 'age', y = 'fare', data = titanic[titanic['class']==\"Third\"])\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:30.626036Z","iopub.execute_input":"2022-07-16T02:08:30.626507Z","iopub.status.idle":"2022-07-16T02:08:30.918759Z","shell.execute_reply.started":"2022-07-16T02:08:30.626460Z","shell.execute_reply":"2022-07-16T02:08:30.917328Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.regplot(x = 'total_bill', y = 'tip', data = tips[tips.time==\"Dinner\"])\nsns.regplot(x = 'total_bill', y = 'tip', data = tips[tips.time==\"Lunch\"])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:08:30.920439Z","iopub.execute_input":"2022-07-16T02:08:30.921471Z","iopub.status.idle":"2022-07-16T02:08:31.284681Z","shell.execute_reply.started":"2022-07-16T02:08:30.921422Z","shell.execute_reply":"2022-07-16T02:08:31.283477Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 추가적으로","metadata":{}},{"cell_type":"code","source":"titanic #age, sex, alive\ntitanic_3 = titanic[['age','sex', 'alive']]#.replace(['male', 'female', 'no','yes'],[0, 1, 0, 1])\ntitanic_3 = titanic_3.dropna()\nsns.heatmap(data = titanic_3.pivot_table(index = 'sex', columns = 'alive', values = 'age', \n                                         aggfunc=[ np.mean]), cmap = \"Reds\", annot=True, )\nplt.show()\nsns.heatmap(data = titanic_3.pivot_table(index = 'sex', columns = 'alive', values = 'age',\n                                         aggfunc=[ np.std]), cmap = \"Reds\", annot=True, )\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:06:17.696485Z","iopub.execute_input":"2022-07-16T03:06:17.696909Z","iopub.status.idle":"2022-07-16T03:06:18.076829Z","shell.execute_reply.started":"2022-07-16T03:06:17.696874Z","shell.execute_reply":"2022-07-16T03:06:18.075463Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.kdeplot(data = titanic[titanic.sex=='male'], x = 'age', hue = 'alive', palette = 'Greens', legend=False)\nsns.kdeplot(data = titanic[titanic.sex=='female'], x = 'age', hue = 'alive', palette = 'Reds', legend=False)\nplt.show()\nsns.heatmap(data = titanic.pivot_table(index = 'sex', columns = 'alive', values = 'age', \n                                         aggfunc=[ np.mean]), cmap = \"Reds\", annot=True, )\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:23:33.893945Z","iopub.execute_input":"2022-07-16T03:23:33.894362Z","iopub.status.idle":"2022-07-16T03:23:34.731414Z","shell.execute_reply.started":"2022-07-16T03:23:33.894327Z","shell.execute_reply":"2022-07-16T03:23:34.730254Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.kdeplot(data = titanic_3[titanic.sex=='male'], x = 'age', hue = 'alive', palette = 'Greens', legend=False)\nsns.kdeplot(data = titanic_3[titanic.sex=='female'], x = 'age', hue = 'alive', palette = 'Reds', legend=False)\nplt.show()\nsns.heatmap(data = titanic_3.pivot_table(index = 'sex', columns = 'alive', values = 'age', \n                                         aggfunc=[ np.mean]), cmap = \"Reds\", annot=True, )\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:13:55.467534Z","iopub.execute_input":"2022-07-16T03:13:55.467990Z","iopub.status.idle":"2022-07-16T03:13:55.836837Z","shell.execute_reply.started":"2022-07-16T03:13:55.467952Z","shell.execute_reply":"2022-07-16T03:13:55.835737Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}