# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + id="pBwbCGGYdQjL"
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from scipy
df = pd.read_csv("stroke.csv")

# + colab={"base_uri": "https://localhost:8080/"} id="Gozz2qMFf_UB" executionInfo={"status": "ok", "timestamp": 1621862425474, "user_tz": -180, "elapsed": 4, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="b0d86cda-1483-4908-e62b-11420508a44e"
df.info()

# + colab={"base_uri": "https://localhost:8080/", "height": 206} id="imreduJYhl5E" executionInfo={"status": "ok", "timestamp": 1621862780445, "user_tz": -180, "elapsed": 291, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="58e328fc-755b-470b-ae05-3e9efdc5d080"
df.head() # 5 perwych punktuw

# + id="Ehoh05fVjgny"
#pearsonr(df.age, df.avg_glucose_level) posmotert bystro korreliaciju mezdu czem to a czem to

# + colab={"base_uri": "https://localhost:8080/", "height": 81} id="kMicf-9KoPto" executionInfo={"status": "ok", "timestamp": 1621864126504, "user_tz": -180, "elapsed": 241, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="2e139207-f2ab-4967-d9ec-7ee51d0a1046"
png.corr(df.age, df.avg_glucose_level)

# + colab={"base_uri": "https://localhost:8080/"} id="5ZrPB6S2k9MD" executionInfo={"status": "ok", "timestamp": 1621863358587, "user_tz": -180, "elapsed": 6880, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="a6618dc7-f945-4de4-f8c5-ce6de973bd59"
# !pip install pingouin

# + id="ux2VIo8plsQ8"
import pingouin as png

# + colab={"base_uri": "https://localhost:8080/", "height": 459} id="XlwZepbDkKwj" executionInfo={"status": "ok", "timestamp": 1621869199219, "user_tz": -180, "elapsed": 1543, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="89b8d8ea-64a3-4c25-d4b0-1a027d086024"
sns.jointplot(x = "age", y = "avg_glucose_level",kind = "hex", data = df) 

# + colab={"base_uri": "https://localhost:8080/", "height": 401} id="BXB_f7WAmJQj" executionInfo={"status": "ok", "timestamp": 1621864092036, "user_tz": -180, "elapsed": 1766, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="b1af352e-2360-47ae-d76a-046a0b50da7b"
sns.relplot(x = "age", y = "avg_glucose_level", hue = "stroke",data = df,alpha = .5 ) # wyzow funkcji plo

# + id="jnFAjDBKkZA7"
# tak kak korelacja rabotat liniowo to korelacja ne wsegda mozet pokazywat nastojasciu korelacjiu

# + colab={"base_uri": "https://localhost:8080/", "height": 401} id="EpvVmb3VobMy" executionInfo={"status": "ok", "timestamp": 1621864169297, "user_tz": -180, "elapsed": 2904, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="99d1db6d-c997-4c6a-8d97-ac7d9116319c"
sns.relplot(x = "age", y = "avg_glucose_level", kind = "line",data = df)# wykres liniowy z przedzialem ufnosci

# + colab={"base_uri": "https://localhost:8080/", "height": 401} id="8poQVu2UokVr" executionInfo={"status": "ok", "timestamp": 1621864234585, "user_tz": -180, "elapsed": 4030, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="4a1a1fca-7029-4817-ea9f-ee3770718051"
sns.relplot(x = "age", y = "avg_glucose_level", kind = "line", hue = "stroke",data = df) # z podzialem dla ludzi ktore mieli udar a ktore nie

# + colab={"base_uri": "https://localhost:8080/", "height": 387} id="EOa4vBdSpC1R" executionInfo={"status": "ok", "timestamp": 1621864405874, "user_tz": -180, "elapsed": 572, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="bce95bc0-24b6-4bd4-add1-336d78539a6b"
sns.displot(data = df, x = "bmi") #dostajemy histogram

