Machine_learning.py 54 KB

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