gui.py 57 KB

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