垃圾邮件分类器 - 基于机器学习的邮件分类系统
self.master = master self.master.title('垃圾邮件分类器') self.master.geometry('1000x700')
self.classifier = SpamClassifier()
self.load_frame = tk.Frame(self.master) self.load_frame.pack(padx=10, pady=10)
self.load_button = tk.Button(self.load_frame, text='导入数据集', command=self.load_dataset, width=15) self.load_button.pack(side='left')
self.show_data_button = tk.Button(self.load_frame, text='查看数据前十行', command=self.show_data, width=15) self.show_data_button.pack(side='left', padx=10, pady=10)
self.file_label = tk.Label(self.master, text='未选择文件') self.file_label.pack(padx=10)
self.test_size_label = tk.Label(self.master, text='测试集所占比例(0~1):') self.test_size_label.pack(padx=10, pady=10)
self.test_size_entry = tk.Entry(self.master, width=15) self.test_size_entry.pack(padx=10, pady=10)
self.train_test_split_button = tk.Button(self.master, text='划分训练集和测试集', command=self.split_data, width=15) self.train_test_split_button.pack(padx=10, pady=10)
self.menu_label = tk.Label(self.master, text='选择分类器:') self.menu_label.pack(anchor=tk.W, padx=5, pady=5)
self.options = ['朴素贝叶斯', '逻辑回归', '支持向量机', 'K近邻', '决策树', '随机森林', 'GDBT', '神经网络'] self.selected_option = tk.StringVar() self.selected_option.set(self.options[0]) self.dropdown_menu = tk.OptionMenu(self.master, self.selected_option, *self.options) self.dropdown_menu.pack(anchor=tk.W, padx=5, pady=5)
self.evaluate_label = tk.Label(self.master, text='模型评估:') self.evaluate_label.pack()
self.evaluate_options=['准确率', '精确率', '召回率', 'F1值'] self.evaluate_option= tk.StringVar() self.evaluate_option.set(self.evaluate_options[0]) self.evaluate_optionmenu = tk.OptionMenu(self.master, self.evaluate_option, *self.evaluate_options) self.evaluate_optionmenu.pack()
self.evaluate_button = tk.Button(self.master, text='评估模型', command=self.evaluate_model) self.evaluate_button.pack(padx=10, pady=10)
self.train_button = tk.Button(self.master, text='训练模型', command=self.train_classifier, width=15) self.train_button.pack(padx=10, pady=10)
self.text_entry = tk.Entry(self.master, width=50) self.text_entry.pack(padx=10, pady=10)
self.predict_button = tk.Button(self.master, text='预测', command=self.predict, width=15) self.predict_button.pack(padx=10, pady=10)
self.random_predict_button = tk.Button(self.master, text='随机预测', command=self.random_predict, width=15) self.random_predict_button.pack(padx=10, pady=10)
self.result_label = tk.Label(self.master, text='', width=30) self.result_label.pack(padx=10, pady=10)
self.chart_type = tk.StringVar(self.master) self.chart_type.set('选择图表类型') self.chart_menu = tk.OptionMenu(self.master, self.chart_type, '邮件分类饼图', '混淆矩阵','ROC曲线') self.chart_menu.pack(padx=10, pady=10)
self.generate_chart_button = tk.Button(self.master, text='生成图表', command=self.generate_chart, width=15) self.generate_chart_button.pack(padx=10, pady=10)
self.clear_canvas_button = tk.Button(self.master, text='清空画布', command=self.clear_canvas, width=15) self.clear_canvas_button.pack(padx=10, pady=10)
self.cm_text = tk.Text(self.master, width=70, height=20) self.cm_text.pack(padx=10, pady=10, side=tk.LEFT)
self.canvas = tk.Canvas(self.master, width=600, height=300) self.canvas.pack(padx=10, pady=10, side=tk.LEFT)
原文地址: https://www.cveoy.top/t/topic/oAT7 著作权归作者所有。请勿转载和采集!