# + colab={"base_uri": "https://localhost:8080/", "height": 809} id="WTDgFHfpptf6" executionInfo={"status": "ok", "timestamp": 1621864800731, "user_tz": -180, "elapsed": 749, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="7553a4b7-a36c-4f25-a2bd-95a41108d852"
sns.displot(data = df, y = "bmi")
df[df.bmi>60]

# + colab={"base_uri": "https://localhost:8080/", "height": 424} id="csBxHU-3qLZR" executionInfo={"status": "ok", "timestamp": 1621864850650, "user_tz": -180, "elapsed": 262, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="93fee45e-660d-4d90-9684-815940ff4f6d"
udary = df[df.stroke == "yes"]
udary

# + colab={"base_uri": "https://localhost:8080/", "height": 387} id="xkE2ree3rX4o" executionInfo={"status": "ok", "timestamp": 1621864936910, "user_tz": -180, "elapsed": 705, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="81eaa144-7ae0-4ee3-843d-6541b1848ec9"
sns.displot(data = udary, x="bmi", binwidth = 2)

# + colab={"base_uri": "https://localhost:8080/", "height": 387} id="q47JvmiarfMP" executionInfo={"status": "ok", "timestamp": 1621865074598, "user_tz": -180, "elapsed": 765, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="ac38bd7f-2c7f-4c19-8706-ad53c0c7dfed"
sns.displot(data = df, x="bmi", kind = "kde")

# + colab={"base_uri": "https://localhost:8080/", "height": 387} id="pl2uiS_csC8Q" executionInfo={"status": "ok", "timestamp": 1621865180581, "user_tz": -180, "elapsed": 1032, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="99e7d063-dc83-4fa6-9ed5-f116b4876966"
sns.displot(data = df, x="age",hue = "stroke", kind = "kde")

# + colab={"base_uri": "https://localhost:8080/", "height": 297} id="By042md4sN3P" executionInfo={"status": "ok", "timestamp": 1621865331949, "user_tz": -180, "elapsed": 1505, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="3180ee46-d24f-4a64-b988-edf2b1a2e20d"
sns.scatterplot(x = "age", y = "avg_glucose_level", hue = "stroke", data = df) # gestosc na osi 
sns.rugplot(x = "age", y = "avg_glucose_level", data = df)

# + colab={"base_uri": "https://localhost:8080/", "height": 401} id="c94d0bDMtPTn" executionInfo={"status": "ok", "timestamp": 1621866270587, "user_tz": -180, "elapsed": 660, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="8527c1ec-a4f6-4675-9ba6-9e5fa341e7e6"
sns.catplot(x="stroke",y = "avg_glucose_level",kind = "bar", data =df)

# + colab={"base_uri": "https://localhost:8080/", "height": 401} id="jfJXeVVIwhiB" executionInfo={"status": "ok", "timestamp": 1621866238780, "user_tz": -180, "elapsed": 778, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="aedf0330-da22-48c3-9c41-17734e0107c7"
sns.catplot(x="stroke",y = "age", data =df)

# + colab={"base_uri": "https://localhost:8080/", "height": 401} id="56tODMlQws03" executionInfo={"status": "ok", "timestamp": 1621866459617, "user_tz": -180, "elapsed": 835, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="af22fee8-8504-4593-dc56-eda967d64c4e"
sns.catplot(x = "stroke", y = "age", kind= "point", data= df)

# + colab={"base_uri": "https://localhost:8080/", "height": 475} id="Yfx1_6-6xfyn" executionInfo={"status": "ok", "timestamp": 1621866525117, "user_tz": -180, "elapsed": 14761, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="cf666bd3-6763-4c54-dc04-22731341f3f3"
sns.catplot(x = "stroke", y = "age", kind= "swarm", data= df)

# + colab={"base_uri": "https://localhost:8080/", "height": 297} id="-ADzQDCPxoj-" executionInfo={"status": "ok", "timestamp": 1621866612971, "user_tz": -180, "elapsed": 264, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="0cc47980-443f-4663-f84a-306f6c281c8b"
sns.catplot(x = "stroke", y = "" data=df)

