#P3492.第1题-基于决策树预判资源调配优先级

第1题-基于决策树预判资源调配优先级 - problem_ide - CodeFun2000

主要是把题看懂

python 复制代码
class Node:
    def __init__(self,feature_index,threshold,left,right,label):
        self.feature_index = feature_index
        self.threshold = threshold
        self.left = left
        self.right =right
        self.label =label


f,m,n = map(int,input().split())

tree = []

for _ in range(m):
    fi,thr,l,r,lbl = input().split()

    tree.append(Node(int(fi),float(thr),int(l),int(r),int(lbl)))

for _ in range(n):
    features = list(map(float,input().split()))

    current = 0

    while True:
        node = tree[current]
        if node.feature_index == -1:
            print(node.label)
            break
        
        if features[node.feature_index] <= node.threshold:
            current = node.left
        else:
            current = node.right
    
相关推荐
y1su2 小时前
Leetcode 字符串模板
java·数据结构·算法·leetcode·职场和发展·动态规划
residual_fan2 小时前
船用柴油机动态机动工况故障诊断:控制感知仿射网络(CAAN)的技术实现
人工智能·算法·数据挖掘·数据分析
爱上纯净的蓝天2 小时前
不用云做 RAG:一个本地笔记问答工具的取舍与坑
python·开源·大模型·rag·本地部署
其实防守也摸鱼3 小时前
Cylab在线靶场——CTF中的通用技能
linux·数据库·学习·算法·靶场·ctf·学习网络安全
cspttty3 小时前
2027风险管理岗准备路线:数学与应用数学如何补齐金融、SQL与Python
开发语言·python·金融
用户8356290780513 小时前
如何使用 Python 格式化 Excel 单元格中的长文本
后端·python
我命由我123453 小时前
Python 开发 - Python 的 pathlib
java·开发语言·后端·python·学习·java-ee·学习方法
蓝悦无人机3 小时前
《Planning algorithms》读书笔记——第8章 反馈运动规划
算法·读书笔记·反馈运动规划
RaaS1003 小时前
Agent Skills 进了 Linux Foundation:2.8 亿次安装,但装 skill 还没有安全规范
人工智能·算法·架构
严谨的麻辣烫3 小时前
Python HTTP 连接池怎么用?从连接复用到请求异常排查
开发语言·python·http·requests·网络排查