You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ExecuteConfig.tsx 14 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. import SubAreaTitle from '@/components/SubAreaTitle';
  2. import {
  3. AutoMLEnsembleClass,
  4. AutoMLResamplingStrategy,
  5. AutoMLTaskType,
  6. autoMLEnsembleClassOptions,
  7. autoMLResamplingStrategyOptions,
  8. autoMLTaskTypeOptions,
  9. } from '@/enums';
  10. import { Col, Form, InputNumber, Radio, Row, Select, Switch } from 'antd';
  11. import { classificationAlgorithms, featureAlgorithms, regressorAlgorithms } from './utils';
  12. // 分类指标
  13. export const classificationMetrics = [
  14. 'accuracy',
  15. 'balanced_accuracy',
  16. 'roc_auc',
  17. 'average_precision',
  18. 'log_loss',
  19. 'precision_macro',
  20. 'precision_micro',
  21. 'precision_samples',
  22. 'precision_weighted',
  23. 'recall_macro',
  24. 'recall_micro',
  25. 'recall_samples',
  26. 'recall_weighted',
  27. 'f1_macro',
  28. 'f1_micro',
  29. 'f1_samples',
  30. 'f1_weighted',
  31. ].map((name) => ({ label: name, value: name }));
  32. // 回归指标
  33. export const regressionMetrics = [
  34. 'mean_absolute_error',
  35. 'mean_squared_error',
  36. 'root_mean_squared_error',
  37. 'mean_squared_log_error',
  38. 'median_absolute_error',
  39. 'r2',
  40. ].map((name) => ({ label: name, value: name }));
  41. function ExecuteConfig() {
  42. const form = Form.useFormInstance();
  43. const task_type = Form.useWatch('task_type', form);
  44. const include_classifier = Form.useWatch('include_classifier', form);
  45. const exclude_classifier = Form.useWatch('exclude_classifier', form);
  46. const include_regressor = Form.useWatch('include_regressor', form);
  47. const exclude_regressor = Form.useWatch('exclude_regressor', form);
  48. const include_feature_preprocessor = Form.useWatch('include_feature_preprocessor', form);
  49. const exclude_feature_preprocessor = Form.useWatch('exclude_feature_preprocessor', form);
  50. return (
  51. <>
  52. <SubAreaTitle
  53. title="执行配置"
  54. image={require('@/assets/img/model-deployment.png')}
  55. style={{ marginTop: '20px', marginBottom: '24px' }}
  56. ></SubAreaTitle>
  57. <Row gutter={8}>
  58. <Col span={10}>
  59. <Form.Item
  60. label="任务类型"
  61. name="task_type"
  62. rules={[{ required: true, message: '请选择任务类型' }]}
  63. >
  64. <Radio.Group
  65. options={autoMLTaskTypeOptions}
  66. onChange={() => form.resetFields(['metrics'])}
  67. ></Radio.Group>
  68. </Form.Item>
  69. </Col>
  70. </Row>
  71. <Row gutter={8}>
  72. <Col span={10}>
  73. <Form.Item
  74. label="特征预处理算法"
  75. name="include_feature_preprocessor"
  76. tooltip="如果不选,则使用所有可能的特征预处理算法。否则,将只使用包含的特征预处理算法"
  77. >
  78. <Select
  79. allowClear
  80. placeholder="请选择特征预处理算法"
  81. options={featureAlgorithms}
  82. disabled={exclude_feature_preprocessor?.length > 0}
  83. mode="multiple"
  84. showSearch
  85. />
  86. </Form.Item>
  87. </Col>
  88. </Row>
  89. <Row gutter={8}>
  90. <Col span={10}>
  91. <Form.Item
  92. label="排除特征预处理算法"
  93. name="exclude_feature_preprocessor"
  94. tooltip="如果不选,则使用所有可能的特征预处理算法。否则,将排除包含的特征预处理算法"
  95. >
  96. <Select
  97. allowClear
  98. placeholder="排除特征预处理算法"
  99. options={featureAlgorithms}
  100. disabled={include_feature_preprocessor?.length > 0}
  101. mode="multiple"
  102. showSearch
  103. />
  104. </Form.Item>
  105. </Col>
  106. </Row>
  107. <Form.Item dependencies={['task_type']} noStyle>
  108. {({ getFieldValue }) => {
  109. return getFieldValue('task_type') === AutoMLTaskType.Classification ? (
  110. <>
  111. <Row gutter={8}>
  112. <Col span={10}>
  113. <Form.Item
  114. label="分类算法"
  115. name="include_classifier"
  116. tooltip="如果不选,则使用所有可能的分类算法。否则,将只使用包含的算法"
  117. >
  118. <Select
  119. allowClear
  120. placeholder="请选择分类算法"
  121. options={classificationAlgorithms}
  122. mode="multiple"
  123. disabled={exclude_classifier?.length > 0}
  124. showSearch
  125. />
  126. </Form.Item>
  127. </Col>
  128. </Row>
  129. <Row gutter={8}>
  130. <Col span={10}>
  131. <Form.Item
  132. label="排除分类算法"
  133. name="exclude_classifier"
  134. tooltip="如果不选,则使用所有可能的分类算法。否则,将排除包含的算法"
  135. >
  136. <Select
  137. allowClear
  138. placeholder="排除分类算法"
  139. options={classificationAlgorithms}
  140. mode="multiple"
  141. disabled={include_classifier?.length > 0}
  142. showSearch
  143. />
  144. </Form.Item>
  145. </Col>
  146. </Row>
  147. </>
  148. ) : (
  149. <>
  150. <Row gutter={8}>
  151. <Col span={10}>
  152. <Form.Item
  153. label="回归算法"
  154. name="include_regressor"
  155. tooltip="如果不选,则使用所有可能的回归算法。否则,将只使用包含的算法"
  156. >
  157. <Select
  158. allowClear
  159. placeholder="请选择回归算法"
  160. options={regressorAlgorithms}
  161. mode="multiple"
  162. disabled={exclude_regressor?.length > 0}
  163. showSearch
  164. />
  165. </Form.Item>
  166. </Col>
  167. </Row>
  168. <Row gutter={8}>
  169. <Col span={10}>
  170. <Form.Item
  171. label="排除的回归算法"
  172. name="exclude_regressor"
  173. tooltip="如果不选,则使用所有可能的回归算法。否则,将排除包含的算法"
  174. >
  175. <Select
  176. allowClear
  177. placeholder="排除回归算法"
  178. options={regressorAlgorithms}
  179. mode="multiple"
  180. disabled={include_regressor?.length > 0}
  181. showSearch
  182. />
  183. </Form.Item>
  184. </Col>
  185. </Row>
  186. </>
  187. );
  188. }}
  189. </Form.Item>
  190. <Row gutter={8}>
  191. <Col span={10}>
  192. <Form.Item
  193. label="集成方式"
  194. name="ensemble_class"
  195. tooltip="仅使用单个最佳模型还是集成模型"
  196. >
  197. <Radio.Group options={autoMLEnsembleClassOptions}></Radio.Group>
  198. </Form.Item>
  199. </Col>
  200. </Row>
  201. <Form.Item dependencies={['ensemble_class']} noStyle>
  202. {({ getFieldValue }) => {
  203. return getFieldValue('ensemble_class') === AutoMLEnsembleClass.Default ? (
  204. <>
  205. <Row gutter={8}>
  206. <Col span={10}>
  207. <Form.Item
  208. label="集成模型数量"
  209. name="ensemble_size"
  210. tooltip="集成模型数量,必须是大于等于1的整数,默认50"
  211. >
  212. <InputNumber placeholder="请输入集成模型数量" min={1} precision={0} />
  213. </Form.Item>
  214. </Col>
  215. </Row>
  216. <Row gutter={8}>
  217. <Col span={10}>
  218. <Form.Item
  219. label="集成最佳模型数量"
  220. name="ensemble_nbest"
  221. tooltip="仅集成最佳的N个模型,必须是大于等于1的整数"
  222. >
  223. <InputNumber placeholder="请输入集成最佳模型数量" min={1} precision={0} />
  224. </Form.Item>
  225. </Col>
  226. </Row>
  227. </>
  228. ) : null;
  229. }}
  230. </Form.Item>
  231. <Row gutter={8}>
  232. <Col span={10}>
  233. <Form.Item
  234. label="最大数量"
  235. name="max_models_on_disc"
  236. tooltip="定义在磁盘中保存的模型的最大数量。额外的模型数量将被永久删除,它设置了一个集成可以使用多少个模型的上限。必须是大于等于1的整数,默认50"
  237. >
  238. <InputNumber placeholder="请输入最大数量" min={1} precision={0} />
  239. </Form.Item>
  240. </Col>
  241. </Row>
  242. <Row gutter={8}>
  243. <Col span={10}>
  244. <Form.Item
  245. label="内存限制(MB)"
  246. name="memory_limit"
  247. tooltip="机器学习算法的内存限制(MB)。如果自动机器学习试图分配超过memory_limit MB,它将停止拟合机器学习算法。默认3072"
  248. >
  249. <InputNumber placeholder="请输入内存限制" min={0} precision={0} />
  250. </Form.Item>
  251. </Col>
  252. </Row>
  253. <Row gutter={8}>
  254. <Col span={10}>
  255. <Form.Item
  256. label="单次时间限制(秒)"
  257. name="per_run_time_limit"
  258. tooltip="单次调用机器学习模型的时间限制(以秒为单位)。如果机器学习算法运行超过时间限制,将终止模型拟合,默认600"
  259. >
  260. <InputNumber placeholder="请输入时间限制" min={0} precision={0} />
  261. </Form.Item>
  262. </Col>
  263. </Row>
  264. <Row gutter={8}>
  265. <Col span={10}>
  266. <Form.Item
  267. label="搜索时间限制(秒)"
  268. name="time_left_for_this_task"
  269. tooltip="搜索合适模型的时间限制(以秒为单位)。通过增加这个值,自动机器学习有更高的机会找到更好的模型。默认3600。"
  270. >
  271. <InputNumber placeholder="请输入搜索时间限制" min={0} precision={0} />
  272. </Form.Item>
  273. </Col>
  274. </Row>
  275. <Row gutter={8}>
  276. <Col span={10}>
  277. <Form.Item
  278. label="测试集比率"
  279. name="test_size"
  280. tooltip="将数据划分为训练数据和测试数据,测试数据集所占比例,0到1之间"
  281. >
  282. <InputNumber placeholder="请输入测试集比率" min={0} max={1} />
  283. </Form.Item>
  284. </Col>
  285. </Row>
  286. <Row gutter={8}>
  287. <Col span={10}>
  288. <Form.Item label="计算指标" name="scoring_functions" tooltip="需要计算并打印的指标">
  289. <Select
  290. allowClear
  291. placeholder="请选择计算指标"
  292. options={
  293. task_type === AutoMLTaskType.Classification
  294. ? classificationMetrics
  295. : regressionMetrics
  296. }
  297. showSearch
  298. />
  299. </Form.Item>
  300. </Col>
  301. </Row>
  302. <Row gutter={8}>
  303. <Col span={10}>
  304. <Form.Item label="随机种子" name="seed" tooltip="随机种子,将决定输出文件名">
  305. <InputNumber placeholder="请输入随机种子" min={0} precision={0} />
  306. </Form.Item>
  307. </Col>
  308. </Row>
  309. <SubAreaTitle
  310. title="重采样策略"
  311. image={require('@/assets/img/resample-icon.png')}
  312. style={{ marginTop: '20px', marginBottom: '24px' }}
  313. ></SubAreaTitle>
  314. <Row gutter={8}>
  315. <Col span={10}>
  316. <Form.Item
  317. label="重采样策略"
  318. name="resampling_strategy"
  319. tooltip="重采样策略,分为holdout和crossValid。holdout指定训练数据划分为训练集和验证集的比例。crossValid为交叉验证。"
  320. >
  321. <Select
  322. allowClear
  323. placeholder="请选择重采样策略"
  324. options={autoMLResamplingStrategyOptions}
  325. showSearch
  326. />
  327. </Form.Item>
  328. </Col>
  329. </Row>
  330. <Form.Item dependencies={['resampling_strategy']} noStyle>
  331. {({ getFieldValue }) => {
  332. return getFieldValue('resampling_strategy') === AutoMLResamplingStrategy.CrossValid ? (
  333. <Row gutter={8}>
  334. <Col span={10}>
  335. <Form.Item
  336. label="交叉验证折数"
  337. name="folds"
  338. tooltip="交叉验证折数必须是大于等于2的整数"
  339. rules={[
  340. {
  341. required: true,
  342. message: '请输入交叉验证折数',
  343. },
  344. ]}
  345. >
  346. <InputNumber placeholder="请输入交叉验证折数" min={2} precision={0} />
  347. </Form.Item>
  348. </Col>
  349. </Row>
  350. ) : null;
  351. }}
  352. </Form.Item>
  353. <Row gutter={8}>
  354. <Col span={10}>
  355. <Form.Item
  356. label="是否打乱"
  357. name="shuffle"
  358. tooltip="拆分数据前是否打乱顺序"
  359. valuePropName="checked"
  360. >
  361. <Switch />
  362. </Form.Item>
  363. </Col>
  364. </Row>
  365. <Row gutter={8}>
  366. <Col span={10}>
  367. <Form.Item
  368. label="训练集比率"
  369. name="train_size"
  370. tooltip="重采样划分训练集和验证集,训练集的比率,0到1之间"
  371. >
  372. <InputNumber placeholder="请输入训练集比率" min={0} max={1} />
  373. </Form.Item>
  374. </Col>
  375. </Row>
  376. </>
  377. );
  378. }
  379. export default ExecuteConfig;