1
0

gui.py 55 KB

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