feature_engineering.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Feature Engineering Assistant - BRAIN</title>
  7. <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
  8. <style>
  9. .feature-engineering-container {
  10. max-width: 1200px;
  11. margin: 0 auto;
  12. padding: 20px;
  13. }
  14. .header-section {
  15. text-align: center;
  16. margin-bottom: 30px;
  17. }
  18. .header-section h1 {
  19. color: #2c3e50;
  20. margin-bottom: 10px;
  21. }
  22. .header-section p {
  23. color: #7f8c8d;
  24. font-size: 16px;
  25. }
  26. .back-button {
  27. position: absolute;
  28. top: 20px;
  29. left: 20px;
  30. background: #3498db;
  31. color: white;
  32. padding: 10px 20px;
  33. border: none;
  34. border-radius: 5px;
  35. text-decoration: none;
  36. display: inline-block;
  37. transition: background-color 0.3s;
  38. }
  39. .back-button:hover {
  40. background: #2980b9;
  41. }
  42. .config-section {
  43. background: #f8f9fa;
  44. padding: 20px;
  45. border-radius: 8px;
  46. margin-bottom: 20px;
  47. }
  48. .config-section h3 {
  49. margin-top: 0;
  50. color: #2c3e50;
  51. }
  52. .form-group {
  53. margin-bottom: 15px;
  54. }
  55. .form-group label {
  56. display: block;
  57. margin-bottom: 5px;
  58. font-weight: bold;
  59. color: #2c3e50;
  60. }
  61. .form-input {
  62. width: 100%;
  63. padding: 10px;
  64. border: 1px solid #ddd;
  65. border-radius: 4px;
  66. font-size: 14px;
  67. }
  68. .form-input:focus {
  69. outline: none;
  70. border-color: #3498db;
  71. box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
  72. }
  73. .btn {
  74. background: #3498db;
  75. color: white;
  76. padding: 10px 20px;
  77. border: none;
  78. border-radius: 4px;
  79. cursor: pointer;
  80. font-size: 14px;
  81. transition: background-color 0.3s;
  82. }
  83. .btn:hover {
  84. background: #2980b9;
  85. }
  86. .btn-success {
  87. background: #27ae60;
  88. }
  89. .btn-success:hover {
  90. background: #229954;
  91. }
  92. .btn-secondary {
  93. background: #95a5a6;
  94. }
  95. .btn-secondary:hover {
  96. background: #7f8c8d;
  97. }
  98. .options-section {
  99. background: white;
  100. border-radius: 8px;
  101. box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  102. margin-bottom: 20px;
  103. }
  104. .options-header {
  105. background: #3498db;
  106. color: white;
  107. padding: 15px 20px;
  108. border-radius: 8px 8px 0 0;
  109. display: flex;
  110. justify-content: space-between;
  111. align-items: center;
  112. }
  113. .options-container {
  114. padding: 20px;
  115. display: grid;
  116. grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  117. gap: 20px;
  118. }
  119. .option-card {
  120. background: #f8f9fa;
  121. border: 2px solid #e9ecef;
  122. border-radius: 8px;
  123. padding: 20px;
  124. transition: all 0.3s ease;
  125. cursor: pointer;
  126. position: relative;
  127. }
  128. .option-card:hover {
  129. border-color: #3498db;
  130. box-shadow: 0 4px 12px rgba(52, 152, 219, 0.15);
  131. }
  132. .option-card.selected {
  133. border-color: #27ae60;
  134. background: #f1f8e9;
  135. }
  136. .option-card.editing {
  137. position: fixed;
  138. top: 50%;
  139. left: 50%;
  140. transform: translate(-50%, -50%);
  141. z-index: 1000;
  142. width: 80%;
  143. max-width: 800px;
  144. max-height: 80vh;
  145. overflow-y: auto;
  146. border-color: #f39c12;
  147. background: #fef9e7;
  148. box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  149. }
  150. .modal-overlay {
  151. position: fixed;
  152. top: 0;
  153. left: 0;
  154. width: 100%;
  155. height: 100%;
  156. background: rgba(0, 0, 0, 0.5);
  157. z-index: 999;
  158. display: none;
  159. }
  160. .modal-overlay.active {
  161. display: block;
  162. }
  163. .option-header {
  164. display: flex;
  165. justify-content: space-between;
  166. align-items: center;
  167. margin-bottom: 15px;
  168. }
  169. .option-number {
  170. background: #3498db;
  171. color: white;
  172. padding: 5px 10px;
  173. border-radius: 20px;
  174. font-size: 12px;
  175. font-weight: bold;
  176. }
  177. .option-actions {
  178. display: flex;
  179. gap: 10px;
  180. }
  181. .option-actions button {
  182. padding: 5px 10px;
  183. font-size: 12px;
  184. border: none;
  185. border-radius: 4px;
  186. cursor: pointer;
  187. }
  188. .edit-btn {
  189. background: #f39c12;
  190. color: white;
  191. }
  192. .save-btn {
  193. background: #27ae60;
  194. color: white;
  195. }
  196. .cancel-btn {
  197. background: #95a5a6;
  198. color: white;
  199. }
  200. .select-btn {
  201. background: #3498db;
  202. color: white;
  203. }
  204. .send-continue-btn {
  205. background: #27ae60;
  206. color: white;
  207. margin-left: 10px;
  208. }
  209. .option-content {
  210. line-height: 1.6;
  211. }
  212. .option-field {
  213. margin-bottom: 10px;
  214. }
  215. .option-field label {
  216. font-weight: bold;
  217. color: #2c3e50;
  218. display: block;
  219. margin-bottom: 5px;
  220. }
  221. .option-field input,
  222. .option-field textarea {
  223. width: 100%;
  224. padding: 8px;
  225. border: 1px solid #ddd;
  226. border-radius: 4px;
  227. font-size: 14px;
  228. }
  229. .option-field textarea {
  230. resize: vertical;
  231. min-height: 80px;
  232. overflow: hidden;
  233. }
  234. .option-card.editing .option-field textarea {
  235. min-height: 120px;
  236. overflow-y: auto;
  237. }
  238. .auto-resize-textarea {
  239. overflow: hidden;
  240. resize: none;
  241. }
  242. .option-field.readonly input,
  243. .option-field.readonly textarea {
  244. background: #f8f9fa;
  245. border-color: #e9ecef;
  246. }
  247. .template-actions {
  248. display: flex;
  249. gap: 10px;
  250. margin-bottom: 20px;
  251. }
  252. .pipeline-status {
  253. background: #fff3cd;
  254. border: 1px solid #ffeaa7;
  255. border-radius: 4px;
  256. padding: 15px;
  257. margin-bottom: 20px;
  258. }
  259. .pipeline-status h4 {
  260. margin-top: 0;
  261. color: #856404;
  262. }
  263. .pipeline-step {
  264. background: #f8f9fa;
  265. border-left: 4px solid #3498db;
  266. padding: 10px 15px;
  267. margin-bottom: 10px;
  268. border-radius: 0 4px 4px 0;
  269. }
  270. .pipeline-step strong {
  271. color: #2c3e50;
  272. }
  273. .notification {
  274. position: fixed;
  275. top: 20px;
  276. right: 20px;
  277. padding: 15px 20px;
  278. border-radius: 4px;
  279. color: white;
  280. font-weight: bold;
  281. z-index: 1000;
  282. animation: slideIn 0.3s ease-out;
  283. }
  284. .notification.success {
  285. background: #27ae60;
  286. }
  287. .notification.error {
  288. background: #e74c3c;
  289. }
  290. @keyframes slideIn {
  291. from {
  292. transform: translateX(100%);
  293. opacity: 0;
  294. }
  295. to {
  296. transform: translateX(0);
  297. opacity: 1;
  298. }
  299. }
  300. .loading-overlay {
  301. position: fixed;
  302. top: 0;
  303. left: 0;
  304. width: 100%;
  305. height: 100%;
  306. background: rgba(0, 0, 0, 0.5);
  307. display: flex;
  308. flex-direction: column;
  309. justify-content: center;
  310. align-items: center;
  311. z-index: 1000;
  312. }
  313. .loading-spinner {
  314. width: 50px;
  315. height: 50px;
  316. border: 5px solid #f3f3f3;
  317. border-top: 5px solid #3498db;
  318. border-radius: 50%;
  319. animation: spin 1s linear infinite;
  320. }
  321. .loading-message {
  322. color: white;
  323. margin-top: 20px;
  324. font-size: 16px;
  325. }
  326. @keyframes spin {
  327. 0% { transform: rotate(0deg); }
  328. 100% { transform: rotate(360deg); }
  329. }
  330. .export-section {
  331. background: #f8f9fa;
  332. padding: 20px;
  333. border-radius: 8px;
  334. margin-top: 20px;
  335. }
  336. .export-section h3 {
  337. margin-top: 0;
  338. color: #2c3e50;
  339. }
  340. .category-list {
  341. display: grid;
  342. grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  343. gap: 10px;
  344. margin-top: 15px;
  345. }
  346. .category-item {
  347. background: #ecf0f1;
  348. padding: 8px 12px;
  349. border-radius: 4px;
  350. font-size: 14px;
  351. border-left: 4px solid #3498db;
  352. }
  353. .quick-actions {
  354. display: flex;
  355. gap: 10px;
  356. margin-bottom: 20px;
  357. }
  358. .quick-actions button {
  359. padding: 8px 16px;
  360. font-size: 14px;
  361. }
  362. .empty-conversation {
  363. text-align: center;
  364. color: #7f8c8d;
  365. padding: 40px;
  366. font-style: italic;
  367. }
  368. /* 操作符参考模态框样式 */
  369. .operator-category {
  370. background: #f8f9fa;
  371. border-radius: 8px;
  372. margin-bottom: 20px;
  373. border: 1px solid #e9ecef;
  374. overflow: hidden;
  375. }
  376. .operator-category.hidden {
  377. display: none;
  378. }
  379. .operator-category-header {
  380. background: #3498db;
  381. color: white;
  382. padding: 15px 20px;
  383. cursor: pointer;
  384. display: flex;
  385. justify-content: space-between;
  386. align-items: center;
  387. transition: background-color 0.3s;
  388. }
  389. .operator-category-header:hover {
  390. background: #2980b9;
  391. }
  392. .operator-category-header h4 {
  393. margin: 0;
  394. font-size: 16px;
  395. }
  396. .operator-category-number {
  397. background: rgba(255, 255, 255, 0.2);
  398. padding: 4px 8px;
  399. border-radius: 12px;
  400. font-size: 12px;
  401. font-weight: bold;
  402. margin-right: 10px;
  403. }
  404. .operator-category-toggle {
  405. font-size: 18px;
  406. transition: transform 0.3s;
  407. }
  408. .operator-category-toggle.expanded {
  409. transform: rotate(180deg);
  410. }
  411. .operator-category-content {
  412. padding: 0;
  413. max-height: 0;
  414. overflow: hidden;
  415. transition: max-height 0.3s ease-out;
  416. }
  417. .operator-category-content.expanded {
  418. max-height: 500px;
  419. padding: 20px;
  420. }
  421. .operator-description {
  422. color: #2c3e50;
  423. margin-bottom: 15px;
  424. font-style: italic;
  425. line-height: 1.5;
  426. }
  427. .operator-list {
  428. background: white;
  429. border-radius: 4px;
  430. padding: 15px;
  431. border: 1px solid #e9ecef;
  432. }
  433. .operator-list h5 {
  434. margin: 0 0 10px 0;
  435. color: #2c3e50;
  436. font-size: 14px;
  437. font-weight: bold;
  438. }
  439. .operators-grid {
  440. display: flex;
  441. flex-wrap: wrap;
  442. gap: 8px;
  443. }
  444. .operator-tag {
  445. background: #ecf0f1;
  446. color: #2c3e50;
  447. padding: 4px 8px;
  448. border-radius: 4px;
  449. font-size: 12px;
  450. font-family: monospace;
  451. border: 1px solid #bdc3c7;
  452. }
  453. .operator-tag.highlight {
  454. background: #fff3cd;
  455. border-color: #ffeaa7;
  456. color: #856404;
  457. }
  458. .no-results {
  459. text-align: center;
  460. color: #7f8c8d;
  461. padding: 40px;
  462. font-style: italic;
  463. }
  464. /* 可点击分类样式 */
  465. .clickable-category {
  466. color: #3498db;
  467. cursor: pointer;
  468. text-decoration: underline;
  469. font-weight: bold;
  470. }
  471. .clickable-category:hover {
  472. color: #2980b9;
  473. background-color: #f8f9fa;
  474. padding: 2px 4px;
  475. border-radius: 3px;
  476. }
  477. /* 分类弹出提示框 */
  478. .category-popup {
  479. position: absolute;
  480. background: white;
  481. border: 2px solid #3498db;
  482. border-radius: 8px;
  483. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  484. z-index: 1000;
  485. max-width: 500px;
  486. min-width: 300px;
  487. padding: 0;
  488. display: none;
  489. }
  490. .category-popup-header {
  491. background: #3498db;
  492. color: white;
  493. padding: 10px 15px;
  494. border-radius: 6px 6px 0 0;
  495. font-weight: bold;
  496. display: flex;
  497. justify-content: space-between;
  498. align-items: center;
  499. }
  500. .category-popup-close {
  501. cursor: pointer;
  502. font-size: 18px;
  503. font-weight: bold;
  504. }
  505. .category-popup-content {
  506. padding: 15px;
  507. }
  508. .category-popup-description {
  509. color: #2c3e50;
  510. margin-bottom: 15px;
  511. font-style: italic;
  512. line-height: 1.4;
  513. }
  514. .category-popup-operators {
  515. background: #f8f9fa;
  516. border-radius: 4px;
  517. padding: 10px;
  518. border: 1px solid #e9ecef;
  519. }
  520. .category-popup-operators h5 {
  521. margin: 0 0 8px 0;
  522. color: #2c3e50;
  523. font-size: 13px;
  524. }
  525. .popup-operators-grid {
  526. display: flex;
  527. flex-wrap: wrap;
  528. gap: 4px;
  529. }
  530. .popup-operator-tag {
  531. background: #ecf0f1;
  532. color: #2c3e50;
  533. padding: 2px 6px;
  534. border-radius: 3px;
  535. font-size: 11px;
  536. font-family: monospace;
  537. border: 1px solid #bdc3c7;
  538. }
  539. .readonly-display {
  540. padding: 10px;
  541. border: 1px solid #ddd;
  542. border-radius: 4px;
  543. background: #f8f9fa;
  544. font-size: 14px;
  545. min-height: 35px;
  546. display: flex;
  547. align-items: center;
  548. }
  549. </style>
  550. </head>
  551. <body>
  552. <div class="feature-engineering-container">
  553. <a href="{{ url_for('index') }}" class="back-button">← 返回主页面</a>
  554. <div class="header-section">
  555. <h1>数据字段指南</h1>
  556. <p>获取AI驱动的多步骤数据字段探索建议</p>
  557. </div>
  558. <!-- API配置部分 -->
  559. <div class="config-section">
  560. <h3>API配置</h3>
  561. <div class="form-group">
  562. <label for="apiKey">Deepseek API密钥:</label>
  563. <input type="password" id="apiKey" class="form-input" placeholder="输入您的Deepseek API密钥">
  564. </div>
  565. <button id="saveApiKey" class="btn">测试并保存API密钥</button>
  566. </div>
  567. <!-- 流水线状态部分 -->
  568. <div class="pipeline-status" id="pipelineStatus" style="display: none;">
  569. <h4>当前流水线状态</h4>
  570. <div id="pipelineSteps">
  571. <!-- 流水线步骤将显示在这里 -->
  572. </div>
  573. </div>
  574. <!-- 初始设置部分 -->
  575. <div class="config-section" id="initialSetup">
  576. <h3>开始新的特征工程流水线</h3>
  577. <div class="template-actions">
  578. <button id="loadQuestionTemplate" class="btn btn-secondary">加载问题模板</button>
  579. <button id="editSystemPrompt" class="btn btn-secondary">编辑系统提示</button>
  580. <button id="startPipeline" class="btn btn-success">获取AI建议</button>
  581. </div>
  582. <div class="form-group">
  583. <label for="questionTemplate">问题模板:</label>
  584. <textarea id="questionTemplate" class="form-input" rows="6" placeholder="点击'加载问题模板'来加载模板"></textarea>
  585. </div>
  586. </div>
  587. <!-- 选项卡片部分 -->
  588. <div class="options-section" id="optionsSection" style="display: none;">
  589. <div class="options-header">
  590. <h3>AI建议</h3>
  591. <div class="quick-actions">
  592. <button id="clearOptions" class="btn btn-secondary">清除并重新开始</button>
  593. <button id="exportPipeline" class="btn">导出流水线</button>
  594. </div>
  595. </div>
  596. <div class="options-container" id="optionsContainer">
  597. <!-- 选项卡片将动态插入到这里 -->
  598. </div>
  599. </div>
  600. <!-- 编辑用模态覆盖层 -->
  601. <div class="modal-overlay" id="modalOverlay"></div>
  602. <!-- 分类弹出框 -->
  603. <div class="category-popup" id="categoryPopup">
  604. <div class="category-popup-header">
  605. <span id="categoryPopupTitle"></span>
  606. <span class="category-popup-close" onclick="hideCategoryPopup()">&times;</span>
  607. </div>
  608. <div class="category-popup-content">
  609. <div class="category-popup-description" id="categoryPopupDescription"></div>
  610. <div class="category-popup-operators">
  611. <h5 id="categoryPopupOperatorsTitle"></h5>
  612. <div class="popup-operators-grid" id="categoryPopupOperators"></div>
  613. </div>
  614. </div>
  615. </div>
  616. <!-- 系统提示编辑模态框 -->
  617. <div class="modal-overlay" id="systemPromptModal" style="display: none;">
  618. <div class="modal-content" style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 80%; max-width: 900px; max-height: 80vh; background: white; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); z-index: 1001;">
  619. <div class="modal-header" style="background: #3498db; color: white; padding: 15px 20px; border-radius: 8px 8px 0 0; display: flex; justify-content: space-between; align-items: center;">
  620. <h3>编辑系统提示</h3>
  621. <span class="close" onclick="closeSystemPromptModal()" style="cursor: pointer; font-size: 24px;">&times;</span>
  622. </div>
  623. <div class="modal-body" style="padding: 20px; max-height: 60vh; overflow-y: auto;">
  624. <div class="form-group">
  625. <label for="systemPromptTextarea">系统提示:</label>
  626. <textarea id="systemPromptTextarea" class="form-input" rows="20" placeholder="在此输入您的自定义系统提示..."></textarea>
  627. </div>
  628. <div class="prompt-actions" style="margin-top: 15px; display: flex; gap: 10px;">
  629. <button id="loadDefaultPrompt" class="btn btn-outline">加载默认提示</button>
  630. </div>
  631. </div>
  632. <div class="modal-footer" style="padding: 15px 20px; border-top: 1px solid #eee; display: flex; justify-content: flex-end; gap: 10px;">
  633. <button onclick="closeSystemPromptModal()" class="btn btn-outline">取消</button>
  634. <button onclick="saveSystemPrompt()" class="btn btn-primary">保存并应用</button>
  635. </div>
  636. </div>
  637. </div>
  638. <!-- 导出部分 -->
  639. <div class="export-section">
  640. <h3>可用的特征工程类别</h3>
  641. <p>AI助手可以从以下15个类别中推荐:</p>
  642. <div class="category-list">
  643. <div class="category-item">基础算术与数学运算</div>
  644. <div class="category-item">逻辑与条件运算</div>
  645. <div class="category-item">时间序列: 变化检测与值比较</div>
  646. <div class="category-item">时间序列: 统计特征工程</div>
  647. <div class="category-item">时间序列: 排名、缩放和归一化</div>
  648. <div class="category-item">时间序列: 衰减、平滑和周转控制</div>
  649. <div class="category-item">时间序列: 极值与位置识别</div>
  650. <div class="category-item">横截面: 排名、缩放和归一化</div>
  651. <div class="category-item">横截面: 回归与中性化</div>
  652. <div class="category-item">横截面: 分布变换与截断</div>
  653. <div class="category-item">变换与过滤操作</div>
  654. <div class="category-item">分组聚合与统计摘要</div>
  655. <div class="category-item">分组排名、缩放和归一化</div>
  656. <div class="category-item">分组回归与中性化</div>
  657. <div class="category-item">分组插值与回填</div>
  658. </div>
  659. </div>
  660. </div>
  661. <script src="{{ url_for('static', filename='feature_engineering.js') }}"></script>
  662. </body>
  663. </html>