gui.py 56 KB

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