# + colab={"base_uri": "https://localhost:8080/", "height": 401} id="K7YqnASSx4To" executionInfo={"status": "ok", "timestamp": 1621866864322, "user_tz": -180, "elapsed": 776, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="deea3143-7aa3-4c6f-a028-99a86e7a5b01"
sns.catplot(x = "stroke", y = "avg_glucose_level", kind= "violin", data= df) # srawnenie gustosti danych w 2ch histogramach/rozklad danych

# + colab={"base_uri": "https://localhost:8080/", "height": 402} id="v3bEDGdgySZd" executionInfo={"status": "ok", "timestamp": 1621866962213, "user_tz": -180, "elapsed": 512, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="34d86f2b-a5f1-43f3-ad95-6f352b0f08be"
sns.catplot(y = "stroke", x = "avg_glucose_level", kind= "box", data= df)

# + colab={"base_uri": "https://localhost:8080/", "height": 401} id="WeLLgpIbzZ49" executionInfo={"status": "ok", "timestamp": 1621867204100, "user_tz": -180, "elapsed": 556, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="a0c84d39-3061-4288-83c6-a44182ccd5ef"
sns.catplot(x = 'gender', y = "avg_glucose_level", data= udary, kind = "swarm")

# + colab={"base_uri": "https://localhost:8080/", "height": 401} id="VIez6xQK0Mit" executionInfo={"status": "ok", "timestamp": 1621868966850, "user_tz": -180, "elapsed": 705, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="dee9e91b-8bc5-418a-bd68-07d7a0c35a00"
sns.set_palette("twilight")
sns.catplot(x = 'stroke', y = "bmi", hue= "hypertension", kind = "violin", data = df)

# + colab={"base_uri": "https://localhost:8080/", "height": 243} id="bofzxvUd0mum" executionInfo={"status": "ok", "timestamp": 1621867393036, "user_tz": -180, "elapsed": 880, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="c35f6a26-b261-405e-909c-421fb0716ef8"
g = sns.FacetGrid(df, col = "stroke")
g.map(sns.histplot, "bmi")

# + colab={"base_uri": "https://localhost:8080/", "height": 243} id="VyNWvfh51GtV" executionInfo={"status": "ok", "timestamp": 1621867502190, "user_tz": -180, "elapsed": 820, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="411f0f89-42be-456c-ba8a-feb3bba2d737"
g = sns.FacetGrid(df, col = "stroke")# beret kolunmu kak os i potom na osnowe toj osi delaet grafik zawisimosti ot drugich weleczin
g.map(sns.scatterplot, "bmi", "age")

# + colab={"base_uri": "https://localhost:8080/", "height": 459} id="1j4qMkUq1fcl" executionInfo={"status": "ok", "timestamp": 1621867735047, "user_tz": -180, "elapsed": 1840, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="1f464e89-50eb-4db9-8dab-c91cb4d18932"
g = sns.FacetGrid(df, col = "stroke", row="hypertension")# beret kolunmu kak os i potom na osnowe toj osi delaet grafik zawisimosti ot drugich weleczin
g.map(sns.scatterplot, "bmi", "avg_glucose_level", alpha= .5) #wielokrotne wykresy

# + colab={"base_uri": "https://localhost:8080/", "height": 441} id="6jsa6yUE13Zc" executionInfo={"status": "ok", "timestamp": 1621868757803, "user_tz": -180, "elapsed": 2801, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "01739312221940399891"}} outputId="ddf6e9b6-43b1-42d0-e61c-ead7002e1544"
g = sns.FacetGrid(df, col = "stroke", row="hypertension")# beret kolunmu kak os i potom na osnowe toj osi delaet grafik zawisimosti ot drugich weleczin
g.map(sns.scatterplot, "age", "avg_glucose_level", alpha= .3) #wielokrotne wykresy
# zapis grafika kak fail
plt.savefig("wykres2.png", dpi = 300)

# + id="6Hx2yUBU6j9A"


StarcoderdataJupyterScriptsDedupFiltered