gui.py 53 KB

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