提交 5dd0659f authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 840b9e5a
...@@ -16,7 +16,9 @@ export default function ButtonModal() { ...@@ -16,7 +16,9 @@ export default function ButtonModal() {
const { post, isLoading } = useAI() const { post, isLoading } = useAI()
// AI设置 // AI设置
const handleAISet = () => { const handleAISet = async () => {
await form.validateFields(['independent_variables', 'dependent_variable'])
const values = form.getFieldsValue() const values = form.getFieldsValue()
post( post(
{ {
...@@ -25,13 +27,11 @@ export default function ButtonModal() { ...@@ -25,13 +27,11 @@ export default function ButtonModal() {
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设计一个Apriori算法,返回JSON格式。 content: `根据提供的数据集,设计一个Apriori算法,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 特征列:${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable}
分别返回是否拟合截距项(fit_intercept):true/false、是否复制数据(copy_x):true/false、并行计算核心数(n_jobs):None(单线程)或 ≥1 的整数(如 -1 表示使用所有核心)、强制正系数(positive):true/false的值。
返回格式示例: 返回格式示例:
json json
{ {
"results": { "fit_intercept": true, "copy_x": true, "n_jobs": 1, "positive": false} "results": { "min_support": "最小支持度(min_support)", "min_confidence": "最小置信度(min_confidence)", "min_lift": "最小提升度(min_lift)", "min_length": "规则最小长度(min_length)", "max_length": "规则最大长度(max_length)", "metric": "评估指标(metric)", "min_threshold": "最小阈值(min_threshold)"}
} }
`, `,
}, },
...@@ -55,8 +55,8 @@ json ...@@ -55,8 +55,8 @@ json
const [results, setResults] = useState<any>({}) const [results, setResults] = useState<any>({})
const code = `${results.code?.replace(/\\n/gi, '\n')}` const code = `${results.code?.replace(/\\n/gi, '\n')}`
const [openResults, setOpenResults] = useState(false) const [openResults, setOpenResults] = useState(false)
const handleAICompute = () => { const handleAICompute = async () => {
const values = form.getFieldsValue() const values = await form.validateFields()
post( post(
{ {
response_format: { type: 'json_object' }, response_format: { type: 'json_object' },
...@@ -64,12 +64,14 @@ json ...@@ -64,12 +64,14 @@ json
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设置的Apriori算法进行试算检查,返回JSON格式。 content: `根据提供的数据集,设置的Apriori算法进行试算检查,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 特征列:${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable} 最小支持度(min_support):${values.min_support}
是否拟合截距项(fit_intercept):${values.fit_intercept} 最小置信度(min_confidence):${values.min_confidence}
是否复制数据(copy_X):${values.copy_x} 最小提升度(min_lift):${values.min_lift}
并行计算核心数(n_jobs):${values.n_jobs} 规则最小长度(min_length):${values.min_length}
强制正系数(positive):${values.positive} 规则最大长度(max_length):${values.max_length}
评估指标(metric):${values.metric}
最小阈值(min_threshold):${values.min_threshold}
返回格式示例: 返回格式示例:
json json
{ {
...@@ -98,11 +100,6 @@ json ...@@ -98,11 +100,6 @@ json
const [step, setStep] = useState<number>(-1) const [step, setStep] = useState<number>(-1)
const options = [
{ label: 'True', value: true },
{ label: 'False', value: false },
]
// 处理下一步按钮逻辑 // 处理下一步按钮逻辑
const handleNext = async () => { const handleNext = async () => {
await form.validateFields() await form.validateFields()
...@@ -315,9 +312,9 @@ json ...@@ -315,9 +312,9 @@ json
{current === 0 && ( {current === 0 && (
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={async () => {
await handleAICompute()
setOpenResults(true) setOpenResults(true)
handleAICompute()
}} }}
loading={isLoading}> loading={isLoading}>
AI检查试算 AI检查试算
......
...@@ -16,7 +16,9 @@ export default function ButtonModal() { ...@@ -16,7 +16,9 @@ export default function ButtonModal() {
const { post, isLoading } = useAI() const { post, isLoading } = useAI()
// AI设置 // AI设置
const handleAISet = () => { const handleAISet = async () => {
await form.validateFields(['independent_variables', 'dependent_variable'])
const values = form.getFieldsValue() const values = form.getFieldsValue()
post( post(
{ {
...@@ -25,13 +27,12 @@ export default function ButtonModal() { ...@@ -25,13 +27,12 @@ export default function ButtonModal() {
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设计一个随机森林算法,返回JSON格式。 content: `根据提供的数据集,设计一个随机森林算法,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 特征列:${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable} 目标列${values.dependent_variable}
分别返回是否拟合截距项(fit_intercept):true/false、是否复制数据(copy_x):true/false、并行计算核心数(n_jobs):None(单线程)或 ≥1 的整数(如 -1 表示使用所有核心)、强制正系数(positive):true/false的值。
返回格式示例: 返回格式示例:
json json
{ {
"results": { "fit_intercept": true, "copy_x": true, "n_jobs": 1, "positive": false} "results": { "n_estimators": "树的数量(n_estimators)", "max_depth": "树的最大深度(max_depth)", "min_samples_split": "节点分裂最小样本数(min_samples_split)", "max_features": "最大特征数(max_features)" bootstrap“: "有放回抽样(bootstrap)"}
} }
`, `,
}, },
...@@ -55,8 +56,8 @@ json ...@@ -55,8 +56,8 @@ json
const [results, setResults] = useState<any>({}) const [results, setResults] = useState<any>({})
const code = `${results.code?.replace(/\\n/gi, '\n')}` const code = `${results.code?.replace(/\\n/gi, '\n')}`
const [openResults, setOpenResults] = useState(false) const [openResults, setOpenResults] = useState(false)
const handleAICompute = () => { const handleAICompute = async () => {
const values = form.getFieldsValue() const values = await form.validateFields()
post( post(
{ {
response_format: { type: 'json_object' }, response_format: { type: 'json_object' },
...@@ -64,12 +65,13 @@ json ...@@ -64,12 +65,13 @@ json
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设置的随机森林算法进行试算检查,返回JSON格式。 content: `根据提供的数据集,设置的随机森林算法进行试算检查,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 特征列:${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable} 目标列${values.dependent_variable}
是否拟合截距项(fit_intercept):${values.fit_intercept} 树的数量(n_estimators):${values.n_estimators}
是否复制数据(copy_X):${values.copy_x} 树的最大深度(max_depth):${values.max_depth}
并行计算核心数(n_jobs):${values.n_jobs} 节点分裂最小样本数(min_samples_split):${values.min_samples_split}
强制正系数(positive):${values.positive} 最大特征数(max_features):${values.max_features}
有放回抽样(bootstrap):${values.bootstrap}
返回格式示例: 返回格式示例:
json json
{ {
...@@ -261,9 +263,9 @@ json ...@@ -261,9 +263,9 @@ json
{current === 0 && ( {current === 0 && (
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={async () => {
await handleAICompute()
setOpenResults(true) setOpenResults(true)
handleAICompute()
}} }}
loading={isLoading}> loading={isLoading}>
AI检查试算 AI检查试算
......
...@@ -16,7 +16,9 @@ export default function ButtonModal() { ...@@ -16,7 +16,9 @@ export default function ButtonModal() {
const { post, isLoading } = useAI() const { post, isLoading } = useAI()
// AI设置 // AI设置
const handleAISet = () => { const handleAISet = async () => {
await form.validateFields(['independent_variables', 'dependent_variable'])
const values = form.getFieldsValue() const values = form.getFieldsValue()
post( post(
{ {
...@@ -25,13 +27,11 @@ export default function ButtonModal() { ...@@ -25,13 +27,11 @@ export default function ButtonModal() {
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设计一个FP-Growth算法,返回JSON格式。 content: `根据提供的数据集,设计一个FP-Growth算法,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 特征列${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable}
分别返回是否拟合截距项(fit_intercept):true/false、是否复制数据(copy_x):true/false、并行计算核心数(n_jobs):None(单线程)或 ≥1 的整数(如 -1 表示使用所有核心)、强制正系数(positive):true/false的值。
返回格式示例: 返回格式示例:
json json
{ {
"results": { "fit_intercept": true, "copy_x": true, "n_jobs": 1, "positive": false} "results": { "min_support": "最小支持度(min_support)", "min_confidence": "最小置信度(min_confidence)", "min_lift": "最小提升度(min_lift)", "min_length": "规则最小长度(min_length)"}
} }
`, `,
}, },
...@@ -55,8 +55,8 @@ json ...@@ -55,8 +55,8 @@ json
const [results, setResults] = useState<any>({}) const [results, setResults] = useState<any>({})
const code = `${results.code?.replace(/\\n/gi, '\n')}` const code = `${results.code?.replace(/\\n/gi, '\n')}`
const [openResults, setOpenResults] = useState(false) const [openResults, setOpenResults] = useState(false)
const handleAICompute = () => { const handleAICompute = async () => {
const values = form.getFieldsValue() const values = await form.validateFields()
post( post(
{ {
response_format: { type: 'json_object' }, response_format: { type: 'json_object' },
...@@ -64,12 +64,11 @@ json ...@@ -64,12 +64,11 @@ json
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设置的FP-Growth算法进行试算检查,返回JSON格式。 content: `根据提供的数据集,设置的FP-Growth算法进行试算检查,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 特征列${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable} 最小支持度(min_support${values.min_support}
是否拟合截距项(fit_intercept):${values.fit_intercept} 最小置信度(min_confidence):${values.min_confidence}
是否复制数据(copy_X):${values.copy_x} 最小提升度(min_lift):${values.min_lift}
并行计算核心数(n_jobs):${values.n_jobs} 规则最小长度(min_length):${values.min_length}
强制正系数(positive):${values.positive}
返回格式示例: 返回格式示例:
json json
{ {
...@@ -249,9 +248,9 @@ json ...@@ -249,9 +248,9 @@ json
{current === 0 && ( {current === 0 && (
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={async () => {
await handleAICompute()
setOpenResults(true) setOpenResults(true)
handleAICompute()
}} }}
loading={isLoading}> loading={isLoading}>
AI检查试算 AI检查试算
......
...@@ -16,7 +16,9 @@ export default function ButtonModal() { ...@@ -16,7 +16,9 @@ export default function ButtonModal() {
const { post, isLoading } = useAI() const { post, isLoading } = useAI()
// AI设置 // AI设置
const handleAISet = () => { const handleAISet = async () => {
await form.validateFields(['independent_variables', 'dependent_variable'])
const values = form.getFieldsValue() const values = form.getFieldsValue()
post( post(
{ {
...@@ -25,13 +27,11 @@ export default function ButtonModal() { ...@@ -25,13 +27,11 @@ export default function ButtonModal() {
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设计一个层次聚类算法,返回JSON格式。 content: `根据提供的数据集,设计一个层次聚类算法,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 特征列:${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable}
分别返回是否拟合截距项(fit_intercept):true/false、是否复制数据(copy_x):true/false、并行计算核心数(n_jobs):None(单线程)或 ≥1 的整数(如 -1 表示使用所有核心)、强制正系数(positive):true/false的值。
返回格式示例: 返回格式示例:
json json
{ {
"results": { "fit_intercept": true, "copy_x": true, "n_jobs": 1, "positive": false} "results": { "linkage": "连接方法(linkage)", "affinity": "距离度量(affinity 或 metric)", "n_jobs": "并行计算核心数(n_jobs)", "compute_full_tree": "计算完整树形(compute_full_tree)", "distance_threshold": "距离阈值(distance_threshold)"}
} }
`, `,
}, },
...@@ -55,8 +55,8 @@ json ...@@ -55,8 +55,8 @@ json
const [results, setResults] = useState<any>({}) const [results, setResults] = useState<any>({})
const code = `${results.code?.replace(/\\n/gi, '\n')}` const code = `${results.code?.replace(/\\n/gi, '\n')}`
const [openResults, setOpenResults] = useState(false) const [openResults, setOpenResults] = useState(false)
const handleAICompute = () => { const handleAICompute = async () => {
const values = form.getFieldsValue() const values = await form.validateFields()
post( post(
{ {
response_format: { type: 'json_object' }, response_format: { type: 'json_object' },
...@@ -64,12 +64,12 @@ json ...@@ -64,12 +64,12 @@ json
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设置的层次聚类算法进行试算检查,返回JSON格式。 content: `根据提供的数据集,设置的层次聚类算法进行试算检查,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 特征列:${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable} 连接方法(linkage):${values.linkage}
是否拟合截距项(fit_intercept):${values.fit_intercept} 距离度量(affinity metric):${values.affinity}
是否复制数据(copy_X):${values.copy_x}
并行计算核心数(n_jobs):${values.n_jobs} 并行计算核心数(n_jobs):${values.n_jobs}
强制正系数(positive):${values.positive} 计算完整树形(compute_full_tree):${values.compute_full_tree}
距离阈值(distance_threshold):${values.distance_threshold}
返回格式示例: 返回格式示例:
json json
{ {
...@@ -277,9 +277,9 @@ json ...@@ -277,9 +277,9 @@ json
{current === 0 && ( {current === 0 && (
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={async () => {
await handleAICompute()
setOpenResults(true) setOpenResults(true)
handleAICompute()
}} }}
loading={isLoading}> loading={isLoading}>
AI检查试算 AI检查试算
......
...@@ -16,7 +16,9 @@ export default function ButtonModal() { ...@@ -16,7 +16,9 @@ export default function ButtonModal() {
const { post, isLoading } = useAI() const { post, isLoading } = useAI()
// AI设置 // AI设置
const handleAISet = () => { const handleAISet = async () => {
await form.validateFields(['independent_variables', 'dependent_variable'])
const values = form.getFieldsValue() const values = form.getFieldsValue()
post( post(
{ {
...@@ -25,13 +27,12 @@ export default function ButtonModal() { ...@@ -25,13 +27,12 @@ export default function ButtonModal() {
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设计一个Holt-Winters算法,返回JSON格式。 content: `根据提供的数据集,设计一个Holt-Winters算法,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 时间列:${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable} 目标列:${values.dependent_variable}
分别返回是否拟合截距项(fit_intercept):true/false、是否复制数据(copy_x):true/false、并行计算核心数(n_jobs):None(单线程)或 ≥1 的整数(如 -1 表示使用所有核心)、强制正系数(positive):true/false的值。
返回格式示例: 返回格式示例:
json json
{ {
"results": { "fit_intercept": true, "copy_x": true, "n_jobs": 1, "positive": false} "results": { "step": "预测步长", "a": "α(水平平滑)", "b": "β(趋势平滑", "y": "γ(季节平滑)"}
} }
`, `,
}, },
...@@ -55,8 +56,8 @@ json ...@@ -55,8 +56,8 @@ json
const [results, setResults] = useState<any>({}) const [results, setResults] = useState<any>({})
const code = `${results.code?.replace(/\\n/gi, '\n')}` const code = `${results.code?.replace(/\\n/gi, '\n')}`
const [openResults, setOpenResults] = useState(false) const [openResults, setOpenResults] = useState(false)
const handleAICompute = () => { const handleAICompute = async () => {
const values = form.getFieldsValue() const values = await form.validateFields()
post( post(
{ {
response_format: { type: 'json_object' }, response_format: { type: 'json_object' },
...@@ -64,12 +65,12 @@ json ...@@ -64,12 +65,12 @@ json
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设置的Holt-Winters算法进行试算检查,返回JSON格式。 content: `根据提供的数据集,设置的Holt-Winters算法进行试算检查,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 时间列:${values.independent_variables?.join(', ')}
因变量${values.dependent_variable} 目标列${values.dependent_variable}
是否拟合截距项(fit_intercept):${values.fit_intercept} 预测步长:${values.step}
是否复制数据(copy_X):${values.copy_x} α(水平平滑):${values.a}
并行计算核心数(n_jobs):${values.n_jobs} β(趋势平滑):${values.b}
强制正系数(positive):${values.positive} γ(季节平滑):${values.y}
返回格式示例: 返回格式示例:
json json
{ {
...@@ -228,9 +229,9 @@ json ...@@ -228,9 +229,9 @@ json
{current === 0 && ( {current === 0 && (
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={async () => {
await handleAICompute()
setOpenResults(true) setOpenResults(true)
handleAICompute()
}} }}
loading={isLoading}> loading={isLoading}>
AI检查试算 AI检查试算
......
...@@ -16,7 +16,9 @@ export default function ButtonModal() { ...@@ -16,7 +16,9 @@ export default function ButtonModal() {
const { post, isLoading } = useAI() const { post, isLoading } = useAI()
// AI设置 // AI设置
const handleAISet = () => { const handleAISet = async () => {
await form.validateFields(['independent_variables'])
const values = form.getFieldsValue() const values = form.getFieldsValue()
post( post(
{ {
...@@ -25,13 +27,11 @@ export default function ButtonModal() { ...@@ -25,13 +27,11 @@ export default function ButtonModal() {
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设计一个K-Means算法,返回JSON格式。 content: `根据提供的数据集,设计一个K-Means算法,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 特征列:${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable}
分别返回是否拟合截距项(fit_intercept):true/false、是否复制数据(copy_x):true/false、并行计算核心数(n_jobs):None(单线程)或 ≥1 的整数(如 -1 表示使用所有核心)、强制正系数(positive):true/false的值。
返回格式示例: 返回格式示例:
json json
{ {
"results": { "fit_intercept": true, "copy_x": true, "n_jobs": 1, "positive": false} "results": { "n_clusters": "簇数量(n_clusters)", "init": "初始化方法(init)", "n_init": "初始化次数(n_init)", "max_iter": "最大迭代次数(max_iter)", "tol": "收敛阈值(tol)", "random_state": "随机种子(random_state)", "algorithm": "算法实现(algorithm)" }
} }
`, `,
}, },
...@@ -55,8 +55,8 @@ json ...@@ -55,8 +55,8 @@ json
const [results, setResults] = useState<any>({}) const [results, setResults] = useState<any>({})
const code = `${results.code?.replace(/\\n/gi, '\n')}` const code = `${results.code?.replace(/\\n/gi, '\n')}`
const [openResults, setOpenResults] = useState(false) const [openResults, setOpenResults] = useState(false)
const handleAICompute = () => { const handleAICompute = async () => {
const values = form.getFieldsValue() const values = await form.validateFields()
post( post(
{ {
response_format: { type: 'json_object' }, response_format: { type: 'json_object' },
...@@ -64,12 +64,14 @@ json ...@@ -64,12 +64,14 @@ json
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设置的K-Means算法进行试算检查,返回JSON格式。 content: `根据提供的数据集,设置的K-Means算法进行试算检查,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 特征列${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable} 簇数量(n_clusters):${values.n_clusters}
是否拟合截距项(fit_intercept):${values.fit_intercept} 初始化方法(init):${values.init}
是否复制数据(copy_X):${values.copy_x} 初始化次数(n_init):${values.n_init}
并行计算核心数(n_jobs):${values.n_jobs} 最大迭代次数(max_iter):${values.max_iter}
强制正系数(positive):${values.positive} 收敛阈值(tol):${values.tol}
随机种子(random_state):${values.random_state}
算法实现(algorithm${values.algorithm}
返回格式示例: 返回格式示例:
json json
{ {
...@@ -98,11 +100,6 @@ json ...@@ -98,11 +100,6 @@ json
const [step, setStep] = useState<number>(-1) const [step, setStep] = useState<number>(-1)
const options = [
{ label: 'True', value: true },
{ label: 'False', value: false },
]
// 处理下一步按钮逻辑 // 处理下一步按钮逻辑
const handleNext = async () => { const handleNext = async () => {
await form.validateFields() await form.validateFields()
...@@ -136,7 +133,7 @@ json ...@@ -136,7 +133,7 @@ json
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<Form.Item label="请输入簇数量(n_clusters)"> <Form.Item label="请输入簇数量(n_clusters)">
<Flex gap={10}> <Flex gap={10}>
<Form.Item name="fit_intercept" noStyle rules={[{ required: true, message: '请选择' }]}> <Form.Item name="n_clusters" noStyle rules={[{ required: true, message: '请选择' }]}>
<Input placeholder="请输入" /> <Input placeholder="请输入" />
</Form.Item> </Form.Item>
<Popover <Popover
...@@ -298,9 +295,9 @@ json ...@@ -298,9 +295,9 @@ json
{current === 0 && ( {current === 0 && (
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={async () => {
await handleAICompute()
setOpenResults(true) setOpenResults(true)
handleAICompute()
}} }}
loading={isLoading}> loading={isLoading}>
AI检查试算 AI检查试算
......
...@@ -16,7 +16,8 @@ export default function ButtonModal() { ...@@ -16,7 +16,8 @@ export default function ButtonModal() {
const { post, isLoading } = useAI() const { post, isLoading } = useAI()
// AI设置 // AI设置
const handleAISet = () => { const handleAISet = async () => {
await form.validateFields(['independent_variables', 'dependent_variable'])
const values = form.getFieldsValue() const values = form.getFieldsValue()
post( post(
{ {
...@@ -25,7 +26,7 @@ export default function ButtonModal() { ...@@ -25,7 +26,7 @@ export default function ButtonModal() {
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设计一个线性回归算法,返回JSON格式。 content: `根据提供的数据集,设计一个线性回归算法,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 自变量:${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable} 因变量:${values.dependent_variable}
分别返回是否拟合截距项(fit_intercept:true/false、是否复制数据(copy_x:true/false、并行计算核心数(n_jobs:None(单线程)或 1 的整数(如 -1 表示使用所有核心)、强制正系数(positive:true/false的值。 分别返回是否拟合截距项(fit_intercept:true/false、是否复制数据(copy_x:true/false、并行计算核心数(n_jobs:None(单线程)或 1 的整数(如 -1 表示使用所有核心)、强制正系数(positive:true/false的值。
返回格式示例: 返回格式示例:
...@@ -55,8 +56,9 @@ json ...@@ -55,8 +56,9 @@ json
const [results, setResults] = useState<any>({}) const [results, setResults] = useState<any>({})
const code = `${results.code?.replace(/\\n/gi, '\n')}` const code = `${results.code?.replace(/\\n/gi, '\n')}`
const [openResults, setOpenResults] = useState(false) const [openResults, setOpenResults] = useState(false)
const handleAICompute = () => {
const values = form.getFieldsValue() const handleAICompute = async () => {
const values = await form.validateFields()
post( post(
{ {
response_format: { type: 'json_object' }, response_format: { type: 'json_object' },
...@@ -64,7 +66,7 @@ json ...@@ -64,7 +66,7 @@ json
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设置的线性回归算法进行试算检查,返回JSON格式。 content: `根据提供的数据集,设置的线性回归算法进行试算检查,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 自变量:${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable} 因变量:${values.dependent_variable}
是否拟合截距项(fit_intercept):${values.fit_intercept} 是否拟合截距项(fit_intercept):${values.fit_intercept}
是否复制数据(copy_X):${values.copy_x} 是否复制数据(copy_X):${values.copy_x}
...@@ -257,9 +259,9 @@ json ...@@ -257,9 +259,9 @@ json
{current === 0 && ( {current === 0 && (
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={async () => {
await handleAICompute()
setOpenResults(true) setOpenResults(true)
handleAICompute()
}} }}
loading={isLoading}> loading={isLoading}>
AI检查试算 AI检查试算
......
...@@ -16,7 +16,9 @@ export default function ButtonModal() { ...@@ -16,7 +16,9 @@ export default function ButtonModal() {
const { post, isLoading } = useAI() const { post, isLoading } = useAI()
// AI设置 // AI设置
const handleAISet = () => { const handleAISet = async () => {
await form.validateFields(['independent_variables', 'dependent_variable'])
const values = form.getFieldsValue() const values = form.getFieldsValue()
post( post(
{ {
...@@ -25,13 +27,12 @@ export default function ButtonModal() { ...@@ -25,13 +27,12 @@ export default function ButtonModal() {
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设计一个逻辑回归算法,返回JSON格式。 content: `根据提供的数据集,设计一个逻辑回归算法,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 自变量:${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable} 因变量:${values.dependent_variable}
分别返回是否拟合截距项(fit_intercept):true/false、是否复制数据(copy_x):true/false、并行计算核心数(n_jobs):None(单线程)或 ≥1 的整数(如 -1 表示使用所有核心)、强制正系数(positive):true/false的值。
返回格式示例: 返回格式示例:
json json
{ {
"results": { "fit_intercept": true, "copy_x": true, "n_jobs": 1, "positive": false} "results": { "c": "正则化强度(C)", "penalty": "正则化类型(penalty)", "solver": "优化算法(solver)", "max_iter": "最大迭代次数(max_iter)", "tol": "收敛阈值(tol)", "multi_class": "ovr或者multinomial"}
} }
`, `,
}, },
...@@ -55,8 +56,8 @@ json ...@@ -55,8 +56,8 @@ json
const [results, setResults] = useState<any>({}) const [results, setResults] = useState<any>({})
const code = `${results.code?.replace(/\\n/gi, '\n')}` const code = `${results.code?.replace(/\\n/gi, '\n')}`
const [openResults, setOpenResults] = useState(false) const [openResults, setOpenResults] = useState(false)
const handleAICompute = () => { const handleAICompute = async () => {
const values = form.getFieldsValue() const values = await form.validateFields()
post( post(
{ {
response_format: { type: 'json_object' }, response_format: { type: 'json_object' },
...@@ -64,12 +65,14 @@ json ...@@ -64,12 +65,14 @@ json
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设置的逻辑回归算法进行试算检查,返回JSON格式。 content: `根据提供的数据集,设置的逻辑回归算法进行试算检查,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 自变量:${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable} 因变量:${values.dependent_variable}
是否拟合截距项(fit_intercept):${values.fit_intercept} 正则化强度(C):${values.c}
是否复制数据(copy_X):${values.copy_x} 正则化类型(penalty):${values.penalty}
并行计算核心数(n_jobs):${values.n_jobs} 优化算法(solver):${values.solver}
强制正系数(positive):${values.positive} 最大迭代次数(max_iter):${values.max_iter}
收敛阈值(tol):${values.tol}
多分类策略(multi_class):${values.multi_class}
返回格式示例: 返回格式示例:
json json
{ {
...@@ -98,11 +101,6 @@ json ...@@ -98,11 +101,6 @@ json
const [step, setStep] = useState<number>(-1) const [step, setStep] = useState<number>(-1)
const options = [
{ label: 'True', value: true },
{ label: 'False', value: false },
]
// 处理下一步按钮逻辑 // 处理下一步按钮逻辑
const handleNext = async () => { const handleNext = async () => {
await form.validateFields() await form.validateFields()
...@@ -311,9 +309,9 @@ json ...@@ -311,9 +309,9 @@ json
{current === 0 && ( {current === 0 && (
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={async () => {
await handleAICompute()
setOpenResults(true) setOpenResults(true)
handleAICompute()
}} }}
loading={isLoading}> loading={isLoading}>
AI检查试算 AI检查试算
......
...@@ -16,7 +16,9 @@ export default function ButtonModal() { ...@@ -16,7 +16,9 @@ export default function ButtonModal() {
const { post, isLoading } = useAI() const { post, isLoading } = useAI()
// AI设置 // AI设置
const handleAISet = () => { const handleAISet = async () => {
await form.validateFields(['independent_variables', 'dependent_variable'])
const values = form.getFieldsValue() const values = form.getFieldsValue()
post( post(
{ {
...@@ -25,13 +27,12 @@ export default function ButtonModal() { ...@@ -25,13 +27,12 @@ export default function ButtonModal() {
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设计一个支持向量机算法,返回JSON格式。 content: `根据提供的数据集,设计一个支持向量机算法,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 特征列:${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable} 目标列:${values.dependent_variable}
分别返回是否拟合截距项(fit_intercept):true/false、是否复制数据(copy_x):true/false、并行计算核心数(n_jobs):None(单线程)或 ≥1 的整数(如 -1 表示使用所有核心)、强制正系数(positive):true/false的值。
返回格式示例: 返回格式示例:
json json
{ {
"results": { "fit_intercept": true, "copy_x": true, "n_jobs": 1, "positive": false} "results": { "c": "正则化参数(C)", "kernel": "核函数类型(kernel)", "gamma": "核函数系数(gamma)", "degree": "多项式核次数(degree)", "class_weight": "类别权重(class_weight)"}
} }
`, `,
}, },
...@@ -55,8 +56,8 @@ json ...@@ -55,8 +56,8 @@ json
const [results, setResults] = useState<any>({}) const [results, setResults] = useState<any>({})
const code = `${results.code?.replace(/\\n/gi, '\n')}` const code = `${results.code?.replace(/\\n/gi, '\n')}`
const [openResults, setOpenResults] = useState(false) const [openResults, setOpenResults] = useState(false)
const handleAICompute = () => { const handleAICompute = async () => {
const values = form.getFieldsValue() const values = await form.validateFields()
post( post(
{ {
response_format: { type: 'json_object' }, response_format: { type: 'json_object' },
...@@ -64,12 +65,13 @@ json ...@@ -64,12 +65,13 @@ json
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设置的支持向量机算法进行试算检查,返回JSON格式。 content: `根据提供的数据集,设置的支持向量机算法进行试算检查,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 特征列:${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable} 目标列:${values.dependent_variable}
是否拟合截距项(fit_intercept):${values.fit_intercept} 正则化参数(C):${values.c}
是否复制数据(copy_X):${values.copy_x} 核函数类型(kernel):${values.kernel}
并行计算核心数(n_jobs):${values.n_jobs} 核函数系数(gamma):${values.gamma}
强制正系数(positive):${values.positive} 多项式核次数(degree):${values.degree}
类别权重(class_weight):${values.class_weight}
返回格式示例: 返回格式示例:
json json
{ {
...@@ -266,9 +268,9 @@ json ...@@ -266,9 +268,9 @@ json
{current === 0 && ( {current === 0 && (
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={async () => {
await handleAICompute()
setOpenResults(true) setOpenResults(true)
handleAICompute()
}} }}
loading={isLoading}> loading={isLoading}>
AI检查试算 AI检查试算
......
...@@ -16,7 +16,9 @@ export default function ButtonModal() { ...@@ -16,7 +16,9 @@ export default function ButtonModal() {
const { post, isLoading } = useAI() const { post, isLoading } = useAI()
// AI设置 // AI设置
const handleAISet = () => { const handleAISet = async () => {
await form.validateFields(['independent_variables', 'dependent_variable'])
const values = form.getFieldsValue() const values = form.getFieldsValue()
post( post(
{ {
...@@ -25,13 +27,12 @@ export default function ButtonModal() { ...@@ -25,13 +27,12 @@ export default function ButtonModal() {
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设计一个决策树(二分类)算法,返回JSON格式。 content: `根据提供的数据集,设计一个决策树(二分类)算法,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 特征列${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable} 目标列:${values.dependent_variable}
分别返回是否拟合截距项(fit_intercept):true/false、是否复制数据(copy_x):true/false、并行计算核心数(n_jobs):None(单线程)或 ≥1 的整数(如 -1 表示使用所有核心)、强制正系数(positive):true/false的值。
返回格式示例: 返回格式示例:
json json
{ {
"results": { "fit_intercept": true, "copy_x": true, "n_jobs": 1, "positive": false} "results": { "max_depth": "树的最大深度(max_depth)", "min_samples_split": "节点分裂最小样本数(min_samples_split)", "min_samples_leaf": "叶节点最小样本数(min_samples_leaf)", "criterion": "分裂标准(criterion)", "max_features": "最大特征数(max_features)"}
} }
`, `,
}, },
...@@ -55,8 +56,8 @@ json ...@@ -55,8 +56,8 @@ json
const [results, setResults] = useState<any>({}) const [results, setResults] = useState<any>({})
const code = `${results.code?.replace(/\\n/gi, '\n')}` const code = `${results.code?.replace(/\\n/gi, '\n')}`
const [openResults, setOpenResults] = useState(false) const [openResults, setOpenResults] = useState(false)
const handleAICompute = () => { const handleAICompute = async () => {
const values = form.getFieldsValue() const values = await form.validateFields()
post( post(
{ {
response_format: { type: 'json_object' }, response_format: { type: 'json_object' },
...@@ -64,12 +65,13 @@ json ...@@ -64,12 +65,13 @@ json
{ {
role: 'user', role: 'user',
content: `根据提供的数据集,设置的决策树(二分类)算法进行试算检查,返回JSON格式。 content: `根据提供的数据集,设置的决策树(二分类)算法进行试算检查,返回JSON格式。
自变量:${values.independent_variables.join(', ')} 特征列${values.independent_variables?.join(', ')}
因变量:${values.dependent_variable} 目标列:${values.dependent_variable}
是否拟合截距项(fit_intercept):${values.fit_intercept} 树的最大深度(max_depth):${values.max_depth}
是否复制数据(copy_X):${values.copy_x} 节点分裂最小样本数(min_samples_split):${values.min_samples_split}
并行计算核心数(n_jobs):${values.n_jobs} 叶节点最小样本数(min_samples_leaf):${values.min_samples_leaf}
强制正系数(positive):${values.positive} 分裂标准(criterion):${values.criterion}
最大特征数(max_features):${values.max_features}
返回格式示例: 返回格式示例:
json json
{ {
...@@ -259,9 +261,9 @@ json ...@@ -259,9 +261,9 @@ json
{current === 0 && ( {current === 0 && (
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={async () => {
await handleAICompute()
setOpenResults(true) setOpenResults(true)
handleAICompute()
}} }}
loading={isLoading}> loading={isLoading}>
AI检查试算 AI检查试算
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论