#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
    
相关推荐
happylifetree4 小时前
Python09:核心语法-数据存储与运算-字面量
python
longlongzihan4 小时前
LeetCode 17电话号码的字母组合:回溯算法(DFS)详解
c++·算法·leetcode·深度优先
心之语歌5 小时前
Tkinter 画布基本梳理
运维·服务器·python
封印师请假去地球钓鱼5 小时前
边解边变的问题:从“决策依赖“一词出发
人工智能·算法
Wx-bishekaifayuan5 小时前
django个性化旅游路线推荐平台49005-计算机课程设计、毕业设计
spring boot·后端·python·django·课程设计·express·旅游
今晚打老虎5 小时前
c++之提高A(前缀和)(第三课)
数据结构·c++·算法
小白快快跑哦6 小时前
python-字符串全解(六):正则表达式-量词
python·正则表达式·字符串
禹凕6 小时前
机器学习之Selenium(Machina Learning about Selenium)
爬虫·python·selenium·测试工具·机器学习
不会就选b6 小时前
算法日常・每日刷题--<贪心>26
数据结构·算法
ebiobiz8 小时前
基于 GD32 Embedded Builder (GEB) 与 Nimmake 的 MCU 工程搭建指南
c++·python·单片机·嵌入式硬件·mcu