1
0

gui.py 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464
  1. import os
  2. import tkinter
  3. from tkinter.scrolledtext import ScrolledText
  4. import tkinter.messagebox
  5. from newtkinter import askopenfilename, asksaveasfilename, askdirectory
  6. import chardet
  7. import webbrowser
  8. from multiprocessing import Queue
  9. import machinelearning.controller
  10. import machinelearning.template
  11. from system import exception_catch, QueueController
  12. queue_controller = QueueController()
  13. input_queue: Queue
  14. output_queue: Queue
  15. calculation_list = []
  16. calculation_method = []
  17. PATH = os.getcwd()
  18. sheet_list = []
  19. merge_list = []
  20. learner_controller = machinelearning.controller.MachineLearner()
  21. SCREEN = tkinter.Tk()
  22. gui_width = 13 # 标准宽度
  23. gui_height = 2
  24. row = 0
  25. column = 0
  26. bg_color = "#FFFAFA" # 主颜色
  27. botton_color = "#FFFAFA" # 按钮颜色
  28. word_color = "#000000" # 文字颜色
  29. SCREEN["bg"] = bg_color
  30. FONT = ("黑体", 11) # 设置字体
  31. learn_dict = {}
  32. class UIAPI:
  33. @staticmethod
  34. @exception_catch()
  35. def add_learner_from_python_gui():
  36. file_dir = askopenfilename(title='python文件')
  37. file_name = os.path.split(file_dir)[-1]
  38. with open(file_dir, 'r') as f:
  39. code = f.read()
  40. return code, file_name
  41. @staticmethod
  42. @exception_catch()
  43. def get_split_shape_list_gui():
  44. try:
  45. split_shape_list = eval(f"[{shape.get()}]", {})[0]
  46. except IndexError:
  47. split_shape_list = 2
  48. return split_shape_list
  49. @staticmethod
  50. @exception_catch()
  51. def get_reval_type_gui():
  52. return processing_type.get()
  53. @staticmethod
  54. @exception_catch()
  55. def update_sheet_box_gui():
  56. global SCREEN, sheet_box, sheet_list
  57. sheet_list = list(learner_controller.get_form().keys())
  58. sheet_box.delete(0, tkinter.END)
  59. sheet_box.insert(tkinter.END, *sheet_list)
  60. @staticmethod
  61. @exception_catch()
  62. def creat_text_sheet_gui(data, name):
  63. global bg_color
  64. new_top = tkinter.Toplevel(bg=bg_color)
  65. new_top.title(name)
  66. new_top.geometry("+10+10") # 设置所在位置
  67. text = ScrolledText(new_top, font=("黑体", 13), height=50)
  68. text.pack(fill=tkinter.BOTH)
  69. text.insert("0.0", data)
  70. text.config(state=tkinter.DISABLED)
  71. new_top.resizable(width=False, height=False)
  72. @staticmethod
  73. @exception_catch()
  74. def add_python_gui():
  75. python_dir = askopenfilename(
  76. title="选择载入的py", filetypes=[("Python", ".py"), ("Txt", ".txt")]
  77. )
  78. name = sheet_name.get().replace(" ", "")
  79. if name == "":
  80. name = os.path.splitext(os.path.split(python_dir)[1])[0]
  81. with open(python_dir, "r") as f:
  82. code = f.read()
  83. return code, name
  84. @staticmethod
  85. @exception_catch()
  86. def get_data_name_gui(get_from_box=True, is_x_data=True): # 获得名字统一接口
  87. global sheet_list, sheet_box, x_data
  88. if get_from_box:
  89. try:
  90. return sheet_list[sheet_box.curselection()[0]]
  91. except IndexError:
  92. try:
  93. return sheet_list[0]
  94. except IndexError:
  95. return None
  96. else:
  97. if is_x_data:
  98. return x_data.get()
  99. else:
  100. return y_data.get()
  101. @staticmethod
  102. @exception_catch()
  103. def add_csv_gui():
  104. csv_dir = askopenfilename(title="选择载入的CSV", filetypes=[("CSV", ".csv")])
  105. the_sep = sep.get()
  106. the_encoding = encoding.get()
  107. must_str = bool(dtype_str.get())
  108. name = sheet_name.get().replace(" ", "")
  109. if name == "":
  110. name = os.path.splitext(os.path.split(csv_dir)[1])[0]
  111. if the_encoding == "":
  112. with open(csv_dir, "rb") as f:
  113. the_encoding = chardet.detect(f.read())["encoding"]
  114. if the_sep == "":
  115. the_sep = ","
  116. return csv_dir, name, the_encoding, must_str, the_sep
  117. @staticmethod
  118. @exception_catch()
  119. def to_csv_gui():
  120. save_dir = asksaveasfilename(title="选择保存的CSV", filetypes=[("CSV", ".csv")])
  121. csv_sep = sep.get()
  122. name = API.get_data_name_gui()
  123. return save_dir, name, csv_sep
  124. @staticmethod
  125. @exception_catch()
  126. def update_leaner_gui():
  127. global learn_dict, learner_box
  128. learn_dict = learner_controller.return_learner()
  129. learner_box.delete(0, tkinter.END)
  130. learner_box.insert(tkinter.END, *learn_dict.keys())
  131. @staticmethod
  132. @exception_catch()
  133. def set_x_data_gui():
  134. global x_data
  135. x_data.set(API.get_data_name_gui())
  136. @staticmethod
  137. @exception_catch()
  138. def set_y_data_gui():
  139. global y_data
  140. y_data.set(API.get_data_name_gui())
  141. @staticmethod
  142. @exception_catch()
  143. def set_learner_gui():
  144. global learner_output
  145. learner_output.set(API.get_learner_gui(True))
  146. @staticmethod
  147. @exception_catch()
  148. def get_learner_gui(return_box=False):
  149. global learn_dict, learner_box, learner_output
  150. if return_box:
  151. try:
  152. return list(learn_dict.keys())[learner_box.curselection()[0]]
  153. except IndexError:
  154. try:
  155. return list(learn_dict.keys)[0]
  156. except IndexError:
  157. return API.get_learner_gui(False)
  158. else:
  159. return learner_output.get()
  160. @staticmethod
  161. @exception_catch()
  162. def show_score_gui(message):
  163. tkinter.messagebox.showinfo("完成", message)
  164. @staticmethod
  165. @exception_catch()
  166. def get_learner_parameters_gui():
  167. global learner_parameters
  168. return learner_parameters.get("0.0", tkinter.END)
  169. @staticmethod
  170. @exception_catch()
  171. def get_merge_box_index_gui():
  172. return merge_box.curselection()[0]
  173. @staticmethod
  174. @exception_catch()
  175. def update_merge_box_gui():
  176. global merge_list, merge_box
  177. merge_box.delete(0, tkinter.END)
  178. merge_box.insert(tkinter.END, *merge_list)
  179. @staticmethod
  180. @exception_catch()
  181. def get_merge_split_type_gui():
  182. return processing_type.get()
  183. @staticmethod
  184. @exception_catch()
  185. def get_shape_gui():
  186. return eval(f"[{shape.get()}]")[0]
  187. @staticmethod
  188. @exception_catch()
  189. def global_settings_gui():
  190. return [bool(i.get()) for i in global_settings]
  191. @staticmethod
  192. @exception_catch()
  193. def get_calculation_num_gui():
  194. return eval(value.get(), {})
  195. @staticmethod
  196. @exception_catch()
  197. def update_calculation_box_gui():
  198. global calculation_list, calculation_method, calculation_box
  199. calculation_box.delete(0, tkinter.END)
  200. a = ["第一参数", "第二参数"]
  201. b = ["参数", "矩阵"]
  202. calculation_box.insert(
  203. tkinter.END,
  204. *[
  205. f"{a[i]} {calculation_list[i]} {b[calculation_method[i]]}"
  206. for i in range(len(calculation_list))
  207. ],
  208. )
  209. @staticmethod
  210. @exception_catch()
  211. def get_calculation_type_gui():
  212. return calculation_type.get()
  213. class API(UIAPI):
  214. @staticmethod
  215. @exception_catch()
  216. def add_learner_from_python(): # 添加Lenear的核心
  217. code_str, name = API.add_learner_from_python_gui()
  218. code_str = code_str.replace('base = None', '')
  219. code_str = code_str.replace('study_base = None', '')
  220. name_space = {'base': machinelearning.template.LearnBase,
  221. 'study_base': machinelearning.template.StudyMachinebase}
  222. exec(code_str, name_space)
  223. learner_controller.add_learner_from_python(name_space.get('learner'), name)
  224. API.update_leaner_gui()
  225. @staticmethod
  226. @exception_catch()
  227. def add_reverse_fast_fourier2(): # 添加Lenear的核心
  228. API.add_leaner("[2]Reverse_Fast_Fourier")
  229. @staticmethod
  230. @exception_catch()
  231. def add_reverse_fast_fourier(): # 添加Lenear的核心
  232. API.add_leaner("Reverse_Fast_Fourier")
  233. @staticmethod
  234. @exception_catch()
  235. def add_fast_fourier(): # 添加Lenear的核心
  236. API.add_leaner("Fast_Fourier")
  237. @staticmethod
  238. @exception_catch()
  239. def curve_fitting():
  240. file_dir = askopenfilename(title="导入参数")
  241. with open(file_dir, "r") as f:
  242. learner_controller.add_curve_fitting(f.read())
  243. API.update_leaner_gui()
  244. @staticmethod
  245. @exception_catch()
  246. def show_clustering_score():
  247. API.show_score(2)
  248. @staticmethod
  249. @exception_catch()
  250. def show_regression_score():
  251. API.show_score(1)
  252. @staticmethod
  253. @exception_catch()
  254. def show_class_score():
  255. API.show_score(0)
  256. @staticmethod
  257. @exception_catch()
  258. def show_score(func):
  259. learner = API.get_learner_gui(True)
  260. save_dir = askdirectory(title="选择保存位置")
  261. data = learner_controller.model_evaluation(
  262. learner,
  263. save_dir,
  264. API.get_data_name_gui(False, True),
  265. API.get_data_name_gui(False, False),
  266. func,
  267. )
  268. webbrowser.open(data[0])
  269. webbrowser.open(data[1]) # 还可以打开文件管理器
  270. API.update_sheet_box_gui()
  271. @staticmethod
  272. @exception_catch()
  273. def calculation():
  274. global calculation_list, calculation_method
  275. func = API.get_calculation_type_gui()
  276. if len(calculation_list) == 2 and 1 in calculation_method:
  277. learner_controller.calculation_matrix(
  278. calculation_list, calculation_method, func
  279. )
  280. API.update_sheet_box_gui()
  281. @staticmethod
  282. @exception_catch()
  283. def add_calculation_core(num, type_):
  284. if len(calculation_list) == 2:
  285. del calculation_list[0]
  286. del calculation_method[0]
  287. calculation_list.append(num)
  288. calculation_method.append(type_)
  289. @staticmethod
  290. @exception_catch()
  291. def add_calculation_number():
  292. API.add_calculation_core(API.get_calculation_num_gui(), 0)
  293. API.update_calculation_box_gui()
  294. @staticmethod
  295. @exception_catch()
  296. def add_calculation_object():
  297. name = API.get_data_name_gui()
  298. API.add_calculation_core(name, 1)
  299. API.update_calculation_box_gui()
  300. @staticmethod
  301. @exception_catch()
  302. def del_leaner():
  303. learn = API.get_learner_gui(True)
  304. set_learne = API.get_learner_gui(False) # 获取学习器Learner
  305. if set_learne != learn:
  306. learner_controller.del_leaner(learn)
  307. API.update_leaner_gui()
  308. @staticmethod
  309. @exception_catch()
  310. def global_seeting():
  311. args = API.global_settings_gui()
  312. machinelearning.template.set_global(*args)
  313. @staticmethod
  314. @exception_catch()
  315. def reshape():
  316. numpy_shape = API.get_shape_gui()
  317. learner_controller.reshape(API.get_data_name_gui(), numpy_shape)
  318. API.update_sheet_box_gui()
  319. @staticmethod
  320. @exception_catch()
  321. def transpose():
  322. try:
  323. func = API.get_shape_gui()
  324. except AssertionError:
  325. func = None
  326. learner_controller.transpose(API.get_data_name_gui(), func)
  327. API.update_sheet_box_gui()
  328. @staticmethod
  329. @exception_catch()
  330. def del_ndim():
  331. learner_controller.del_ndim(API.get_data_name_gui())
  332. API.update_sheet_box_gui()
  333. @staticmethod
  334. @exception_catch()
  335. def reval():
  336. global learner_controller
  337. reval_type = API.get_reval_type_gui()
  338. learner_controller.reval(API.get_data_name_gui(), reval_type)
  339. API.update_sheet_box_gui()
  340. @staticmethod
  341. @exception_catch()
  342. def two_split():
  343. split_type = API.get_merge_split_type_gui()
  344. learner_controller.two_split(API.get_data_name_gui(), shape.get(), split_type)
  345. API.update_sheet_box_gui()
  346. @staticmethod
  347. @exception_catch()
  348. def split():
  349. global learner_controller, shape
  350. split_type = API.get_merge_split_type_gui()
  351. split_shape_list = API.get_split_shape_list_gui()
  352. learner_controller.split(API.get_data_name_gui(), split_shape_list, split_type)
  353. API.update_sheet_box_gui()
  354. @staticmethod
  355. @exception_catch()
  356. def merge():
  357. if len(merge_list) < 1:
  358. return False
  359. merge_type = API.get_merge_split_type_gui()
  360. learner_controller.merge(merge_list, merge_type)
  361. API.update_sheet_box_gui()
  362. @staticmethod
  363. @exception_catch()
  364. def merge_del():
  365. del merge_list[API.get_merge_box_index_gui()]
  366. API.update_merge_box_gui()
  367. @staticmethod
  368. @exception_catch()
  369. def merge_add():
  370. merge_list.append(API.get_data_name_gui())
  371. API.update_merge_box_gui()
  372. @staticmethod
  373. @exception_catch()
  374. def visualization_results():
  375. learner = API.get_learner_gui(True)
  376. save_dir = askdirectory(title="选择保存位置")
  377. data = learner_controller.model_visualization(learner, save_dir)
  378. print('A')
  379. webbrowser.open(data[0])
  380. webbrowser.open(data[1]) # 还可以打开文件管理器
  381. API.update_sheet_box_gui()
  382. @staticmethod
  383. @exception_catch()
  384. def score_learner():
  385. learner = API.get_learner_gui()
  386. score = learner_controller.score(
  387. API.get_data_name_gui(False, True), API.get_data_name_gui(False, False), learner
  388. )
  389. API.show_score_gui(f"针对测试数据评分结果为:{score}")
  390. @staticmethod
  391. @exception_catch()
  392. def predict_learner():
  393. learner = API.get_learner_gui()
  394. data = learner_controller.predict(API.get_data_name_gui(False, True), learner)
  395. title = f"CoTan数据处理 学习器:{learner}"
  396. API.creat_text_sheet_gui(data, title)
  397. API.update_sheet_box_gui()
  398. @staticmethod
  399. @exception_catch()
  400. def fit_learner():
  401. learner = API.get_learner_gui()
  402. try:
  403. split = float(data_split.get())
  404. assert not split < 0 or 1 < split
  405. except (AssertionError, ValueError):
  406. split = 0.3
  407. socore = learner_controller.fit_model(
  408. API.get_data_name_gui(False, True),
  409. API.get_data_name_gui(False, False),
  410. learner,
  411. Text=API.get_learner_parameters_gui(),
  412. split=split,
  413. )
  414. API.show_score_gui(
  415. f"针对训练数据({(1 - split) * 100}%)评分结果为:{socore[0]}\n"
  416. f"针对测试数据评分({split * 100}%)结果为:{socore[1]}",
  417. )
  418. @staticmethod
  419. @exception_catch()
  420. def add_statistics(): # 添加Lenear的核心
  421. API.add_leaner("Statistics")
  422. @staticmethod
  423. @exception_catch()
  424. def add_correlation():
  425. API.add_leaner("Correlation")
  426. @staticmethod
  427. @exception_catch()
  428. def add_matrix_scatter():
  429. API.add_leaner("MatrixScatter")
  430. @staticmethod
  431. @exception_catch()
  432. def add_view_data():
  433. learner_controller.add_view_data(
  434. API.get_learner_gui(), parameters=API.get_learner_parameters_gui()
  435. )
  436. API.update_leaner_gui()
  437. @staticmethod
  438. @exception_catch()
  439. def add_cluster_tree():
  440. API.add_leaner("ClusterTree")
  441. @staticmethod
  442. @exception_catch()
  443. def add_feature_y_x():
  444. API.add_leaner("FeatureY-X")
  445. @staticmethod
  446. @exception_catch()
  447. def add_numpy_to_heatmap():
  448. API.add_leaner("HeatMap")
  449. @staticmethod
  450. @exception_catch()
  451. def add_predictive_heatmap_more(): # 添加Lenear的核心
  452. learner_controller.add_predictive_heat_map_more(
  453. API.get_learner_gui(), parameters=API.get_learner_parameters_gui()
  454. )
  455. API.update_leaner_gui()
  456. @staticmethod
  457. @exception_catch()
  458. def add_predictive_heatmap(): # 添加Lenear的核心
  459. learner_controller.add_predictive_heat_map(
  460. API.get_learner_gui(), parameters=API.get_learner_parameters_gui()
  461. )
  462. API.update_leaner_gui()
  463. @staticmethod
  464. @exception_catch()
  465. def add_feature_scatter_class_all():
  466. API.add_leaner("FeatureScatterClass_all")
  467. @staticmethod
  468. @exception_catch()
  469. def add_feature_scatter_all():
  470. API.add_leaner("FeatureScatter_all")
  471. @staticmethod
  472. @exception_catch()
  473. def add_feature_scatter_class():
  474. API.add_leaner("FeatureScatterClass")
  475. @staticmethod
  476. @exception_catch()
  477. def add_feature_scatter():
  478. API.add_leaner("FeatureScatter")
  479. @staticmethod
  480. @exception_catch()
  481. def add_class_bar():
  482. API.add_leaner("ClassBar")
  483. @staticmethod
  484. @exception_catch()
  485. def add_dbscan():
  486. API.add_leaner("DBSCAN")
  487. @staticmethod
  488. @exception_catch()
  489. def add_agglomerative():
  490. API.add_leaner("Agglomerative")
  491. @staticmethod
  492. @exception_catch()
  493. def add_k_means():
  494. API.add_leaner("k-means")
  495. @staticmethod
  496. @exception_catch()
  497. def add_mlp_class():
  498. API.add_leaner("MLP_class")
  499. @staticmethod
  500. @exception_catch()
  501. def add_mlp():
  502. API.add_leaner("MLP")
  503. @staticmethod
  504. @exception_catch()
  505. def add_svr():
  506. API.add_leaner("SVR")
  507. @staticmethod
  508. @exception_catch()
  509. def add_svc():
  510. API.add_leaner("SVC")
  511. @staticmethod
  512. @exception_catch()
  513. def add_gradient_tree():
  514. API.add_leaner("GradientTree")
  515. @staticmethod
  516. @exception_catch()
  517. def add_gradient_tree_class():
  518. API.add_leaner("GradientTree_class")
  519. @staticmethod
  520. @exception_catch()
  521. def add_tsne():
  522. API.add_leaner("t-SNE")
  523. @staticmethod
  524. @exception_catch()
  525. def add_nmf():
  526. API.add_leaner("NMF")
  527. @staticmethod
  528. @exception_catch()
  529. def add_lda():
  530. API.add_leaner("LDA")
  531. @staticmethod
  532. @exception_catch()
  533. def add_kpca():
  534. API.add_leaner("KPCA")
  535. @staticmethod
  536. @exception_catch()
  537. def add_rpca():
  538. API.add_leaner("RPCA")
  539. @staticmethod
  540. @exception_catch()
  541. def add_pca():
  542. API.add_leaner("PCA")
  543. @staticmethod
  544. @exception_catch()
  545. def add_missed():
  546. API.add_leaner("Missed")
  547. @staticmethod
  548. @exception_catch()
  549. def add_label():
  550. API.add_leaner("Label")
  551. @staticmethod
  552. @exception_catch()
  553. def add_one_hot_encoder():
  554. API.add_leaner("OneHotEncoder")
  555. @staticmethod
  556. @exception_catch()
  557. def add_discretization():
  558. API.add_leaner("Discretization")
  559. @staticmethod
  560. @exception_catch()
  561. def add_binarizer():
  562. API.add_leaner("Binarizer")
  563. @staticmethod
  564. @exception_catch()
  565. def add_regularization():
  566. API.add_leaner("Regularization")
  567. @staticmethod
  568. @exception_catch()
  569. def add_fuzzy_quantization():
  570. API.add_leaner("Fuzzy_quantization")
  571. @staticmethod
  572. @exception_catch()
  573. def add_mapzoom():
  574. API.add_leaner("Mapzoom")
  575. @staticmethod
  576. @exception_catch()
  577. def add_sigmod_scaler():
  578. API.add_leaner("sigmodScaler")
  579. @staticmethod
  580. @exception_catch()
  581. def add_decimal_scaler():
  582. API.add_leaner("decimalScaler")
  583. @staticmethod
  584. @exception_catch()
  585. def add_atan_scaler():
  586. API.add_leaner("atanScaler")
  587. @staticmethod
  588. @exception_catch()
  589. def add_log_scaler():
  590. API.add_leaner("LogScaler")
  591. @staticmethod
  592. @exception_catch()
  593. def add_min_max_scaler():
  594. API.add_leaner("MinMaxScaler")
  595. @staticmethod
  596. @exception_catch()
  597. def add_z_score():
  598. API.add_leaner("Z-Score")
  599. @staticmethod
  600. @exception_catch()
  601. def add_forest():
  602. API.add_leaner("Forest")
  603. @staticmethod
  604. @exception_catch()
  605. def add_forest_class():
  606. API.add_leaner("Forest_class")
  607. @staticmethod
  608. @exception_catch()
  609. def add_tree_class():
  610. API.add_leaner("Tree_class")
  611. @staticmethod
  612. @exception_catch()
  613. def add_tree():
  614. API.add_leaner("Tree")
  615. @staticmethod
  616. @exception_catch()
  617. def add_select_k_best():
  618. API.add_leaner("SelectKBest")
  619. @staticmethod
  620. @exception_catch()
  621. def add_knn_class():
  622. API.add_leaner("Knn_class")
  623. @staticmethod
  624. @exception_catch()
  625. def add_logistic_regression():
  626. API.add_leaner("LogisticRegression")
  627. @staticmethod
  628. @exception_catch()
  629. def add_lasso():
  630. API.add_leaner("Lasso")
  631. @staticmethod
  632. @exception_catch()
  633. def add_variance():
  634. API.add_leaner("Variance")
  635. @staticmethod
  636. @exception_catch()
  637. def add_knn():
  638. API.add_leaner("Knn")
  639. @staticmethod
  640. @exception_catch()
  641. def add_ridge():
  642. API.add_leaner("Ridge")
  643. @staticmethod
  644. @exception_catch()
  645. def add_line():
  646. API.add_leaner("Line")
  647. @staticmethod
  648. @exception_catch()
  649. def add_select_from_model(): # 添加Lenear的核心
  650. learner_controller.add_select_from_model(
  651. API.get_learner_gui(), parameters=API.get_learner_parameters_gui()
  652. )
  653. API.update_leaner_gui()
  654. @staticmethod
  655. @exception_catch()
  656. def add_leaner(learner_type): # 添加Lenear的核心
  657. learner_controller.add_learner(
  658. learner_type, parameters=API.get_learner_parameters_gui()
  659. )
  660. API.update_leaner_gui()
  661. @staticmethod
  662. @exception_catch()
  663. def to_html_one():
  664. html_dir = f"{PATH}{os.sep}$Show_Sheet.html"
  665. name = API.get_data_name_gui()
  666. assert name is not None
  667. learner_controller.to_html_one(name, html_dir)
  668. webbrowser.open(html_dir)
  669. @staticmethod
  670. @exception_catch()
  671. def del_sheet():
  672. name = API.get_data_name_gui()
  673. assert name is not None
  674. learner_controller.del_sheet(name)
  675. API.update_sheet_box_gui()
  676. @staticmethod
  677. @exception_catch()
  678. def to_html():
  679. html_dir = f"{PATH}{os.sep}$Show_Sheet.html"
  680. name = API.get_data_name_gui()
  681. assert name is not None
  682. learner_controller.to_html(name, html_dir, to_html_type.get())
  683. webbrowser.open(html_dir)
  684. @staticmethod
  685. @exception_catch()
  686. def to_csv():
  687. learner_controller.to_csv(*API.to_csv_gui())
  688. API.update_sheet_box_gui()
  689. @staticmethod
  690. @exception_catch()
  691. def add_csv():
  692. learner_controller.read_csv(*API.add_csv_gui())
  693. API.update_sheet_box_gui()
  694. @staticmethod
  695. @exception_catch()
  696. def add_python():
  697. code, name = API.add_python_gui()
  698. learner_controller.add_python(code, name)
  699. API.update_sheet_box_gui()
  700. def machine_learning(in_queue, out_queue):
  701. global SCREEN
  702. queue_controller.set_queue(in_queue, out_queue)
  703. queue_controller()
  704. SCREEN.mainloop()
  705. queue_controller.stop_process()
  706. SCREEN.title("CoTan机器学习")
  707. SCREEN.resizable(width=False, height=False)
  708. SCREEN.geometry("+10+10") # 设置所在位置
  709. SCREEN.iconbitmap(bitmap=f'Pic{os.sep}favicon.ico', default=f'Pic{os.sep}favicon.ico')
  710. tkinter.Button(
  711. SCREEN,
  712. bg=botton_color,
  713. fg=word_color,
  714. text="导入CSV",
  715. command=API.add_csv,
  716. font=FONT,
  717. width=gui_width,
  718. height=gui_height,
  719. ).grid(
  720. column=column,
  721. row=row,
  722. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  723. )
  724. tkinter.Button(
  725. SCREEN,
  726. bg=botton_color,
  727. fg=word_color,
  728. text="导入Py",
  729. command=API.add_python,
  730. font=FONT,
  731. width=gui_width,
  732. height=gui_height,
  733. ).grid(
  734. column=column + 1,
  735. row=row,
  736. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  737. )
  738. tkinter.Button(
  739. SCREEN,
  740. bg=botton_color,
  741. fg=word_color,
  742. text="导出CSV",
  743. command=API.to_csv,
  744. font=FONT,
  745. width=gui_width,
  746. height=gui_height,
  747. ).grid(
  748. column=column + 2,
  749. row=row,
  750. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  751. )
  752. row += 1
  753. tkinter.Label(
  754. SCREEN,
  755. text="表格名称:",
  756. bg=bg_color,
  757. fg=word_color,
  758. font=FONT,
  759. width=gui_width,
  760. height=gui_height,
  761. ).grid(
  762. column=column, row=row
  763. ) # 设置说明
  764. sheet_name = tkinter.Entry(SCREEN, width=gui_width)
  765. sheet_name.grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  766. row += 1
  767. tkinter.Button(
  768. SCREEN,
  769. bg=botton_color,
  770. fg=word_color,
  771. text="删除表格",
  772. font=FONT,
  773. command=API.del_sheet,
  774. width=gui_width,
  775. height=gui_height,
  776. ).grid(
  777. column=column,
  778. row=row,
  779. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  780. )
  781. tkinter.Button(
  782. SCREEN,
  783. bg=botton_color,
  784. fg=word_color,
  785. text="查看表格",
  786. command=API.to_html,
  787. font=FONT,
  788. width=gui_width,
  789. height=gui_height,
  790. ).grid(
  791. column=column + 1,
  792. row=row,
  793. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  794. )
  795. tkinter.Button(
  796. SCREEN,
  797. bg=botton_color,
  798. fg=word_color,
  799. text="查看单一表格",
  800. command=API.to_html_one,
  801. font=FONT,
  802. width=gui_width,
  803. height=gui_height,
  804. ).grid(
  805. column=column + 2,
  806. row=row,
  807. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  808. )
  809. row += 1
  810. to_html_type = tkinter.IntVar() # 正,负,0
  811. lable = ["选项卡型", "可移动型", "自适应型"] # 复选框
  812. for i in range(3):
  813. tkinter.Radiobutton(
  814. SCREEN,
  815. bg=bg_color,
  816. fg=word_color,
  817. activebackground=bg_color,
  818. activeforeground=word_color,
  819. selectcolor=bg_color,
  820. text=lable[i],
  821. variable=to_html_type,
  822. value=i,
  823. ).grid(column=column + i, row=row, sticky=tkinter.W)
  824. dtype_str = tkinter.IntVar()
  825. row += 1
  826. tkinter.Label(
  827. SCREEN,
  828. text="编码方式:",
  829. bg=bg_color,
  830. fg=word_color,
  831. font=FONT,
  832. width=gui_width,
  833. height=gui_height,
  834. ).grid(
  835. column=column, row=row
  836. ) # 设置说明
  837. encoding = tkinter.Entry(SCREEN, width=gui_width)
  838. encoding.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  839. buttom = tkinter.Checkbutton(
  840. SCREEN,
  841. bg=bg_color,
  842. fg=word_color,
  843. activebackground=bg_color,
  844. activeforeground=word_color,
  845. selectcolor=bg_color,
  846. text="字符串类型",
  847. variable=dtype_str,
  848. )
  849. buttom.grid(column=column + 2, row=row, sticky=tkinter.W)
  850. row += 1
  851. tkinter.Label(
  852. SCREEN,
  853. text="CSV分隔符:",
  854. bg=bg_color,
  855. fg=word_color,
  856. font=FONT,
  857. width=gui_width,
  858. height=gui_height,
  859. ).grid(
  860. column=column, row=row
  861. ) # 设置说明
  862. sep = tkinter.Entry(SCREEN, width=gui_width)
  863. sep.grid(column=column + 1, columnspan=2, row=row, sticky=tkinter.E + tkinter.W)
  864. row += 1
  865. sheet_box = tkinter.Listbox(SCREEN, width=gui_width * 3, height=gui_height * 10) # 显示符号
  866. sheet_box.grid(
  867. column=column,
  868. row=row,
  869. columnspan=3,
  870. rowspan=10,
  871. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  872. )
  873. # 422
  874. row += 10
  875. tkinter.Button(
  876. SCREEN,
  877. bg=botton_color,
  878. fg=word_color,
  879. text="添加数据",
  880. command=API.merge_add,
  881. font=FONT,
  882. width=gui_width,
  883. height=gui_height,
  884. ).grid(
  885. column=column,
  886. row=row,
  887. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  888. )
  889. tkinter.Button(
  890. SCREEN,
  891. bg=botton_color,
  892. fg=word_color,
  893. text="删除数据",
  894. command=API.merge_del,
  895. font=FONT,
  896. width=gui_width,
  897. height=gui_height,
  898. ).grid(
  899. column=column + 1,
  900. row=row,
  901. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  902. )
  903. tkinter.Button(
  904. SCREEN,
  905. bg=botton_color,
  906. fg=word_color,
  907. text="组合数据",
  908. command=API.merge,
  909. font=FONT,
  910. width=gui_width,
  911. height=gui_height,
  912. ).grid(
  913. column=column + 2,
  914. row=row,
  915. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  916. )
  917. row += 1
  918. merge_box = tkinter.Listbox(SCREEN, width=gui_width * 3, height=gui_height * 3) # 显示符号
  919. merge_box.grid(
  920. column=column,
  921. row=row,
  922. columnspan=3,
  923. rowspan=3,
  924. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  925. )
  926. row += 3
  927. processing_type = tkinter.IntVar() # 正,负,0
  928. lable = ["横向处理", "纵向处理", "深度处理"] # 复选框
  929. for i in range(3):
  930. tkinter.Radiobutton(
  931. SCREEN,
  932. bg=bg_color,
  933. fg=word_color,
  934. activebackground=bg_color,
  935. activeforeground=word_color,
  936. selectcolor=bg_color,
  937. text=lable[i],
  938. variable=processing_type,
  939. value=i,
  940. ).grid(column=column + i, row=row, sticky=tkinter.W)
  941. row += 1
  942. tkinter.Button(
  943. SCREEN,
  944. bg=botton_color,
  945. fg=word_color,
  946. text="数据切片",
  947. command=API.two_split,
  948. font=FONT,
  949. width=gui_width,
  950. height=gui_height,
  951. ).grid(
  952. column=column,
  953. row=row,
  954. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  955. )
  956. tkinter.Button(
  957. SCREEN,
  958. bg=botton_color,
  959. fg=word_color,
  960. text="数据分割",
  961. command=API.split,
  962. font=FONT,
  963. width=gui_width,
  964. height=gui_height,
  965. ).grid(
  966. column=column + 1,
  967. row=row,
  968. columnspan=2,
  969. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  970. )
  971. row += 1
  972. tkinter.Label(
  973. SCREEN,
  974. text="重塑形状:",
  975. bg=bg_color,
  976. fg=word_color,
  977. font=FONT,
  978. width=gui_width,
  979. height=gui_height,
  980. ).grid(column=column, row=row)
  981. shape = tkinter.Entry(SCREEN, width=gui_width)
  982. shape.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  983. tkinter.Button(
  984. SCREEN,
  985. bg=botton_color,
  986. fg=word_color,
  987. text="矩阵重塑",
  988. command=API.reshape,
  989. font=FONT,
  990. width=gui_width,
  991. height=gui_height,
  992. ).grid(
  993. column=column + 2,
  994. row=row,
  995. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  996. )
  997. row += 1
  998. tkinter.Button(
  999. SCREEN,
  1000. bg=botton_color,
  1001. fg=word_color,
  1002. text="矩阵伸展",
  1003. command=API.reval,
  1004. font=FONT,
  1005. width=gui_width,
  1006. height=gui_height,
  1007. ).grid(
  1008. column=column,
  1009. row=row,
  1010. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1011. )
  1012. tkinter.Button(
  1013. SCREEN,
  1014. bg=botton_color,
  1015. fg=word_color,
  1016. text="矩阵降维",
  1017. command=API.del_ndim,
  1018. font=FONT,
  1019. width=gui_width,
  1020. height=gui_height,
  1021. ).grid(
  1022. column=column + 1,
  1023. row=row,
  1024. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1025. )
  1026. tkinter.Button(
  1027. SCREEN,
  1028. bg=botton_color,
  1029. fg=word_color,
  1030. text="矩阵转置",
  1031. command=API.transpose,
  1032. font=FONT,
  1033. width=gui_width,
  1034. height=gui_height,
  1035. ).grid(
  1036. column=column + 2,
  1037. row=row,
  1038. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1039. )
  1040. column += 3
  1041. tkinter.Label(SCREEN, text="", bg=bg_color, fg=word_color, font=FONT, width=1).grid(
  1042. column=column, row=row
  1043. ) # 设置说明
  1044. column += 1
  1045. row = 0
  1046. tkinter.Label(
  1047. SCREEN,
  1048. text="【机器学习】",
  1049. bg=bg_color,
  1050. fg=word_color,
  1051. font=FONT,
  1052. width=gui_width * 3,
  1053. height=gui_height,
  1054. ).grid(
  1055. column=column,
  1056. columnspan=3,
  1057. row=row,
  1058. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1059. ) # 设置说明
  1060. row += 1
  1061. x_data = tkinter.StringVar()
  1062. put = tkinter.Entry(SCREEN, width=gui_width * 2, textvariable=x_data)
  1063. put.grid(column=column, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  1064. put["state"] = "readonly"
  1065. tkinter.Button(
  1066. SCREEN,
  1067. bg=botton_color,
  1068. fg=word_color,
  1069. text="选用X集",
  1070. command=API.set_x_data_gui,
  1071. font=FONT,
  1072. width=gui_width,
  1073. height=gui_height,
  1074. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  1075. y_data = tkinter.StringVar()
  1076. row += 1
  1077. put = tkinter.Entry(SCREEN, width=gui_width * 2, textvariable=y_data)
  1078. put.grid(column=column, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  1079. put["state"] = "readonly"
  1080. tkinter.Button(
  1081. SCREEN,
  1082. bg=botton_color,
  1083. fg=word_color,
  1084. text="选用Y集",
  1085. command=API.set_y_data_gui,
  1086. font=FONT,
  1087. width=gui_width,
  1088. height=gui_height,
  1089. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  1090. learner_output = tkinter.StringVar()
  1091. row += 1
  1092. put = tkinter.Entry(SCREEN, width=gui_width * 2, textvariable=learner_output)
  1093. put.grid(column=column, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  1094. put["state"] = "readonly"
  1095. tkinter.Button(
  1096. SCREEN,
  1097. bg=botton_color,
  1098. fg=word_color,
  1099. text="选用学习器",
  1100. command=API.set_learner_gui,
  1101. font=FONT,
  1102. width=gui_width,
  1103. height=gui_height,
  1104. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  1105. row += 1
  1106. tkinter.Label(
  1107. SCREEN,
  1108. text="测试数据分割:",
  1109. bg=bg_color,
  1110. fg=word_color,
  1111. font=FONT,
  1112. width=gui_width,
  1113. height=gui_height,
  1114. ).grid(column=column, row=row)
  1115. data_split = tkinter.Entry(SCREEN, width=gui_width * 2)
  1116. data_split.grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  1117. row += 1
  1118. learner_box = tkinter.Listbox(SCREEN, width=gui_width * 3, height=gui_height * 5)
  1119. learner_box.grid(
  1120. column=column,
  1121. row=row,
  1122. columnspan=3,
  1123. rowspan=5,
  1124. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  1125. )
  1126. row += 5
  1127. tkinter.Button(
  1128. SCREEN,
  1129. bg=botton_color,
  1130. fg=word_color,
  1131. text="导入学习器",
  1132. font=FONT,
  1133. command=API.add_learner_from_python,
  1134. width=gui_width,
  1135. height=gui_height,
  1136. ).grid(
  1137. column=column,
  1138. row=row,
  1139. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1140. )
  1141. tkinter.Button(
  1142. SCREEN,
  1143. bg=botton_color,
  1144. fg=word_color,
  1145. text="查看数据",
  1146. command=API.visualization_results,
  1147. font=FONT,
  1148. width=gui_width,
  1149. height=gui_height,
  1150. ).grid(
  1151. column=column + 1,
  1152. row=row,
  1153. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1154. )
  1155. tkinter.Button(
  1156. SCREEN,
  1157. bg=botton_color,
  1158. fg=word_color,
  1159. text="删除学习器",
  1160. command=API.del_leaner,
  1161. font=FONT,
  1162. width=gui_width,
  1163. height=gui_height,
  1164. ).grid(
  1165. column=column + 2,
  1166. row=row,
  1167. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1168. )
  1169. row += 1
  1170. tkinter.Button(
  1171. SCREEN,
  1172. bg=botton_color,
  1173. fg=word_color,
  1174. text="训练机器",
  1175. command=API.fit_learner,
  1176. font=FONT,
  1177. width=gui_width,
  1178. height=gui_height,
  1179. ).grid(
  1180. column=column,
  1181. row=row,
  1182. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1183. )
  1184. tkinter.Button(
  1185. SCREEN,
  1186. bg=botton_color,
  1187. fg=word_color,
  1188. text="测试机器",
  1189. command=API.score_learner,
  1190. font=FONT,
  1191. width=gui_width,
  1192. height=gui_height,
  1193. ).grid(
  1194. column=column + 1,
  1195. row=row,
  1196. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1197. )
  1198. tkinter.Button(
  1199. SCREEN,
  1200. bg=botton_color,
  1201. fg=word_color,
  1202. text="数据预测",
  1203. command=API.predict_learner,
  1204. font=FONT,
  1205. width=gui_width,
  1206. height=gui_height,
  1207. ).grid(
  1208. column=column + 2,
  1209. row=row,
  1210. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1211. )
  1212. row += 1
  1213. tkinter.Button(
  1214. SCREEN,
  1215. bg=botton_color,
  1216. fg=word_color,
  1217. text="单一变量特征选择",
  1218. command=API.add_select_k_best,
  1219. font=FONT,
  1220. width=gui_width,
  1221. height=gui_height,
  1222. ).grid(
  1223. column=column,
  1224. row=row,
  1225. columnspan=2,
  1226. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1227. )
  1228. tkinter.Button(
  1229. SCREEN,
  1230. bg=botton_color,
  1231. fg=word_color,
  1232. text="映射标准化",
  1233. command=API.add_mapzoom,
  1234. font=FONT,
  1235. width=gui_width,
  1236. height=gui_height,
  1237. ).grid(
  1238. column=column + 2,
  1239. row=row,
  1240. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1241. )
  1242. row += 1
  1243. tkinter.Button(
  1244. SCREEN,
  1245. bg=botton_color,
  1246. fg=word_color,
  1247. text="方差特征选择",
  1248. command=API.add_variance,
  1249. font=FONT,
  1250. width=gui_width,
  1251. height=gui_height,
  1252. ).grid(
  1253. column=column,
  1254. row=row,
  1255. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1256. )
  1257. tkinter.Button(
  1258. SCREEN,
  1259. bg=botton_color,
  1260. fg=word_color,
  1261. text="使用学习器筛选",
  1262. command=API.add_select_from_model,
  1263. font=FONT,
  1264. width=gui_width,
  1265. height=gui_height,
  1266. ).grid(
  1267. column=column + 1,
  1268. row=row,
  1269. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1270. )
  1271. tkinter.Button(
  1272. SCREEN,
  1273. bg=botton_color,
  1274. fg=word_color,
  1275. text="模糊量化标准化",
  1276. command=API.add_fuzzy_quantization,
  1277. font=FONT,
  1278. width=gui_width,
  1279. height=gui_height,
  1280. ).grid(
  1281. column=column + 2,
  1282. row=row,
  1283. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1284. )
  1285. row += 1
  1286. tkinter.Button(
  1287. SCREEN,
  1288. bg=botton_color,
  1289. fg=word_color,
  1290. text="Z-score",
  1291. command=API.add_z_score,
  1292. font=FONT,
  1293. width=gui_width,
  1294. height=gui_height,
  1295. ).grid(
  1296. column=column,
  1297. row=row,
  1298. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1299. )
  1300. tkinter.Button(
  1301. SCREEN,
  1302. bg=botton_color,
  1303. fg=word_color,
  1304. text="离差标准化",
  1305. command=API.add_min_max_scaler,
  1306. font=FONT,
  1307. width=gui_width,
  1308. height=gui_height,
  1309. ).grid(
  1310. column=column + 1,
  1311. row=row,
  1312. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1313. )
  1314. tkinter.Button(
  1315. SCREEN,
  1316. bg=botton_color,
  1317. fg=word_color,
  1318. text="Log变换",
  1319. command=API.add_log_scaler,
  1320. font=FONT,
  1321. width=gui_width,
  1322. height=gui_height,
  1323. ).grid(
  1324. column=column + 2,
  1325. row=row,
  1326. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1327. )
  1328. row += 1
  1329. tkinter.Button(
  1330. SCREEN,
  1331. bg=botton_color,
  1332. fg=word_color,
  1333. text="atan变换",
  1334. command=API.add_atan_scaler,
  1335. font=FONT,
  1336. width=gui_width,
  1337. height=gui_height,
  1338. ).grid(
  1339. column=column,
  1340. row=row,
  1341. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1342. )
  1343. tkinter.Button(
  1344. SCREEN,
  1345. bg=botton_color,
  1346. fg=word_color,
  1347. text="小数定标准化",
  1348. command=API.add_decimal_scaler,
  1349. font=FONT,
  1350. width=gui_width,
  1351. height=gui_height,
  1352. ).grid(
  1353. column=column + 1,
  1354. row=row,
  1355. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1356. )
  1357. tkinter.Button(
  1358. SCREEN,
  1359. bg=botton_color,
  1360. fg=word_color,
  1361. text="Sigmod变换",
  1362. command=API.add_sigmod_scaler,
  1363. font=FONT,
  1364. width=gui_width,
  1365. height=gui_height,
  1366. ).grid(
  1367. column=column + 2,
  1368. row=row,
  1369. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1370. )
  1371. row += 1
  1372. tkinter.Button(
  1373. SCREEN,
  1374. bg=botton_color,
  1375. fg=word_color,
  1376. text="正则化",
  1377. command=API.add_regularization,
  1378. font=FONT,
  1379. width=gui_width,
  1380. height=gui_height,
  1381. ).grid(
  1382. column=column,
  1383. row=row,
  1384. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1385. )
  1386. tkinter.Button(
  1387. SCREEN,
  1388. bg=botton_color,
  1389. fg=word_color,
  1390. text="二值离散",
  1391. command=API.add_binarizer,
  1392. font=FONT,
  1393. width=gui_width,
  1394. height=gui_height,
  1395. ).grid(
  1396. column=column + 1,
  1397. row=row,
  1398. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1399. )
  1400. tkinter.Button(
  1401. SCREEN,
  1402. bg=botton_color,
  1403. fg=word_color,
  1404. text="多值离散",
  1405. command=API.add_discretization,
  1406. font=FONT,
  1407. width=gui_width,
  1408. height=gui_height,
  1409. ).grid(
  1410. column=column + 2,
  1411. row=row,
  1412. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1413. )
  1414. row += 1
  1415. tkinter.Button(
  1416. SCREEN,
  1417. bg=botton_color,
  1418. fg=word_color,
  1419. text="独热编码",
  1420. command=API.add_one_hot_encoder,
  1421. font=FONT,
  1422. width=gui_width,
  1423. height=gui_height,
  1424. ).grid(
  1425. column=column,
  1426. row=row,
  1427. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1428. )
  1429. tkinter.Button(
  1430. SCREEN,
  1431. bg=botton_color,
  1432. fg=word_color,
  1433. text="数字编码",
  1434. command=API.add_label,
  1435. font=FONT,
  1436. width=gui_width,
  1437. height=gui_height,
  1438. ).grid(
  1439. column=column + 1,
  1440. row=row,
  1441. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1442. )
  1443. tkinter.Button(
  1444. SCREEN,
  1445. bg=botton_color,
  1446. fg=word_color,
  1447. text="缺失填充",
  1448. command=API.add_missed,
  1449. font=FONT,
  1450. width=gui_width,
  1451. height=gui_height,
  1452. ).grid(
  1453. column=column + 2,
  1454. row=row,
  1455. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1456. )
  1457. row += 1
  1458. tkinter.Button(
  1459. SCREEN,
  1460. bg=botton_color,
  1461. fg=word_color,
  1462. text="PCA降维",
  1463. command=API.add_pca,
  1464. font=FONT,
  1465. width=gui_width,
  1466. height=gui_height,
  1467. ).grid(
  1468. column=column,
  1469. row=row,
  1470. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1471. )
  1472. tkinter.Button(
  1473. SCREEN,
  1474. bg=botton_color,
  1475. fg=word_color,
  1476. text="RPCA降维",
  1477. command=API.add_rpca,
  1478. font=FONT,
  1479. width=gui_width,
  1480. height=gui_height,
  1481. ).grid(
  1482. column=column + 1,
  1483. row=row,
  1484. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1485. )
  1486. tkinter.Button(
  1487. SCREEN,
  1488. bg=botton_color,
  1489. fg=word_color,
  1490. text="KPCA升维",
  1491. command=API.add_kpca,
  1492. font=FONT,
  1493. width=gui_width,
  1494. height=gui_height,
  1495. ).grid(
  1496. column=column + 2,
  1497. row=row,
  1498. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1499. )
  1500. row += 1
  1501. tkinter.Button(
  1502. SCREEN,
  1503. bg=botton_color,
  1504. fg=word_color,
  1505. text="LDA降维",
  1506. command=API.add_lda,
  1507. font=FONT,
  1508. width=gui_width,
  1509. height=gui_height,
  1510. ).grid(
  1511. column=column,
  1512. row=row,
  1513. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1514. )
  1515. tkinter.Button(
  1516. SCREEN,
  1517. bg=botton_color,
  1518. fg=word_color,
  1519. text="NMF降维",
  1520. command=API.add_nmf,
  1521. font=FONT,
  1522. width=gui_width,
  1523. height=gui_height,
  1524. ).grid(
  1525. column=column + 1,
  1526. row=row,
  1527. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1528. )
  1529. tkinter.Button(
  1530. SCREEN,
  1531. bg=botton_color,
  1532. fg=word_color,
  1533. text="t-SNE",
  1534. command=API.add_tsne,
  1535. font=FONT,
  1536. width=gui_width,
  1537. height=gui_height,
  1538. ).grid(
  1539. column=column + 2,
  1540. row=row,
  1541. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1542. )
  1543. row += 1
  1544. tkinter.Button(
  1545. SCREEN,
  1546. bg=botton_color,
  1547. fg=word_color,
  1548. text="线性回归",
  1549. command=API.add_line,
  1550. font=FONT,
  1551. width=gui_width,
  1552. height=gui_height,
  1553. ).grid(
  1554. column=column,
  1555. row=row,
  1556. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1557. )
  1558. tkinter.Button(
  1559. SCREEN,
  1560. bg=botton_color,
  1561. fg=word_color,
  1562. text="岭回归",
  1563. command=API.add_ridge,
  1564. font=FONT,
  1565. width=gui_width,
  1566. height=gui_height,
  1567. ).grid(
  1568. column=column + 1,
  1569. row=row,
  1570. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1571. )
  1572. tkinter.Button(
  1573. SCREEN,
  1574. bg=botton_color,
  1575. fg=word_color,
  1576. text="Lasso",
  1577. command=API.add_lasso,
  1578. font=FONT,
  1579. width=gui_width,
  1580. height=gui_height,
  1581. ).grid(
  1582. column=column + 2,
  1583. row=row,
  1584. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1585. )
  1586. row += 1
  1587. tkinter.Button(
  1588. SCREEN,
  1589. bg=botton_color,
  1590. fg=word_color,
  1591. text="逻辑回归",
  1592. command=API.add_logistic_regression,
  1593. font=FONT,
  1594. width=gui_width,
  1595. height=gui_height,
  1596. ).grid(
  1597. column=column,
  1598. row=row,
  1599. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1600. )
  1601. tkinter.Button(
  1602. SCREEN,
  1603. bg=botton_color,
  1604. fg=word_color,
  1605. text="K邻近预测",
  1606. command=API.add_knn,
  1607. font=FONT,
  1608. width=gui_width,
  1609. height=gui_height,
  1610. ).grid(
  1611. column=column + 1,
  1612. row=row,
  1613. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1614. )
  1615. tkinter.Button(
  1616. SCREEN,
  1617. bg=botton_color,
  1618. fg=word_color,
  1619. text="K邻近分类",
  1620. command=API.add_knn_class,
  1621. font=FONT,
  1622. width=gui_width,
  1623. height=gui_height,
  1624. ).grid(
  1625. column=column + 2,
  1626. row=row,
  1627. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1628. )
  1629. row += 1
  1630. tkinter.Button(
  1631. SCREEN,
  1632. bg=botton_color,
  1633. fg=word_color,
  1634. text="梯度回归树回归",
  1635. command=API.add_gradient_tree,
  1636. font=FONT,
  1637. width=gui_width,
  1638. height=gui_height,
  1639. ).grid(
  1640. column=column,
  1641. row=row,
  1642. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1643. )
  1644. tkinter.Button(
  1645. SCREEN,
  1646. bg=botton_color,
  1647. fg=word_color,
  1648. text="决策树回归",
  1649. command=API.add_tree,
  1650. font=FONT,
  1651. width=gui_width,
  1652. height=gui_height,
  1653. ).grid(
  1654. column=column + 1,
  1655. row=row,
  1656. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1657. )
  1658. tkinter.Button(
  1659. SCREEN,
  1660. bg=botton_color,
  1661. fg=word_color,
  1662. text="决策树分类",
  1663. command=API.add_tree_class,
  1664. font=FONT,
  1665. width=gui_width,
  1666. height=gui_height,
  1667. ).grid(
  1668. column=column + 2,
  1669. row=row,
  1670. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1671. )
  1672. row += 1
  1673. tkinter.Button(
  1674. SCREEN,
  1675. bg=botton_color,
  1676. fg=word_color,
  1677. text="梯度回归树分类",
  1678. command=API.add_gradient_tree_class,
  1679. font=FONT,
  1680. width=gui_width,
  1681. height=gui_height,
  1682. ).grid(
  1683. column=column,
  1684. row=row,
  1685. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1686. )
  1687. tkinter.Button(
  1688. SCREEN,
  1689. bg=botton_color,
  1690. fg=word_color,
  1691. text="随机森林回归",
  1692. command=API.add_forest,
  1693. font=FONT,
  1694. width=gui_width,
  1695. height=gui_height,
  1696. ).grid(
  1697. column=column + 1,
  1698. row=row,
  1699. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1700. )
  1701. tkinter.Button(
  1702. SCREEN,
  1703. bg=botton_color,
  1704. fg=word_color,
  1705. text="随机森林分类",
  1706. command=API.add_forest_class,
  1707. font=FONT,
  1708. width=gui_width,
  1709. height=gui_height,
  1710. ).grid(
  1711. column=column + 2,
  1712. row=row,
  1713. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1714. )
  1715. column += 3
  1716. tkinter.Label(SCREEN, text="", bg=bg_color, fg=word_color, font=FONT, width=1).grid(
  1717. column=column, row=row
  1718. ) # 设置说明
  1719. column += 1
  1720. row = 0
  1721. tkinter.Button(
  1722. SCREEN,
  1723. bg=botton_color,
  1724. fg=word_color,
  1725. text="多层感知机回归",
  1726. command=API.add_mlp,
  1727. font=FONT,
  1728. width=gui_width,
  1729. height=gui_height,
  1730. ).grid(
  1731. column=column,
  1732. row=row,
  1733. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1734. )
  1735. tkinter.Button(
  1736. SCREEN,
  1737. bg=botton_color,
  1738. fg=word_color,
  1739. text="多层感知机分类",
  1740. command=API.add_mlp_class,
  1741. font=FONT,
  1742. width=gui_width,
  1743. height=gui_height,
  1744. ).grid(
  1745. column=column + 1,
  1746. row=row,
  1747. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1748. )
  1749. tkinter.Button(
  1750. SCREEN,
  1751. bg=botton_color,
  1752. fg=word_color,
  1753. text="随机森林分类",
  1754. command=API.add_forest_class,
  1755. font=FONT,
  1756. width=gui_width,
  1757. height=gui_height,
  1758. ).grid(
  1759. column=column + 2,
  1760. row=row,
  1761. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1762. )
  1763. row += 1
  1764. tkinter.Button(
  1765. SCREEN,
  1766. bg=botton_color,
  1767. fg=word_color,
  1768. text="支持向量机分类:SVC",
  1769. command=API.add_svc,
  1770. font=FONT,
  1771. width=gui_width,
  1772. height=gui_height,
  1773. ).grid(
  1774. column=column,
  1775. row=row,
  1776. columnspan=2,
  1777. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1778. )
  1779. tkinter.Button(
  1780. SCREEN,
  1781. bg=botton_color,
  1782. fg=word_color,
  1783. text="回归:SVR",
  1784. command=API.add_svr,
  1785. font=FONT,
  1786. width=gui_width,
  1787. height=gui_height,
  1788. ).grid(
  1789. column=column + 2,
  1790. row=row,
  1791. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1792. )
  1793. row += 1
  1794. tkinter.Button(
  1795. SCREEN,
  1796. bg=botton_color,
  1797. fg=word_color,
  1798. text="k-means",
  1799. command=API.add_k_means,
  1800. font=FONT,
  1801. width=gui_width,
  1802. height=gui_height,
  1803. ).grid(
  1804. column=column,
  1805. row=row,
  1806. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1807. )
  1808. tkinter.Button(
  1809. SCREEN,
  1810. bg=botton_color,
  1811. fg=word_color,
  1812. text="凝聚聚类",
  1813. command=API.add_agglomerative,
  1814. font=FONT,
  1815. width=gui_width,
  1816. height=gui_height,
  1817. ).grid(
  1818. column=column + 1,
  1819. row=row,
  1820. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1821. )
  1822. tkinter.Button(
  1823. SCREEN,
  1824. bg=botton_color,
  1825. fg=word_color,
  1826. text="DBSCAN",
  1827. command=API.add_dbscan,
  1828. font=FONT,
  1829. width=gui_width,
  1830. height=gui_height,
  1831. ).grid(
  1832. column=column + 2,
  1833. row=row,
  1834. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1835. )
  1836. row += 1
  1837. tkinter.Button(
  1838. SCREEN,
  1839. bg=botton_color,
  1840. fg=word_color,
  1841. text="特征分类图",
  1842. command=API.add_class_bar,
  1843. font=FONT,
  1844. width=gui_width,
  1845. height=gui_height,
  1846. ).grid(
  1847. column=column,
  1848. row=row,
  1849. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1850. )
  1851. tkinter.Button(
  1852. SCREEN,
  1853. bg=botton_color,
  1854. fg=word_color,
  1855. text="临近特征回归图",
  1856. command=API.add_feature_scatter,
  1857. font=FONT,
  1858. width=gui_width,
  1859. height=gui_height,
  1860. ).grid(
  1861. column=column + 1,
  1862. row=row,
  1863. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1864. )
  1865. tkinter.Button(
  1866. SCREEN,
  1867. bg=botton_color,
  1868. fg=word_color,
  1869. text="临近特征分类图",
  1870. command=API.add_feature_scatter_class,
  1871. font=FONT,
  1872. width=gui_width,
  1873. height=gui_height,
  1874. ).grid(
  1875. column=column + 2,
  1876. row=row,
  1877. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1878. )
  1879. row += 1
  1880. tkinter.Button(
  1881. SCREEN,
  1882. bg=botton_color,
  1883. fg=word_color,
  1884. text="所有特征回归图",
  1885. command=API.add_feature_scatter_all,
  1886. font=FONT,
  1887. width=gui_width,
  1888. height=gui_height,
  1889. ).grid(
  1890. column=column,
  1891. row=row,
  1892. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1893. )
  1894. tkinter.Button(
  1895. SCREEN,
  1896. bg=botton_color,
  1897. fg=word_color,
  1898. text="所有特征分类图",
  1899. command=API.add_feature_scatter_class_all,
  1900. font=FONT,
  1901. width=gui_width,
  1902. height=gui_height,
  1903. ).grid(
  1904. column=column + 1,
  1905. row=row,
  1906. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1907. )
  1908. tkinter.Button(
  1909. SCREEN,
  1910. bg=botton_color,
  1911. fg=word_color,
  1912. text="临近特征预测图",
  1913. command=API.add_predictive_heatmap,
  1914. font=FONT,
  1915. width=gui_width,
  1916. height=gui_height,
  1917. ).grid(
  1918. column=column + 2,
  1919. row=row,
  1920. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1921. )
  1922. row += 1
  1923. tkinter.Button(
  1924. SCREEN,
  1925. bg=botton_color,
  1926. fg=word_color,
  1927. text="所有特征预测图",
  1928. command=API.add_predictive_heatmap_more,
  1929. font=FONT,
  1930. width=gui_width,
  1931. height=gui_height,
  1932. ).grid(
  1933. column=column,
  1934. row=row,
  1935. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1936. )
  1937. tkinter.Button(
  1938. SCREEN,
  1939. bg=botton_color,
  1940. fg=word_color,
  1941. text="矩阵热力图",
  1942. command=API.add_numpy_to_heatmap,
  1943. font=FONT,
  1944. width=gui_width,
  1945. height=gui_height,
  1946. ).grid(
  1947. column=column + 1,
  1948. row=row,
  1949. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1950. )
  1951. tkinter.Button(
  1952. SCREEN,
  1953. bg=botton_color,
  1954. fg=word_color,
  1955. text="数据y-x散点图",
  1956. command=API.add_feature_y_x,
  1957. font=FONT,
  1958. width=gui_width,
  1959. height=gui_height,
  1960. ).grid(
  1961. column=column + 2,
  1962. row=row,
  1963. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1964. )
  1965. row += 1
  1966. tkinter.Button(
  1967. SCREEN,
  1968. bg=botton_color,
  1969. fg=word_color,
  1970. text="聚类树状图",
  1971. command=API.add_cluster_tree,
  1972. font=FONT,
  1973. width=gui_width,
  1974. height=gui_height,
  1975. ).grid(
  1976. column=column,
  1977. row=row,
  1978. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1979. )
  1980. tkinter.Button(
  1981. SCREEN,
  1982. bg=botton_color,
  1983. fg=word_color,
  1984. text="获取数据",
  1985. command=API.add_view_data,
  1986. font=FONT,
  1987. width=gui_width,
  1988. height=gui_height,
  1989. ).grid(
  1990. column=column + 1,
  1991. row=row,
  1992. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1993. )
  1994. tkinter.Button(
  1995. SCREEN,
  1996. bg=botton_color,
  1997. fg=word_color,
  1998. text="矩阵散点图",
  1999. command=API.add_matrix_scatter,
  2000. font=FONT,
  2001. width=gui_width,
  2002. height=gui_height,
  2003. ).grid(
  2004. column=column + 2,
  2005. row=row,
  2006. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2007. )
  2008. row += 1
  2009. tkinter.Button(
  2010. SCREEN,
  2011. bg=botton_color,
  2012. fg=word_color,
  2013. text="特征相关性",
  2014. command=API.add_correlation,
  2015. font=FONT,
  2016. width=gui_width,
  2017. height=gui_height,
  2018. ).grid(
  2019. column=column,
  2020. row=row,
  2021. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2022. )
  2023. tkinter.Button(
  2024. SCREEN,
  2025. bg=botton_color,
  2026. fg=word_color,
  2027. text="曲线拟合",
  2028. command=API.curve_fitting,
  2029. font=FONT,
  2030. width=gui_width,
  2031. height=gui_height,
  2032. ).grid(
  2033. column=column + 1,
  2034. row=row,
  2035. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2036. )
  2037. tkinter.Button(
  2038. SCREEN,
  2039. bg=botton_color,
  2040. fg=word_color,
  2041. text="快速傅里叶",
  2042. command=API.add_fast_fourier,
  2043. font=FONT,
  2044. width=gui_width,
  2045. height=gui_height,
  2046. ).grid(
  2047. column=column + 2,
  2048. row=row,
  2049. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2050. )
  2051. row += 1
  2052. tkinter.Button(
  2053. SCREEN,
  2054. bg=botton_color,
  2055. fg=word_color,
  2056. text="数据统计",
  2057. command=API.add_statistics,
  2058. font=FONT,
  2059. width=gui_width,
  2060. height=gui_height,
  2061. ).grid(
  2062. column=column,
  2063. row=row,
  2064. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2065. )
  2066. tkinter.Button(
  2067. SCREEN,
  2068. bg=botton_color,
  2069. fg=word_color,
  2070. text="双逆向傅里叶",
  2071. command=API.add_reverse_fast_fourier2,
  2072. font=FONT,
  2073. width=gui_width,
  2074. height=gui_height,
  2075. ).grid(
  2076. column=column + 1,
  2077. row=row,
  2078. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2079. )
  2080. tkinter.Button(
  2081. SCREEN,
  2082. bg=botton_color,
  2083. fg=word_color,
  2084. text="逆向傅里叶",
  2085. command=API.add_reverse_fast_fourier,
  2086. font=FONT,
  2087. width=gui_width,
  2088. height=gui_height,
  2089. ).grid(
  2090. column=column + 2,
  2091. row=row,
  2092. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2093. )
  2094. row += 1
  2095. tkinter.Button(
  2096. SCREEN,
  2097. bg=botton_color,
  2098. fg=word_color,
  2099. text="分类模型评估",
  2100. command=API.show_class_score,
  2101. font=FONT,
  2102. width=gui_width,
  2103. height=gui_height,
  2104. ).grid(
  2105. column=column,
  2106. row=row,
  2107. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2108. )
  2109. tkinter.Button(
  2110. SCREEN,
  2111. bg=botton_color,
  2112. fg=word_color,
  2113. text="回归模型评估",
  2114. command=API.show_regression_score,
  2115. font=FONT,
  2116. width=gui_width,
  2117. height=gui_height,
  2118. ).grid(
  2119. column=column + 1,
  2120. row=row,
  2121. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2122. )
  2123. tkinter.Button(
  2124. SCREEN,
  2125. bg=botton_color,
  2126. fg=word_color,
  2127. text="聚类模型评估",
  2128. command=API.show_clustering_score,
  2129. font=FONT,
  2130. width=gui_width,
  2131. height=gui_height,
  2132. ).grid(
  2133. column=column + 2,
  2134. row=row,
  2135. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2136. )
  2137. row += 1
  2138. tkinter.Label(
  2139. SCREEN,
  2140. text="【学习器配置】",
  2141. bg=bg_color,
  2142. fg=word_color,
  2143. font=FONT,
  2144. width=gui_width * 3,
  2145. height=gui_height,
  2146. ).grid(
  2147. column=column,
  2148. columnspan=3,
  2149. row=row,
  2150. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2151. ) # 设置说明
  2152. row += 1
  2153. global_settings = []
  2154. lable = ["聚类仅邻近特征", "导出单独页面", "导出表格CSV"] # 复选框
  2155. for i in range(3):
  2156. global_settings.append(tkinter.IntVar())
  2157. tkinter.Checkbutton(
  2158. SCREEN,
  2159. bg=bg_color,
  2160. fg=word_color,
  2161. activebackground=bg_color,
  2162. activeforeground=word_color,
  2163. selectcolor=bg_color,
  2164. text=lable[i],
  2165. variable=global_settings[-1],
  2166. command=API.global_seeting,
  2167. ).grid(column=column + i, row=row, sticky=tkinter.W)
  2168. row += 1
  2169. lable = ["导出模型", "压缩为tar.gz", "创建新目录"] # 复选框
  2170. for i in range(3):
  2171. global_settings.append(tkinter.IntVar())
  2172. tkinter.Checkbutton(
  2173. SCREEN,
  2174. bg=bg_color,
  2175. fg=word_color,
  2176. activebackground=bg_color,
  2177. activeforeground=word_color,
  2178. selectcolor=bg_color,
  2179. text=lable[i],
  2180. variable=global_settings[-1],
  2181. command=API.global_seeting,
  2182. ).grid(column=column + i, row=row, sticky=tkinter.W)
  2183. for i in global_settings[1:]:
  2184. i.set(1)
  2185. API.global_seeting()
  2186. row += 1
  2187. learner_parameters = tkinter.Text(SCREEN, width=gui_width * 3, height=gui_height * 6)
  2188. learner_parameters.grid(
  2189. column=column,
  2190. row=row,
  2191. columnspan=3,
  2192. rowspan=6,
  2193. sticky=tkinter.E + tkinter.W + tkinter.N + tkinter.S,
  2194. )
  2195. row += 6
  2196. tkinter.Label(
  2197. SCREEN,
  2198. text="【矩阵运算】",
  2199. bg=bg_color,
  2200. fg=word_color,
  2201. font=FONT,
  2202. width=gui_width * 3,
  2203. height=gui_height,
  2204. ).grid(
  2205. column=column,
  2206. columnspan=3,
  2207. row=row,
  2208. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2209. ) # 设置说明
  2210. row += 1
  2211. calculation_box = tkinter.Listbox(SCREEN, width=gui_width * 3, height=gui_height * 1)
  2212. calculation_box.grid(
  2213. column=column,
  2214. row=row,
  2215. columnspan=3,
  2216. rowspan=1,
  2217. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  2218. )
  2219. row += 1
  2220. tkinter.Label(
  2221. SCREEN,
  2222. text="运算类型:",
  2223. bg=bg_color,
  2224. fg=word_color,
  2225. font=FONT,
  2226. width=gui_width,
  2227. height=gui_height,
  2228. ).grid(column=column, row=row)
  2229. calculation_type = tkinter.Entry(SCREEN, width=gui_width * 2)
  2230. calculation_type.grid(
  2231. column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W
  2232. )
  2233. row += 1
  2234. tkinter.Label(
  2235. SCREEN,
  2236. text="键入参数:",
  2237. bg=bg_color,
  2238. fg=word_color,
  2239. font=FONT,
  2240. width=gui_width,
  2241. height=gui_height,
  2242. ).grid(column=column, row=row)
  2243. value = tkinter.Entry(SCREEN, width=gui_width * 2)
  2244. value.grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  2245. row += 1
  2246. tkinter.Button(
  2247. SCREEN,
  2248. bg=botton_color,
  2249. fg=word_color,
  2250. text="选择参数",
  2251. command=API.add_calculation_object,
  2252. font=FONT,
  2253. width=gui_width,
  2254. height=gui_height,
  2255. ).grid(
  2256. column=column,
  2257. row=row,
  2258. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2259. )
  2260. tkinter.Button(
  2261. SCREEN,
  2262. bg=botton_color,
  2263. fg=word_color,
  2264. text="键入参数",
  2265. command=API.add_calculation_number,
  2266. font=FONT,
  2267. width=gui_width,
  2268. height=gui_height,
  2269. ).grid(
  2270. column=column + 1,
  2271. row=row,
  2272. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2273. )
  2274. tkinter.Button(
  2275. SCREEN,
  2276. bg=botton_color,
  2277. fg=word_color,
  2278. text="矩阵运算",
  2279. command=API.calculation,
  2280. font=FONT,
  2281. width=gui_width,
  2282. height=gui_height,
  2283. ).grid(
  2284. column=column + 2,
  2285. row=row,
  2286. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2287. )