Cryptography

Bài tập về Dictory

Bài 1: Frequency - Thống kê tần suất

Input: nhập vào dãy số nguyên

Output: in ra tần suất xuất hiện các giá trị trong danh sách trên

Ví dụ
Input [3, 7, 3, 2, 2, 3, 4, 2, 3]
Output Giá trị 3724
Tần suất 4131

Bài 2: Label Encoder

2.1 Encode

Input: nhập vào dãy chuỗi

Output: in ra Label Encoder

Ví dụ
Input RedGreenRedGreenBlueRed
Output 010120

2.2 Decode

Input 010120
Output RedGreenRedGreenBlueRed

Bài 3: One Hot Encoder

3.1: Encode

Input: nhập vào dãy chuỗi

Output: in ra One Hot Encoder

Ví dụ
Input:
RedGreenRedGreenBlueRed
Output:
RedGreenBlue
100
010
100
010
001
100

3.2: Decode

Input:
RedGreenBlue
100
010
100
010
001
100
Output:
RedGreenRedGreenBlueRed

Bài 4: Tạo biểu đồ nhánh lá

Input: nhập vào dãy số

Output: in ra biểu đồ nhánh lá

Ví dụ

Input

251312231225107100

Output

Steam Leaf
0 2, 5
1 3, 2, 2
2 3, 5
10 7, 0

Bài 5: CountVectorizer

Đầu vào là một tập (corpus) các văn bản

Input
string[] corpus = {
    "This I Can't is the first document.",
    "This document is the second document.",
    "And this is the third one.",
    "Is this the first document?" 
};
Output

Tạo ra ma trân thống kê tần suất như sau

thisIcan’tisthefirstdocumentsecondandthirdone
11111110000
10011021000
10011000111
10011110000

Bài 6: Confusion Matrix

Đầu và là 2 mảng chứa danh sách các chuỗi, in ra ma trận nhầm lẫn Confusion Matrix như sau:

Ví dụ
yTrue dogcatpandasdogdogcatpandascatdogpandas cat cat
yPred dogcatpandascatdogdogpandascatdogcat pandas pandas
Ouput
y Pred
dog cat pandas
y True dog 3 1 0
cat 1 2 2
pandas 0 1 2

Bài 7: Cây phân cấp

Input

Cho tập dữ liệu như sau

Id Name ParentId
1 Laptop
2 Mouse
3 Keyboard
4 DELL 1
5 ASUS 1
6 ACER 1
7 HP 1
8 DELL Vostro 4
10 DELL XPS 4
11 DELL Latitude 4
12 HP Pavilion 7
13 HP Omen 7
14 HP Victus 7
15 Chuột Logitech 2
16 Chuột CORSAIR 2
17 Chuột Genius 2
18 Bàn phím Genius 3
19 Bàn phím ASUS 3
20 Bàn phím MSI 3
  • Laptop
    • DELL
      • DELL Vostro
      • DELL XPS
      • DELL Latitude
    • ASUS
    • ACER
    • HP
      • HP Pavilion
      • HP Omen
      • HP Victus
  • Mouse
    • Chuột Logitech
    • Chuột CORSAIR
    • Chuột Genius
  • Keyboard
    • Bàn phím Genius
    • Bàn phím ASUS
    • Bàn phím MSI

Bài tập 2.10: Phân phối student

Viết chương trình nhập vào giá trị bậc tự do (df) và mức ý nghĩa (α) đễ tra bảng phân phối student

InputOutput
dfα$$t^{df}_{\alpha}$$
190.012.539
250.00253.078
Bảng tra phân phối Student
df | α0.250.20.150.10.050.0250.020.010.0050.00250.0010.0005
111.3761.9633.0786.31412.7115.8931.8263.66127.3318.3636.6
20.8161.0611.3861.8862.924.3034.8496.9659.92514.0922.3331.6
30.7650.9781.251.6382.3533.1823.4824.5415.8417.45310.2112.92
40.7410.9411.191.5332.1322.7762.9993.7474.6045.5987.1738.61
50.7270.921.1561.4762.0152.5712.7573.3654.0324.7735.8936.869
60.7180.9061.1341.441.9432.4472.6123.1433.7074.3175.2085.959
70.7110.8961.1191.4151.8952.3652.5172.9983.4994.0294.7855.408
80.7060.8891.1081.3971.862.3062.4492.8963.3553.8334.5015.041
90.7030.8831.11.3831.8332.2622.3982.8213.253.694.2974.781
100.70.8791.0931.3721.8122.2282.3592.7643.1693.5814.1444.587
110.6970.8761.0881.3631.7962.2012.3282.7183.1063.4974.0254.437
120.6950.8731.0831.3561.7822.1792.3032.6813.0553.4283.934.318
130.6940.871.0791.351.7712.162.2822.653.0123.3723.8524.221
140.6920.8681.0761.3451.7612.1452.2642.6242.9773.3263.7874.14
150.6910.8661.0741.3411.7532.1312.2492.6022.9473.2863.7334.073
160.690.8651.0711.3371.7462.122.2352.5832.9213.2523.6864.015
170.6890.8631.0691.3331.742.112.2242.5672.8983.2223.6463.965
180.6880.8621.0671.331.7342.1012.2142.5522.8783.1973.6113.922
190.6880.8611.0661.3281.7292.0932.2052.5392.8613.1743.5793.883
200.6870.861.0641.3251.7252.0862.1972.5282.8453.1533.5523.85
210.6860.8591.0631.3231.7212.082.1892.5182.8313.1353.5273.819
220.6860.8581.0611.3211.7172.0742.1832.5082.8193.1193.5053.792
230.6850.8581.061.3191.7142.0692.1772.52.8073.1043.4853.768
240.6850.8571.0591.3181.7112.0642.1722.4922.7973.0913.4673.745
250.6840.8561.0581.3161.7082.062.1672.4852.7873.0783.453.725
260.6840.8561.0581.3151.7062.0562.1622.4792.7793.0673.4353.707
270.6840.8551.0571.3141.7032.0522.1582.4732.7713.0573.4213.69
280.6830.8551.0561.3131.7012.0482.1542.4672.7633.0473.4083.674
290.6830.8541.0551.3111.6992.0452.152.4622.7563.0383.3963.659
300.6830.8541.0551.311.6972.0422.1472.4572.753.033.3853.646