基于宠物活动接触时长的人畜共患病潜在接触风险分析(教学级原型)
一、实际应用场景描述
在智能健康管理课程中,人畜共患病(Zoonoses)是重要的交叉学科议题。
本程序适用于:
- 家庭、宠物医院、动物实验室等场景
- 记录:
- 人与宠物的接触类型
- 每日接触时长
- 防护措施使用情况
- 基于公共卫生常识规则,评估:
- 潜在接触风险等级
- 基础防护建议
✅ 不替代兽医或医生
✅ 不做绝对风险评估
✅ 仅作为健康数据意识工具
二、痛点引入(真实可共鸣)
痛点 表现
接触无记录 不清楚接触频率与时长
风险不可见 “养宠物很安全”缺乏依据
防护不规范 洗手、口罩、手套常被忽略
认知偏差 儿童 / 老人风险被低估
管理粗放 无家庭级数据积累
👉 需要一个轻量、本地、可解释的分析工具
三、核心逻辑讲解(工程视角)
1️⃣ 数据模型设计
PetContact
├── pet_type 宠物种类
├── contact_type 接触方式
├── duration_minutes 每日接触时长
├── protection_used 是否使用防护
└── population 接触人群
2️⃣ 风险评分机制(规则驱动)
因素 风险倾向
接触时间长 ↑
高风险宠物 ↑
无防护措施 ↑
易感人群 ↑
简化风险公式
风险指数 =
基础风险 × 时长系数 × 防护系数 × 人群系数
3️⃣ 输出结果
- 风险等级(低 / 中 / 高)
- 防护建议(非医疗)
- 家庭接触行为画像
四、Python 模块化代码(可直接运行)
📁 项目结构
pet_risk_analysis/
│
├── main.py
├── models.py
├── analyzer.py
├── storage.py
└── README.md
✅ models.py(数据建模)
"""
models.py
人与宠物接触数据模型
"""
class PetContact:
def __init__(
self,
pet_type,
contact_type,
duration_minutes,
protection_used,
population
):
self.pet_type = pet_type
self.contact_type = contact_type
self.duration_minutes = duration_minutes
self.protection_used = protection_used
self.population = population
✅ analyzer.py(核心分析逻辑)
"""
analyzer.py
人畜共患病潜在接触风险分析
"""
BASE_RISK = {
"猫": 2,
"狗": 2,
"鸟": 3,
"爬行动物": 4,
"啮齿类": 3
}
CONTACT_MULTIPLIER = {
"抚摸": 1,
"清洁笼舍": 1.5,
"喂食": 1.2,
"同床": 2
}
POPULATION_RISK = {
"成人": 1,
"儿童": 1.3,
"老人": 1.4,
"免疫低下": 1.6
}
def analyze(contacts):
results = []
for c in contacts:
base = BASE_RISK.get(c.pet_type, 2)
contact_factor = CONTACT_MULTIPLIER.get(c.contact_type, 1)
pop_factor = POPULATION_RISK.get(c.population, 1)
protection_factor = 0.7 if c.protection_used else 1.2
score = (
base *
(c.duration_minutes / 30) *
contact_factor *
pop_factor *
protection_factor
)
risk_level = interpret(score)
results.append({
"pet_type": c.pet_type,
"duration": c.duration_minutes,
"risk_score": round(score, 2),
"risk_level": risk_level,
"suggestion": suggest(risk_level, c.protection_used)
})
return results
def interpret(score):
if score < 3:
return "低风险"
elif score < 6:
return "中风险"
else:
return "高风险"
def suggest(level, protected):
if level == "低风险":
return "保持良好卫生习惯"
elif level == "中风险" and not protected:
return "建议加强手部卫生与防护"
elif level == "高风险":
return "减少密切接触,必要时咨询专业人员"
else:
return "维持现有防护措施"
✅ storage.py(本地存储)
"""
storage.py
JSON 本地存储
"""
import json
import os
FILE_PATH = "pet_contacts.json"
def save_contacts(contacts):
data = [c.__dict__ for c in contacts]
with open(FILE_PATH, "w", encoding="utf-8") as f:
json.dump(data, f, ensure_ascii=False, indent=2)
✅ main.py(交互入口)
"""
main.py
人畜共患病潜在接触风险分析工具
"""
from models import PetContact
from analyzer import analyze
from storage import save_contacts
def main():
print("=== 人畜共患病潜在接触风险分析 ===")
contacts = []
while True:
pet_type = input("宠物种类(空结束):")
if not pet_type:
break
contact_type = input("接触方式:")
duration = int(input("每日接触时长(分钟):"))
protection = input("是否使用防护(y/n):") == "y"
population = input("接触人群(成人/儿童/老人/免疫低下):")
contact = PetContact(
pet_type,
contact_type,
duration,
protection,
population
)
contacts.append(contact)
results = analyze(contacts)
print("\n【分析结果】")
for r in results:
print(r)
save_contacts(contacts)
print("✅ 数据已保存")
if __name__ == "__main__":
main()
五、README 与使用说明
# 人畜共患病潜在接触风险分析(教学版)
## 项目说明
用于记录人与宠物接触情况,并基于规则模型评估潜在接触风险。
## 使用方式
```bash
python main.py
```
## 适用范围
- 健康管理课程
- 公共卫生教学
- 家庭健康意识培养
## 注意事项
- 非医疗诊断工具
- 不替代兽医或医生建议
- 结果仅作教学参考
六、核心知识点卡片(教学向)
分类 内容
Python 类、条件判断、函数
工程思想 模型与业务逻辑解耦
风险管理 风险因子量化
公共卫生 人畜共患病概念
数据伦理 不夸大、不误导
可扩展性 可接入数据库 / Web
七、总结(工程师视角)
这是一个完全中立、去营销化、可教学的原型系统:
✅ 不制造健康焦虑
✅ 不神化 AI 预测
✅ 不替代专业机构
它真正展示的是:
如何用 Python 把日常行为转化为可分析的健康数据
利用AI解决实际问题,如果你觉得这个工具好用,欢迎关注长安牧笛!