From d3bce57a27c44561c1f82db8627b2ec2c38396fc Mon Sep 17 00:00:00 2001 From: cy <939601402@qq.com> Date: Tue, 15 Oct 2024 20:46:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20function.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- function.py | 84 ++++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/function.py b/function.py index c2f8278..e64cd0e 100644 --- a/function.py +++ b/function.py @@ -100,47 +100,47 @@ def load_dataset(directory): if __name__ == "__main__": - # # 以下代码可用于测试,可自行随意修改 - # train_data, train_labels = load_dataset("trainingDigits") + # 以下代码可用于测试,可自行随意修改 + train_data, train_labels = load_dataset("trainingDigits") - # test_data = ( - # "00000000000000110000000000000000" - # "00000000000011111000000000000000" - # "00000000000011111100000000000000" - # "00000000001111111110000000000000" - # "00000000001111111110000000000000" - # "00000000001111111100000000000000" - # "00000000011111111000000000000000" - # "00000000111111111000000000000000" - # "00000000111111110000000000000000" - # "00000000111111110000000000000000" - # "00000000111111110000000000000000" - # "00000000111111110000000000000000" - # "00000000111111100000000000000000" - # "00000001111111100000000000000000" - # "00000001111111100000000000000000" - # "00000001111111100000000000000000" - # "00000001111111111111000000000000" - # "00000001111111111111111000000000" - # "00000001111111111111111100000000" - # "00000011111111111111111110000000" - # "00000011111111111111111110000000" - # "00000001111111111111111110000000" - # "00000001111111111111111110000000" - # "00000000111111111100111111100000" - # "00000000111111111000111111100000" - # "00000000011111111001111111100000" - # "00000000011111111111111111000000" - # "00000000001111111111111111000000" - # "00000000000111111111111111000000" - # "00000000000011111111111100000000" - # "00000000000001111111110000000000" - # "00000000000000000111100000000000" - # ) - # predicted_label = classify( - # np.array([int(char) for char in test_data]).reshape(1, 1024), - # train_data, - # train_labels, - # ) + test_data = ( + "00000000000000110000000000000000" + "00000000000011111000000000000000" + "00000000000011111100000000000000" + "00000000001111111110000000000000" + "00000000001111111110000000000000" + "00000000001111111100000000000000" + "00000000011111111000000000000000" + "00000000111111111000000000000000" + "00000000111111110000000000000000" + "00000000111111110000000000000000" + "00000000111111110000000000000000" + "00000000111111110000000000000000" + "00000000111111100000000000000000" + "00000001111111100000000000000000" + "00000001111111100000000000000000" + "00000001111111100000000000000000" + "00000001111111111111000000000000" + "00000001111111111111111000000000" + "00000001111111111111111100000000" + "00000011111111111111111110000000" + "00000011111111111111111110000000" + "00000001111111111111111110000000" + "00000001111111111111111110000000" + "00000000111111111100111111100000" + "00000000111111111000111111100000" + "00000000011111111001111111100000" + "00000000011111111111111111000000" + "00000000001111111111111111000000" + "00000000000111111111111111000000" + "00000000000011111111111100000000" + "00000000000001111111110000000000" + "00000000000000000111100000000000" + ) + predicted_label = classify( + np.array([int(char) for char in test_data]).reshape(1, 1024), + train_data, + train_labels, + ) - # print(f"预测的标签: {predicted_label}") \ No newline at end of file + print(f"预测的标签: {predicted_label}") \ No newline at end of file