Untuk tugas ini, Anda akan melihat data tahun 2017 tentang imunisasi dari CDC. File data Anda untuk penugasan ini ada di assets/NISPUF17. csv. Panduan pengguna data untuk ini, yang Anda perlukan untuk memetakan variabel dalam data ke pertanyaan yang diajukan, tersedia di aset/NIS-PUF17-DUG. pdf. Catatan. Anda mungkin harus pergi ke pohon Jupyter Anda [klik pada gambar Coursera] dan arahkan ke folder aset tugas 2 untuk melihat file PDF ini]
pertanyaan 1
Write a function called
12 which returns the proportion of children in the dataset who had a mother with the education levels equal to less than high school [12] and college degree.
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Fungsi ini harus mengembalikan kamus dalam bentuk [gunakan angka yang benar, jangan membulatkan angka]
1
2
3
4
{"less than high school":0.2,
"high school":0.4,
"more than high school but not college":0.2,
"college":0.2}
Kode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
def proportion_of_education[]:
# your code goes here
# YOUR CODE HERE
# raise NotImplementedError[]
import pandas as pd
import numpy as np
df = pd.read_csv["assests/NISPUF17.csv", index_col=0]
EDUS=df['EDUC1']
edus=np.sort[EDUS.values]
poe={"less than high school":0,
"high school":0,
"more than high school but not college":0,
"college":0}
n=len[edus]
poe["less than high school"]=np.sum[edus==1]/n
poe["high school"]=np.sum[edus==2]/n
poe["more than high school but not college"]=np.sum[edus==3]/n
poe["college"]=np.sum[edus==4]/n
return poe
1
2
3
4
5
6
assert type[proportion_of_education[]]==type[{}], "You must return a dictionary."
assert len[proportion_of_education[]] == 4, "You have not returned a dictionary with four items in it."
assert "less than high school" in proportion_of_education[].keys[], "You have not returned a dictionary with the correct keys."
assert "high school" in proportion_of_education[].keys[], "You have not returned a dictionary with the correct keys."
assert "more than high school but not college" in proportion_of_education[].keys[], "You have not returned a dictionary with the correct keys."
assert "college" in proportion_of_education[].keys[], "You have not returned a dictionary with the correct keys."
结果
Pertanyaan 2
Mari jelajahi hubungan antara diberi ASI saat masih kecil dan mendapatkan vaksin influenza musiman dari penyedia layanan kesehatan. Kembalikan sejumlah rata-rata jumlah vaksin influenza untuk anak-anak yang kami tahu menerima ASI saat masih kecil dan mereka yang tahu tidak
Fungsi ini harus mengembalikan tuple dalam bentuk [gunakan nomor yang benar
1_
[2.5, 0.1]
Kode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def average_influenza_doses[]:
# YOUR CODE HERE
# raise NotImplementedError[]
import pandas as pd
import numpy as np
df = pd.read_csv["assests/NISPUF17.csv", index_col=0]
cbf_flu=df.loc[:,['CBF_01','P_NUMFLU']]
cbf_flu1=cbf_flu[cbf_flu['CBF_01'] ==1].dropna[]
cbf_flu2=cbf_flu[cbf_flu['CBF_01'] ==2].dropna[]
flu1=cbf_flu1['P_NUMFLU'].values.copy[]
flu1[np.isnan[flu1]] = 0
f1=np.sum[flu1]/len[flu1]
flu2=cbf_flu2['P_NUMFLU'].values.copy[]
flu2[np.isnan[flu2]] = 0
f2=np.sum[flu2]/len[flu2]
aid =[f1,f2]
return aid
1
{"less than high school":0.2,1
"high school":0.4,
"more than high school but not college":0.2,
"college":0.2}
结果
## Pertanyaan 3 Akan menarik untuk melihat apakah ada bukti hubungan antara efektivitas vaksin dan jenis kelamin anak. Hitung rasio jumlah anak yang tertular cacar air tetapi divaksinasi [setidaknya satu dosis varicella] versus mereka yang divaksinasi tetapi tidak tertular cacar air. Kembalikan hasil berdasarkan jenis kelamin
Fungsi ini harus mengembalikan kamus dalam bentuk [gunakan angka yang benar]
{"less than high school":0.2,2
"high school":0.4,
"more than high school but not college":0.2,
"college":0.2}
{"less than high school":0.2,3
"high school":0.4,
"more than high school but not college":0.2,
"college":0.2}
Catatan. Untuk membantu verifikasi, nilai
1_3 yang dicari autograder dimulai dengan angka
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
14
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Kode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{"less than high school":0.2,5
"high school":0.4,
"more than high school but not college":0.2,
"college":0.2}
1
{"less than high school":0.2,7
"high school":0.4,
"more than high school but not college":0.2,
"college":0.2}
结果
Pertanyaan 4
Korelasi adalah hubungan statistik antara dua variabel. Jika kita ingin mengetahui apakah vaksin bekerja, kita dapat melihat korelasi antara penggunaan vaksin dan apakah itu menghasilkan pencegahan infeksi atau penyakit [1]. Dalam pertanyaan ini, Anda akan melihat apakah ada korelasi antara pernah terkena cacar air dan jumlah dosis vaksin cacar air yang diberikan [varicella]
Beberapa catatan tentang menafsirkan jawabannya.
15 adalah
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
16 [untuk ya] atau
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
17 [untuk tidak], dan
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
18 adalah jumlah dosis vaksin varicella yang telah diberikan kepada seorang anak. Korelasi positif [mis. g. ,
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
1_9] berarti bahwa peningkatan
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
15 [yang berarti lebih banyak tidak] juga akan meningkatkan nilai
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
18 [yang berarti lebih banyak dosis vaksin]. Jika ada korelasi negatif [mis. g. ,
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
def proportion_of_education[]:_2], menunjukkan bahwa pernah terkena cacar air berhubungan dengan peningkatan jumlah dosis vaksin
# your code goes here
# YOUR CODE HERE
# raise NotImplementedError[]
import pandas as pd
import numpy as np
df = pd.read_csv["assests/NISPUF17.csv", index_col=0]
EDUS=df['EDUC1']
edus=np.sort[EDUS.values]
poe={"less than high school":0,
"high school":0,
"more than high school but not college":0,
"college":0}
n=len[edus]
poe["less than high school"]=np.sum[edus==1]/n
poe["high school"]=np.sum[edus==2]/n
poe["more than high school but not college"]=np.sum[edus==3]/n
poe["college"]=np.sum[edus==4]/n
return poe
Juga,
def proportion_of_education[]:_3 adalah probabilitas bahwa kita mengamati korelasi antara
# your code goes here
# YOUR CODE HERE
# raise NotImplementedError[]
import pandas as pd
import numpy as np
df = pd.read_csv["assests/NISPUF17.csv", index_col=0]
EDUS=df['EDUC1']
edus=np.sort[EDUS.values]
poe={"less than high school":0,
"high school":0,
"more than high school but not college":0,
"college":0}
n=len[edus]
poe["less than high school"]=np.sum[edus==1]/n
poe["high school"]=np.sum[edus==2]/n
poe["more than high school but not college"]=np.sum[edus==3]/n
poe["college"]=np.sum[edus==4]/n
return poe
15 dan
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
18 yang lebih besar dari atau sama dengan nilai tertentu yang terjadi secara kebetulan.
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
def proportion_of_education[]:_3 kecil berarti bahwa korelasi yang diamati sangat tidak mungkin terjadi secara kebetulan. Dalam hal ini,
# your code goes here
# YOUR CODE HERE
# raise NotImplementedError[]
import pandas as pd
import numpy as np
df = pd.read_csv["assests/NISPUF17.csv", index_col=0]
EDUS=df['EDUC1']
edus=np.sort[EDUS.values]
poe={"less than high school":0,
"high school":0,
"more than high school but not college":0,
"college":0}
n=len[edus]
poe["less than high school"]=np.sum[edus==1]/n
poe["high school"]=np.sum[edus==2]/n
poe["more than high school but not college"]=np.sum[edus==3]/n
poe["college"]=np.sum[edus==4]/n
return poe
def proportion_of_education[]:3 harus sangat kecil [akan diakhiri dengan
# your code goes here
# YOUR CODE HERE
# raise NotImplementedError[]
import pandas as pd
import numpy as np
df = pd.read_csv["assests/NISPUF17.csv", index_col=0]
EDUS=df['EDUC1']
edus=np.sort[EDUS.values]
poe={"less than high school":0,
"high school":0,
"more than high school but not college":0,
"college":0}
n=len[edus]
poe["less than high school"]=np.sum[edus==1]/n
poe["high school"]=np.sum[edus==2]/n
poe["more than high school but not college"]=np.sum[edus==3]/n
poe["college"]=np.sum[edus==4]/n
return poe
def proportion_of_education[]:8 menunjukkan angka yang sangat kecil]
# your code goes here
# YOUR CODE HERE
# raise NotImplementedError[]
import pandas as pd
import numpy as np
df = pd.read_csv["assests/NISPUF17.csv", index_col=0]
EDUS=df['EDUC1']
edus=np.sort[EDUS.values]
poe={"less than high school":0,
"high school":0,
"more than high school but not college":0,
"college":0}
n=len[edus]
poe["less than high school"]=np.sum[edus==1]/n
poe["high school"]=np.sum[edus==2]/n
poe["more than high school but not college"]=np.sum[edus==3]/n
poe["college"]=np.sum[edus==4]/n
return poe
[1] Ini bukan gambaran lengkapnya, karena kita tidak melihat kapan dosis diberikan. Ada kemungkinan anak-anak menderita cacar air dan kemudian orang tua mereka pergi untuk mendapatkan vaksin. Apakah kumpulan data ini memiliki data yang kami perlukan untuk menyelidiki waktu pemberian dosis?