1
0

Machine_learning.py 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  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. print('Start')
  10. def Main():
  11. global top,ML,Form_List,PATH,bg,bbg,fg,Merge_list,Cul_list,Cul_Type
  12. Cul_list = []
  13. Cul_Type = []
  14. PATH = os.getcwd()
  15. Form_List = []
  16. Merge_list = []
  17. ML = Learn_Numpy.Machine_Learner()
  18. top = tkinter.Tk()
  19. bg = '#FFFAFA' # 主颜色
  20. bbg = '#FFFAFA' # 按钮颜色
  21. fg = '#000000' # 文字颜色
  22. top["bg"] = bg
  23. FONT = ('黑体', 11) # 设置字体
  24. top.title('CoTan机器学习')
  25. top.resizable(width=False, height=False)
  26. top.geometry('+10+10') # 设置所在位置
  27. width_B = 13 # 标准宽度
  28. height_B = 2
  29. a_y = 0
  30. a_x = 0
  31. tkinter.Button(top, bg=bbg, fg=fg, text='导入CSV', command=Add_CSV, font=FONT, width=width_B,
  32. height=height_B).grid(column=a_x, row=a_y,
  33. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  34. tkinter.Button(top, bg=bbg, fg=fg, text='导入Py', command=Add_Python, font=FONT, width=width_B,
  35. height=height_B).grid(column=a_x + 1, row=a_y,
  36. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  37. tkinter.Button(top, bg=bbg, fg=fg, text='导出CSV', command=to_CSV, font=FONT, width=width_B,
  38. height=height_B).grid(column=a_x + 2, row=a_y,
  39. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  40. global name_Input
  41. a_y += 1
  42. tkinter.Label(top, text='表格名称:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
  43. row=a_y) # 设置说明
  44. name_Input = tkinter.Entry(top, width=width_B)
  45. name_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  46. a_y += 1
  47. tkinter.Button(top, bg=bbg, fg=fg, text='删除表格', font=FONT, width=width_B,
  48. height=height_B).grid(column=a_x, row=a_y,
  49. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  50. tkinter.Button(top, bg=bbg, fg=fg, text='查看表格', command=Show, font=FONT, width=width_B,
  51. height=height_B).grid(column=a_x + 1, row=a_y,
  52. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  53. tkinter.Button(top, bg=bbg, fg=fg, text='查看单一表格', command=Show_One, font=FONT, width=width_B,
  54. height=height_B).grid(column=a_x + 2, row=a_y,
  55. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  56. global Form_BOX, Index_BOX, Column_BOX, to_HTML_Type, Seq_Input, Code_Input,str_must
  57. a_y += 1
  58. to_HTML_Type = tkinter.IntVar() # 正,负,0
  59. lable = ['选项卡型', '可移动型', '自适应型'] # 复选框
  60. for i in range(3):
  61. tkinter.Radiobutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text=lable[i],
  62. variable=to_HTML_Type,
  63. value=i).grid(column=a_x + i, row=a_y, sticky=tkinter.W)
  64. str_must = tkinter.IntVar()
  65. a_y += 1
  66. tkinter.Label(top, text='编码方式:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
  67. row=a_y) # 设置说明
  68. Code_Input = tkinter.Entry(top, width=width_B)
  69. Code_Input.grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  70. buttom = tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg,
  71. text='字符串类型',
  72. variable=str_must)
  73. buttom.grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  74. a_y += 1
  75. tkinter.Label(top, text='CSV分隔符:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
  76. row=a_y) # 设置说明
  77. Seq_Input = tkinter.Entry(top, width=width_B)
  78. Seq_Input.grid(column=a_x + 1,columnspan=2, row=a_y, sticky=tkinter.E + tkinter.W)
  79. a_y += 1
  80. Form_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B * 10) # 显示符号
  81. Form_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=10, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  82. #422
  83. a_y += 10
  84. tkinter.Button(top, bg=bbg, fg=fg, text='添加数据', command=Merge_Add, font=FONT, width=width_B,
  85. height=height_B).grid(column=a_x, row=a_y,
  86. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  87. tkinter.Button(top, bg=bbg, fg=fg, text='删除数据', command=Merge_Del, font=FONT, width=width_B,
  88. height=height_B).grid(column=a_x + 1, row=a_y,
  89. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  90. tkinter.Button(top, bg=bbg, fg=fg, text='组合数据', command=Merge, font=FONT, width=width_B,
  91. height=height_B).grid(column=a_x + 2, row=a_y,
  92. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  93. global Processing_type, Shape_Input, Merge_BOX
  94. a_y += 1
  95. Merge_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B * 3) # 显示符号
  96. Merge_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=3, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  97. a_y += 3
  98. Processing_type = tkinter.IntVar()#正,负,0
  99. lable = ['横向处理','纵向处理','深度处理']#复选框
  100. for i in range(3):
  101. tkinter.Radiobutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg,text=lable[i],
  102. variable=Processing_type, value=i).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  103. a_y += 1
  104. tkinter.Button(top, bg=bbg, fg=fg, text='数据切片', command=Two_Split, font=FONT, width=width_B,
  105. height=height_B).grid(column=a_x, row=a_y,
  106. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  107. tkinter.Button(top, bg=bbg, fg=fg, text='数据分割', command=Split, font=FONT, width=width_B,
  108. height=height_B).grid(column=a_x + 1, row=a_y,columnspan=2,
  109. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  110. a_y += 1
  111. tkinter.Label(top, text='重塑形状:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
  112. Shape_Input = tkinter.Entry(top, width=width_B)
  113. Shape_Input.grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  114. tkinter.Button(top, bg=bbg, fg=fg, text='矩阵重塑', command=Reshape, font=FONT, width=width_B,
  115. height=height_B).grid(column=a_x + 2, row=a_y,
  116. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  117. a_y += 1
  118. tkinter.Button(top, bg=bbg, fg=fg, text='矩阵伸展', command=Reval, font=FONT, width=width_B,
  119. height=height_B).grid(column=a_x, row=a_y,
  120. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  121. tkinter.Button(top, bg=bbg, fg=fg, text='矩阵降维', command=Del_Ndim, font=FONT, width=width_B,
  122. height=height_B).grid(column=a_x + 1, row=a_y,
  123. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  124. tkinter.Button(top, bg=bbg, fg=fg, text='矩阵转置', command=T, font=FONT, width=width_B,
  125. height=height_B).grid(column=a_x + 2, row=a_y,
  126. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  127. a_x += 3
  128. tkinter.Label(top, text='', bg=bg, fg=fg, font=FONT, width=1).grid(column=a_x, row=a_y) # 设置说明
  129. a_x += 1
  130. a_y = 0
  131. tkinter.Label(top, text='【机器学习】', bg=bg, fg=fg, font=FONT, width=width_B * 3, height=height_B).grid(column=a_x,
  132. columnspan=3,
  133. row=a_y,
  134. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N) # 设置说明
  135. global ML_BOX, ML_OUT,X_OUT,Y_OUT
  136. a_y += 1
  137. X_OUT = tkinter.StringVar()
  138. Put = tkinter.Entry(top, width=width_B * 2, textvariable=X_OUT)
  139. Put.grid(column=a_x, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  140. Put['state'] = 'readonly'
  141. tkinter.Button(top, bg=bbg, fg=fg, text='选用X集', command=set_Feature, font=FONT, width=width_B,
  142. height=height_B).grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  143. Y_OUT = tkinter.StringVar()
  144. a_y += 1
  145. Put = tkinter.Entry(top, width=width_B * 2, textvariable=Y_OUT)
  146. Put.grid(column=a_x, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  147. Put['state'] = 'readonly'
  148. tkinter.Button(top, bg=bbg, fg=fg, text='选用Y集', command=set_Label, font=FONT, width=width_B,
  149. height=height_B).grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  150. ML_OUT = tkinter.StringVar()
  151. a_y += 1
  152. Put = tkinter.Entry(top, width=width_B * 2, textvariable=ML_OUT)
  153. Put.grid(column=a_x, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  154. Put['state'] = 'readonly'
  155. tkinter.Button(top, bg=bbg, fg=fg, text='选用学习器', command=set_Learner, font=FONT, width=width_B,
  156. height=height_B).grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  157. global Split_Input
  158. a_y += 1
  159. tkinter.Label(top, text='测试数据分割:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
  160. row=a_y)
  161. Split_Input = tkinter.Entry(top, width=width_B * 2)
  162. Split_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  163. a_y += 1
  164. ML_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B * 5)
  165. ML_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=5, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  166. a_y += 5
  167. tkinter.Button(top, bg=bbg, fg=fg, text='导入学习器', font=FONT, width=width_B, height=height_B).grid(
  168. column=a_x, row=a_y,
  169. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  170. tkinter.Button(top, bg=bbg, fg=fg, text='查看数据', command=Show_Args, font=FONT, width=width_B, height=height_B).grid(
  171. column=a_x + 1, row=a_y,
  172. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  173. tkinter.Button(top, bg=bbg, fg=fg, text='删除学习器', command=Del_Leaner, font=FONT, width=width_B,
  174. height=height_B).grid(column=a_x + 2, row=a_y,
  175. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  176. a_y += 1
  177. tkinter.Button(top, bg=bbg, fg=fg, text='训练机器', command=Fit_Learner, font=FONT, width=width_B,
  178. height=height_B).grid(column=a_x, row=a_y,
  179. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  180. tkinter.Button(top, bg=bbg, fg=fg, text='测试机器', command=Score_Learner, font=FONT, width=width_B,
  181. height=height_B).grid(column=a_x + 1, row=a_y,
  182. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  183. tkinter.Button(top, bg=bbg, fg=fg, text='数据预测', command=Predict_Learner, font=FONT, width=width_B,
  184. height=height_B).grid(column=a_x + 2, row=a_y,
  185. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  186. a_y += 1
  187. tkinter.Button(top, bg=bbg, fg=fg, text='单一变量特征选择', command=Add_SelectKBest, font=FONT, width=width_B, height=height_B).grid(column=a_x, row=a_y,columnspan=2,
  188. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  189. tkinter.Button(top, bg=bbg, fg=fg, text='映射标准化', command=Add_Mapzoom, font=FONT, width=width_B,
  190. height=height_B).grid(column=a_x+2, row=a_y,
  191. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  192. a_y += 1
  193. tkinter.Button(top, bg=bbg, fg=fg, text='方差特征选择',command=Add_Variance, font=FONT, width=width_B, height=height_B).grid(
  194. column=a_x, row=a_y,
  195. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  196. tkinter.Button(top, bg=bbg, fg=fg, text='使用学习器筛选', command=Add_SelectFrom_Model, font=FONT, width=width_B,
  197. height=height_B).grid(column=a_x + 1, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  198. tkinter.Button(top, bg=bbg, fg=fg, text='模糊量化标准化', command=Add_Fuzzy_quantization, font=FONT, width=width_B, height=height_B).grid(
  199. column=a_x + 2, row=a_y,
  200. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  201. a_y += 1
  202. tkinter.Button(top, bg=bbg, fg=fg, text='Z-score',command=Add_Z_Score, font=FONT, width=width_B, height=height_B).grid(
  203. column=a_x, row=a_y,
  204. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  205. tkinter.Button(top, bg=bbg, fg=fg, text='离差标准化', command=Add_MinMaxScaler, font=FONT, width=width_B, height=height_B).grid(
  206. column=a_x + 1, row=a_y,
  207. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  208. tkinter.Button(top, bg=bbg, fg=fg, text='Log变换', command=Add_LogScaler, font=FONT, width=width_B,
  209. height=height_B).grid(column=a_x + 2, row=a_y,
  210. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  211. a_y += 1
  212. tkinter.Button(top, bg=bbg, fg=fg, text='atan变换',command=Add_atanScaler, font=FONT, width=width_B, height=height_B).grid(
  213. column=a_x, row=a_y,
  214. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  215. tkinter.Button(top, bg=bbg, fg=fg, text='小数定标准化', command=Add_decimalScaler, font=FONT, width=width_B, height=height_B).grid(
  216. column=a_x + 1, row=a_y,
  217. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  218. tkinter.Button(top, bg=bbg, fg=fg, text='Sigmod变换', command=Add_sigmodScaler, font=FONT, width=width_B,
  219. height=height_B).grid(column=a_x + 2, row=a_y,
  220. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  221. a_y += 1
  222. tkinter.Button(top, bg=bbg, fg=fg, text='正则化',command=Add_Regularization, font=FONT, width=width_B, height=height_B).grid(
  223. column=a_x, row=a_y,
  224. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  225. tkinter.Button(top, bg=bbg, fg=fg, text='二值离散', command=Add_Binarizer, font=FONT, width=width_B, height=height_B).grid(
  226. column=a_x + 1, row=a_y,
  227. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  228. tkinter.Button(top, bg=bbg, fg=fg, text='多值离散', command=Add_Discretization, font=FONT, width=width_B,
  229. height=height_B).grid(column=a_x + 2, row=a_y,
  230. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  231. a_y += 1
  232. tkinter.Button(top, bg=bbg, fg=fg, text='独热编码',command=Add_OneHotEncoder, font=FONT, width=width_B, height=height_B).grid(
  233. column=a_x, row=a_y,
  234. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  235. tkinter.Button(top, bg=bbg, fg=fg, text='数字编码', command=Add_Label, font=FONT, width=width_B, height=height_B).grid(
  236. column=a_x + 1, row=a_y,
  237. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  238. tkinter.Button(top, bg=bbg, fg=fg, text='缺失填充', command=Add_Missed, font=FONT, width=width_B,
  239. height=height_B).grid(column=a_x + 2, row=a_y,
  240. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  241. a_y += 1
  242. tkinter.Button(top, bg=bbg, fg=fg, text='PCA降维',command=Add_PCA, font=FONT, width=width_B, height=height_B).grid(
  243. column=a_x, row=a_y,
  244. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  245. tkinter.Button(top, bg=bbg, fg=fg, text='RPCA降维', command=Add_RPCA, font=FONT, width=width_B, height=height_B).grid(
  246. column=a_x + 1, row=a_y,
  247. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  248. tkinter.Button(top, bg=bbg, fg=fg, text='KPCA升维', command=Add_KPCA, font=FONT, width=width_B,
  249. height=height_B).grid(column=a_x + 2, row=a_y,
  250. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  251. a_y += 1
  252. tkinter.Button(top, bg=bbg, fg=fg, text='LDA降维', command=Add_LDA, font=FONT, width=width_B, height=height_B).grid(
  253. column=a_x, row=a_y,
  254. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  255. tkinter.Button(top, bg=bbg, fg=fg, text='NMF降维', command=Add_NMF, font=FONT, width=width_B, height=height_B).grid(
  256. column=a_x+1, row=a_y,
  257. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  258. tkinter.Button(top, bg=bbg, fg=fg, text='t-SNE', command=Add_TSNE, font=FONT, width=width_B, height=height_B).grid(
  259. column=a_x+2, row=a_y,
  260. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  261. a_y += 1
  262. tkinter.Button(top, bg=bbg, fg=fg, text='线性回归', command=Add_Line, font=FONT, width=width_B, height=height_B).grid(
  263. column=a_x, row=a_y,
  264. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  265. tkinter.Button(top, bg=bbg, fg=fg, text='岭回归', command=Add_Ridge, font=FONT, width=width_B, height=height_B).grid(
  266. column=a_x + 1, row=a_y,
  267. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  268. tkinter.Button(top, bg=bbg, fg=fg, text='Lasso', command=Add_Lasso, font=FONT, width=width_B, height=height_B).grid(
  269. column=a_x + 2, row=a_y,
  270. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  271. a_y += 1
  272. tkinter.Button(top, bg=bbg, fg=fg, text='逻辑回归', command=Add_LogisticRegression, font=FONT, width=width_B,
  273. height=height_B).grid(column=a_x, row=a_y,
  274. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  275. tkinter.Button(top, bg=bbg, fg=fg, text='K邻近预测', command=Add_Knn, font=FONT, width=width_B, height=height_B).grid(
  276. column=a_x + 1, row=a_y,
  277. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  278. tkinter.Button(top, bg=bbg, fg=fg, text='K邻近分类', command=Add_Knn_Class, font=FONT, width=width_B,
  279. height=height_B).grid(column=a_x + 2, row=a_y,
  280. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  281. a_y += 1
  282. tkinter.Button(top, bg=bbg, fg=fg, text='梯度回归树回归', command=Add_GradientTree, font=FONT, width=width_B,
  283. height=height_B).grid(column=a_x, row=a_y,
  284. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  285. tkinter.Button(top, bg=bbg, fg=fg, text='决策树回归',command=Add_Tree, font=FONT, width=width_B, height=height_B).grid(
  286. column=a_x + 1, row=a_y,
  287. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  288. tkinter.Button(top, bg=bbg, fg=fg, text='决策树分类',command=Add_Tree_Class, font=FONT, width=width_B, height=height_B).grid(
  289. column=a_x + 2, row=a_y,
  290. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  291. a_y += 1
  292. tkinter.Button(top, bg=bbg, fg=fg, text='梯度回归树分类', command=Add_GradientTree_class, font=FONT, width=width_B,
  293. height=height_B).grid(column=a_x, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  294. tkinter.Button(top, bg=bbg, fg=fg, text='随机森林回归', command=Add_Forest, font=FONT, width=width_B,
  295. height=height_B).grid(column=a_x+1, row=a_y,
  296. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  297. tkinter.Button(top, bg=bbg, fg=fg, text='随机森林分类',command=Add_Forest_class, font=FONT, width=width_B, height=height_B).grid(
  298. column=a_x + 2, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  299. a_x += 3
  300. tkinter.Label(top, text='', bg=bg, fg=fg, font=FONT, width=1).grid(column=a_x, row=a_y) # 设置说明
  301. a_x += 1
  302. a_y = 0
  303. tkinter.Button(top, bg=bbg, fg=fg, text='多层感知机回归', command=Add_MLP, font=FONT, width=width_B,
  304. height=height_B).grid(column=a_x, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  305. tkinter.Button(top, bg=bbg, fg=fg, text='多层感知机分类', command=Add_MLP_class, font=FONT, width=width_B,
  306. height=height_B).grid(column=a_x+1, row=a_y,
  307. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  308. tkinter.Button(top, bg=bbg, fg=fg, text='随机森林分类',command=Add_Forest_class, font=FONT, width=width_B, height=height_B).grid(
  309. column=a_x + 2, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  310. a_y += 1
  311. tkinter.Button(top, bg=bbg, fg=fg, text='支持向量机分类:SVC', command=Add_SVC, font=FONT, width=width_B, height=height_B).grid(
  312. column=a_x, row=a_y,columnspan=2,
  313. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  314. tkinter.Button(top, bg=bbg, fg=fg, text='回归:SVR', command=Add_SVR, font=FONT, width=width_B, height=height_B).grid(
  315. column=a_x + 2, row=a_y,
  316. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  317. a_y += 1
  318. tkinter.Button(top, bg=bbg, fg=fg, text='k-means', command=Add_KMeans, font=FONT, width=width_B,
  319. height=height_B).grid(column=a_x, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  320. tkinter.Button(top, bg=bbg, fg=fg, text='凝聚聚类', command=Add_Agglomerative, font=FONT, width=width_B,
  321. height=height_B).grid(column=a_x+1, row=a_y,
  322. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  323. tkinter.Button(top, bg=bbg, fg=fg, text='DBSCAN',command=Add_DBSCAN, font=FONT, width=width_B, height=height_B).grid(
  324. column=a_x + 2, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  325. a_y += 1
  326. tkinter.Button(top, bg=bbg, fg=fg, text='特征分类图', command=Add_ClassBar, font=FONT, width=width_B,
  327. height=height_B).grid(column=a_x, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  328. tkinter.Button(top, bg=bbg, fg=fg, text='临近特征回归图', command=Add_FeatureScatter, font=FONT, width=width_B,
  329. height=height_B).grid(column=a_x+1, row=a_y,
  330. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  331. tkinter.Button(top, bg=bbg, fg=fg, text='临近特征分类图',command=Add_FeatureScatterClass, font=FONT, width=width_B, height=height_B).grid(
  332. column=a_x + 2, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  333. a_y += 1
  334. tkinter.Button(top, bg=bbg, fg=fg, text='所有特征回归图', command=Add_FeatureScatter_all, font=FONT, width=width_B,
  335. height=height_B).grid(column=a_x, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  336. tkinter.Button(top, bg=bbg, fg=fg, text='所有特征分类图', command=Add_FeatureScatterClass_all, font=FONT, width=width_B,
  337. height=height_B).grid(column=a_x+1, row=a_y,
  338. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  339. tkinter.Button(top, bg=bbg, fg=fg, text='临近特征预测图',command=Add_Predictive_HeatMap, font=FONT, width=width_B, height=height_B).grid(
  340. column=a_x + 2, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  341. a_y += 1
  342. tkinter.Button(top, bg=bbg, fg=fg, text='所有特征预测图', command=Add_Predictive_HeatMap_More, font=FONT, width=width_B,
  343. height=height_B).grid(column=a_x, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  344. tkinter.Button(top, bg=bbg, fg=fg, text='矩阵热力图', command=Add_Numpy_To_HeatMap, font=FONT, width=width_B,
  345. height=height_B).grid(column=a_x+1, row=a_y,
  346. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  347. tkinter.Button(top, bg=bbg, fg=fg, text='数据y-x散点图',command=Add_FeatureY_X, font=FONT, width=width_B, height=height_B).grid(
  348. column=a_x + 2, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  349. a_y += 1
  350. tkinter.Button(top, bg=bbg, fg=fg, text='聚类树状图', command=Add_ClusterTree, font=FONT, width=width_B,
  351. height=height_B).grid(column=a_x, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  352. tkinter.Button(top, bg=bbg, fg=fg, text='获取数据', command=Add_View_data, font=FONT, width=width_B,
  353. height=height_B).grid(column=a_x+1, row=a_y,
  354. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  355. tkinter.Button(top, bg=bbg, fg=fg, text='矩阵散点图',command=Add_MatrixScatter, font=FONT, width=width_B, height=height_B).grid(
  356. column=a_x + 2, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  357. a_y += 1
  358. tkinter.Button(top, bg=bbg, fg=fg, text='特征相关性', command=Add_corr, font=FONT, width=width_B,
  359. height=height_B).grid(column=a_x, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  360. tkinter.Button(top, bg=bbg, fg=fg, text='曲线拟合', command=Curve_fitting, font=FONT, width=width_B,
  361. height=height_B).grid(column=a_x+1, row=a_y,
  362. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  363. tkinter.Button(top, bg=bbg, fg=fg, text='快速傅里叶',command=Add_Fast_Fourier, font=FONT, width=width_B, height=height_B).grid(
  364. column=a_x + 2, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  365. a_y += 1
  366. tkinter.Button(top, bg=bbg, fg=fg, text='数据统计', command=Add_Des, font=FONT, width=width_B,
  367. height=height_B).grid(column=a_x, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  368. tkinter.Button(top, bg=bbg, fg=fg, text='双逆向傅里叶',command=Add_Reverse_Fast_Fourier2, font=FONT, width=width_B,
  369. height=height_B).grid(column=a_x+1, row=a_y,
  370. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  371. tkinter.Button(top, bg=bbg, fg=fg, text='逆向傅里叶',command=Add_Reverse_Fast_Fourier, font=FONT, width=width_B, height=height_B).grid(
  372. column=a_x + 2, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  373. a_y += 1
  374. tkinter.Button(top, bg=bbg, fg=fg, text='分类模型评估', command=Show_Class_Score, font=FONT, width=width_B,
  375. height=height_B).grid(column=a_x, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  376. tkinter.Button(top, bg=bbg, fg=fg, text='回归模型评估', command=Show_Regression_Score, font=FONT, width=width_B,
  377. height=height_B).grid(column=a_x+1, row=a_y,
  378. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  379. tkinter.Button(top, bg=bbg, fg=fg, text='聚类模型评估', command=Show_Clustering_Score, font=FONT, width=width_B, height=height_B).grid(
  380. column=a_x + 2, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  381. a_y += 1
  382. tkinter.Label(top, text='【学习器配置】', bg=bg, fg=fg, font=FONT, width=width_B * 3, height=height_B).grid(column=a_x,
  383. columnspan=3,
  384. row=a_y,
  385. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N) # 设置说明
  386. global Global_Type
  387. a_y += 1
  388. Global_Type = []
  389. lable = ['聚类仅邻近特征','导出单独页面','导出表格CSV']#复选框
  390. for i in range(3):
  391. Global_Type.append(tkinter.IntVar())
  392. tkinter.Checkbutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg, text=lable[i],
  393. variable=Global_Type[-1],command=globalSeeting).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  394. a_y += 1
  395. lable = ['导出模型','压缩为tar.gz','创建新目录']#复选框
  396. for i in range(3):
  397. Global_Type.append(tkinter.IntVar())
  398. tkinter.Checkbutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg, text=lable[i],
  399. variable=Global_Type[-1],command=globalSeeting).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  400. for i in Global_Type[1:]:i.set(1)
  401. globalSeeting()
  402. global Args_Learner
  403. a_y += 1
  404. Args_Learner = tkinter.Text(top, width=width_B * 3, height=height_B * 6)
  405. Args_Learner.grid(column=a_x, row=a_y, columnspan=3, rowspan=6,
  406. sticky=tkinter.E + tkinter.W + tkinter.N + tkinter.S)
  407. a_y += 6
  408. tkinter.Label(top, text='【矩阵运算】', bg=bg, fg=fg, font=FONT, width=width_B * 3, height=height_B).grid(column=a_x,
  409. columnspan=3,
  410. row=a_y,
  411. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N) # 设置说明
  412. global Cul_Box,CulType_Input,Value_Input
  413. a_y += 1
  414. Cul_Box = tkinter.Listbox(top, width=width_B * 3, height=height_B * 1)
  415. Cul_Box.grid(column=a_x, row=a_y, columnspan=3, rowspan=1, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  416. a_y +=1
  417. tkinter.Label(top, text='运算类型:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
  418. CulType_Input = tkinter.Entry(top, width=width_B * 2)
  419. CulType_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  420. a_y +=1
  421. tkinter.Label(top, text='键入参数:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
  422. Value_Input = tkinter.Entry(top, width=width_B * 2)
  423. Value_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  424. a_y += 1
  425. tkinter.Button(top, bg=bbg, fg=fg, text='选择参数', command=Cul_Add, font=FONT, width=width_B,
  426. height=height_B).grid(column=a_x, row=a_y,
  427. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  428. tkinter.Button(top, bg=bbg, fg=fg, text='键入参数', command=Cul_Input, font=FONT, width=width_B,
  429. height=height_B).grid(column=a_x + 1, row=a_y,
  430. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  431. tkinter.Button(top, bg=bbg, fg=fg, text='矩阵运算', command=Cul_Numpy, font=FONT, width=width_B,
  432. height=height_B).grid(column=a_x + 2, row=a_y,
  433. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
  434. top.mainloop()
  435. def Add_Reverse_Fast_Fourier2(): # 添加Lenear的核心
  436. Add_leaner('[2]Reverse_Fast_Fourier')
  437. def Add_Reverse_Fast_Fourier(): # 添加Lenear的核心
  438. Add_leaner('Reverse_Fast_Fourier')
  439. def Add_Fast_Fourier(): # 添加Lenear的核心
  440. Add_leaner('Fast_Fourier')
  441. def Curve_fitting():
  442. Dic = askopenfilename(title='导入参数')
  443. with open(Dic,'r') as f:
  444. ML.Add_Curve_Fitting(f.read(),Text=get_Args_Learner())
  445. Update_Leaner()
  446. def Show_Clustering_Score():
  447. Show_Score(2)
  448. def Show_Regression_Score():
  449. Show_Score(1)
  450. def Show_Class_Score():
  451. Show_Score(0)
  452. def Show_Score(func):
  453. learner = get_Learner(True)
  454. Dic = askdirectory(title='选择保存位置')
  455. data = ML.Show_Score(learner,Dic,get_Name(False,True),get_Name(False,False),func)
  456. webbrowser.open(data[0])
  457. webbrowser.open(data[1])#还可以打开文件管理器
  458. Update_BOX()
  459. def Cul_Numpy():
  460. global Cul_list, Cul_Type, CulType_Input
  461. func = CulType_Input.get()
  462. if len(Cul_list) == 2 and 1 in Cul_Type:
  463. ML.Cul_Numpy(Cul_list,Cul_Type,func)
  464. Update_BOX()
  465. def Add_Cul(num,type_):
  466. global Cul_list, Cul_Type
  467. if len(Cul_list) == 2:
  468. del Cul_list[0]
  469. del Cul_Type[0]
  470. Cul_list.append(num)
  471. Cul_Type.append(type_)
  472. def Update_Cul():
  473. global Cul_list,Cul_Type,Cul_Box
  474. Cul_Box.delete(0, tkinter.END)
  475. a = ['第一参数','第二参数']
  476. b = ['参数','矩阵']
  477. Cul_Box.insert(tkinter.END, *[f'{a[i]} {Cul_list[i]} {b[Cul_Type[i]]}' for i in range(len(Cul_list))])
  478. def Cul_Input():
  479. global Cul_Box,CulType_Input,Value_Input
  480. num = eval(Value_Input.get(),{})
  481. Add_Cul(num,0)
  482. Update_Cul()
  483. def Cul_Add():
  484. name = get_Name()
  485. Add_Cul(name,1)
  486. Update_Cul()
  487. def Del_Leaner():
  488. Learn = get_Learner(True)
  489. set_Learne = get_Learner(False) # 获取学习器Learner
  490. if set_Learne != Learn:
  491. ML.Del_Leaner(Learn)
  492. Update_Leaner()
  493. def globalSeeting():
  494. global Global_Type
  495. args = [bool(i.get()) for i in Global_Type]
  496. Learn_Numpy.set_Global(*args)
  497. def Reshape():
  498. global ML,Processing_type
  499. shape = eval(f'[{Shape_Input.get()}]')[0]
  500. ML.reShape(get_Name(),shape)
  501. Update_BOX()
  502. def T():
  503. global ML,Processing_type,Shape_Input
  504. try:
  505. Func = eval(f'[{Shape_Input.get()}]')
  506. except:
  507. Func = None
  508. ML.T(get_Name(),Func)
  509. Update_BOX()
  510. def Del_Ndim():
  511. global ML
  512. ML.Del_Ndim(get_Name())
  513. Update_BOX()
  514. def Reval():
  515. global ML,Processing_type
  516. Type = Processing_type.get()
  517. ML.Reval(get_Name(),Type)
  518. Update_BOX()
  519. def Two_Split():
  520. global ML,Processing_type,Shape_Input
  521. Type = Processing_type.get()
  522. ML.Two_Split(get_Name(),Shape_Input.get(),Type)
  523. Update_BOX()
  524. def Split():
  525. global ML,Processing_type,Shape_Input
  526. Type = Processing_type.get()
  527. try:
  528. Split = eval(f'[{Shape_Input.get()}]')[0]
  529. except:
  530. Split = 2
  531. ML.Split(get_Name(),Split,Type)
  532. Update_BOX()
  533. def Merge():
  534. global Merge_list,ML,Processing_type
  535. if len(Merge_list) < 1:
  536. return False
  537. Type = Processing_type.get()
  538. ML.Merge(Merge_list,Type)
  539. Update_BOX()
  540. def Update_Merge():
  541. global Merge_list,Merge_BOX
  542. Merge_BOX.delete(0, tkinter.END)
  543. Merge_BOX.insert(tkinter.END, *Merge_list)
  544. def Merge_Del():
  545. global Merge_list,Merge_BOX
  546. del Merge_list[Merge_BOX.curselection()[0]]
  547. Update_Merge()
  548. def Merge_Add():
  549. global Merge_list
  550. name = get_Name()
  551. Merge_list.append(name)
  552. Update_Merge()
  553. def Show_Args():
  554. learner = get_Learner(True)
  555. Dic = askdirectory(title='选择保存位置')
  556. data = ML.Show_Args(learner,Dic)
  557. webbrowser.open(data[0])
  558. webbrowser.open(data[1])#还可以打开文件管理器
  559. Update_BOX()
  560. def get_Args_Learner():
  561. global Args_Learner
  562. return Args_Learner.get('0.0', tkinter.END)
  563. def Score_Learner():
  564. learner = get_Learner()
  565. socore = ML.Score(get_Name(False,True),get_Name(False,False), learner)
  566. tkinter.messagebox.showinfo('测试完成', f'针对测试数据评分结果为:{socore}')
  567. def Predict_Learner():
  568. learner = get_Learner()
  569. Data = ML.Predict(get_Name(False,True),learner)
  570. title = f'CoTan数据处理 学习器:{learner}'
  571. Creat_TextSheet(Data, title)
  572. Update_BOX()
  573. def Fit_Learner():
  574. learner = get_Learner()
  575. try:
  576. split = float(Split_Input.get())
  577. if split < 0 or 1 < split: raise Exception
  578. except:
  579. split = 0.3
  580. socore = ML.Fit(get_Name(False,True),get_Name(False,False), learner, Text=get_Args_Learner(), split=split)
  581. tkinter.messagebox.showinfo('训练完成', f'针对训练数据({(1 - split) * 100}%)评分结果为:{socore[0]}\n'
  582. f'针对测试数据评分({split * 100}%)结果为:{socore[1]}')
  583. def set_Feature():
  584. global X_OUT
  585. X_OUT.set(get_Name())
  586. def set_Label():
  587. global Y_OUT
  588. Y_OUT.set(get_Name())
  589. def set_Learner():
  590. global ML_OUT
  591. ML_OUT.set(get_Learner(True))
  592. def get_Learner(Type=False):
  593. global Learn_Dic, ML_BOX, ML_OUT
  594. if Type:
  595. try:
  596. return list(Learn_Dic.keys())[ML_BOX.curselection()[0]]
  597. except:
  598. try:
  599. return list(Learn_Dic.keys)[0]
  600. except:
  601. return get_Learner(False)
  602. else:
  603. try:
  604. return ML_OUT.get()
  605. except:
  606. return None
  607. def Add_Des(): # 添加Lenear的核心
  608. Add_leaner('Statistics')
  609. def Add_corr():
  610. Add_leaner('Correlation')
  611. def Add_MatrixScatter():
  612. Add_leaner('MatrixScatter')
  613. def Add_View_data():
  614. ML.Add_View_data(get_Learner(), Text=get_Args_Learner())
  615. Update_Leaner()
  616. def Add_ClusterTree():
  617. Add_leaner('ClusterTree')
  618. def Add_FeatureY_X():
  619. Add_leaner('FeatureY-X')
  620. def Add_Numpy_To_HeatMap():
  621. Add_leaner('HeatMap')
  622. def Add_Predictive_HeatMap_More(): # 添加Lenear的核心
  623. ML.Add_Predictive_HeatMap_More(get_Learner(), Text=get_Args_Learner())
  624. Update_Leaner()
  625. def Add_Predictive_HeatMap(): # 添加Lenear的核心
  626. ML.Add_Predictive_HeatMap(get_Learner(), Text=get_Args_Learner())
  627. Update_Leaner()
  628. def Add_FeatureScatterClass_all():
  629. Add_leaner('FeatureScatterClass_all')
  630. def Add_FeatureScatter_all():
  631. Add_leaner('FeatureScatter_all')
  632. def Add_FeatureScatterClass():
  633. Add_leaner('FeatureScatterClass')
  634. def Add_FeatureScatter():
  635. Add_leaner('FeatureScatter')
  636. def Add_ClassBar():
  637. Add_leaner('ClassBar')
  638. def Add_DBSCAN():
  639. Add_leaner('DBSCAN')
  640. def Add_Agglomerative():
  641. Add_leaner('Agglomerative')
  642. def Add_KMeans():
  643. Add_leaner('k-means')
  644. def Add_MLP_class():
  645. Add_leaner('MLP_class')
  646. def Add_MLP():
  647. Add_leaner('MLP')
  648. def Add_SVR():
  649. Add_leaner('SVR')
  650. def Add_SVC():
  651. Add_leaner('SVC')
  652. def Add_GradientTree():
  653. Add_leaner('GradientTree')
  654. def Add_GradientTree_class():
  655. Add_leaner('GradientTree_class')
  656. def Add_TSNE():
  657. Add_leaner('t-SNE')
  658. def Add_NMF():
  659. Add_leaner('NMF')
  660. def Add_LDA():
  661. Add_leaner('LDA')
  662. def Add_KPCA():
  663. Add_leaner('KPCA')
  664. def Add_RPCA():
  665. Add_leaner('RPCA')
  666. def Add_PCA():
  667. Add_leaner('PCA')
  668. def Add_Missed():
  669. Add_leaner('Missed')
  670. def Add_Label():
  671. Add_leaner('Label')
  672. def Add_OneHotEncoder():
  673. Add_leaner('OneHotEncoder')
  674. def Add_Discretization():
  675. Add_leaner('Discretization')
  676. def Add_Binarizer():
  677. Add_leaner('Binarizer')
  678. def Add_Regularization():
  679. Add_leaner('Regularization')
  680. def Add_Fuzzy_quantization():
  681. Add_leaner('Fuzzy_quantization')
  682. def Add_Mapzoom():
  683. Add_leaner('Mapzoom')
  684. def Add_sigmodScaler():
  685. Add_leaner('sigmodScaler')
  686. def Add_decimalScaler():
  687. Add_leaner('decimalScaler')
  688. def Add_atanScaler():
  689. Add_leaner('atanScaler')
  690. def Add_LogScaler():
  691. Add_leaner('LogScaler')
  692. def Add_MinMaxScaler():
  693. Add_leaner('MinMaxScaler')
  694. def Add_Z_Score():
  695. Add_leaner('Z-Score')
  696. def Add_Forest():
  697. Add_leaner('Forest')
  698. def Add_Forest_class():
  699. Add_leaner('Forest_class')
  700. def Add_Tree_Class():
  701. Add_leaner('Tree_class')
  702. def Add_Tree():
  703. Add_leaner('Tree')
  704. def Add_SelectKBest():
  705. Add_leaner('SelectKBest')
  706. def Add_Knn_Class():
  707. Add_leaner('Knn_class')
  708. def Add_LogisticRegression():
  709. Add_leaner('LogisticRegression')
  710. def Add_Lasso():
  711. Add_leaner('Lasso')
  712. def Add_Variance():
  713. Add_leaner('Variance')
  714. def Add_Knn():
  715. Add_leaner('Knn')
  716. def Add_Ridge():
  717. Add_leaner('Ridge')
  718. def Add_Line():
  719. Add_leaner('Line')
  720. def Add_SelectFrom_Model(): # 添加Lenear的核心
  721. ML.Add_SelectFrom_Model(get_Learner(), Text=get_Args_Learner())
  722. Update_Leaner()
  723. def Add_leaner(Type): # 添加Lenear的核心
  724. ML.Add_Learner(Type, Text=get_Args_Learner())
  725. Update_Leaner()
  726. def Update_Leaner():
  727. global Learn_Dic, ML_BOX
  728. Learn_Dic = ML.Return_Learner()
  729. ML_BOX.delete(0, tkinter.END)
  730. ML_BOX.insert(tkinter.END, *Learn_Dic.keys())
  731. def Show_One():
  732. global PATH, to_HTML_Type
  733. Dic = f'{PATH}/$Show_Sheet.html'
  734. try:
  735. name = get_Name()
  736. if name == None: raise Exception
  737. ML.to_Html_One(name, Dic)
  738. webbrowser.open(Dic)
  739. except:
  740. # pass
  741. raise
  742. def Show():
  743. global PATH, to_HTML_Type
  744. Dic = f'{PATH}/$Show_Sheet.html'
  745. try:
  746. name = get_Name()
  747. if name == None: raise Exception
  748. ML.to_Html(name, Dic, to_HTML_Type.get())
  749. webbrowser.open(Dic)
  750. except:
  751. pass
  752. def to_CSV():
  753. global top, Seq_Input, Code_Input, str_must, Index_must
  754. Dic = asksaveasfilename(title='选择保存的CSV', filetypes=[("CSV", ".csv")])
  755. Seq = Seq_Input.get()
  756. name = get_Name()
  757. ML.to_CSV(Dic, name, Seq)
  758. Update_BOX()
  759. def Add_CSV():
  760. global top, Seq_Input, Code_Input, str_must, name_Input
  761. Dic = askopenfilename(title='选择载入的CSV', filetypes=[("CSV", ".csv")])
  762. if Dic == '': return False
  763. Seq = Seq_Input.get()
  764. Codeing = Code_Input.get()
  765. str_ = bool(str_must.get())
  766. name = name_Input.get().replace(' ', '')
  767. if name == '':
  768. name = os.path.splitext(os.path.split(Dic)[1])[0]
  769. print(name)
  770. if Codeing == '':
  771. with open(Dic, 'rb') as f:
  772. Codeing = chardet.detect(f.read())['encoding']
  773. if Seq == '': Seq = ','
  774. ML.read_csv(Dic, name, Codeing, str_, Seq,)
  775. Update_BOX()
  776. def Add_Python():
  777. global top, Seq_Input, Code_Input, str_must, Index_must
  778. Dic = askopenfilename(title='选择载入的py', filetypes=[("Python", ".py"), ("Txt", ".txt")])
  779. name = name_Input.get().replace(' ', '')
  780. if name == '':
  781. name = os.path.splitext(os.path.split(Dic)[1])[0]
  782. with open(Dic, 'r') as f:
  783. ML.Add_Python(f.read(), name)
  784. Update_BOX()
  785. def get_Name(Type=True, x=True): # 获得名字统一接口
  786. global Form_List, Form_BOX, X_OUT
  787. if Type:
  788. try:
  789. return Form_List[Form_BOX.curselection()[0]]
  790. except:
  791. try:
  792. return Form_List[0]
  793. except:
  794. return None
  795. else:
  796. try:
  797. if x:
  798. return X_OUT.get()
  799. else:
  800. return Y_OUT.get()
  801. except:
  802. return None
  803. def Update_BOX():
  804. global top, Form_BOX, Form_List
  805. Form_List = list(ML.get_Form().keys())
  806. Form_BOX.delete(0, tkinter.END)
  807. Form_BOX.insert(tkinter.END, *Form_List)
  808. def Creat_TextSheet(data, name):
  809. global bg
  810. new_top = tkinter.Toplevel(bg=bg)
  811. new_top.title(name)
  812. new_top.geometry('+10+10') # 设置所在位置
  813. text = ScrolledText(new_top, font=('黑体', 13), height=50)
  814. text.pack(fill=tkinter.BOTH)
  815. text.insert('0.0', data)
  816. text.config(state=tkinter.DISABLED)
  817. new_top.resizable(width=False, height=False)