news 2026/4/16 8:59:03

Python Victor-DAY 6 数据可视化

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Python Victor-DAY 6 数据可视化

内容回顾:数据初步可视化

  1. 单特征可视化:连续变量箱线图(还说了核密度直方图)、离散特征直方图
  2. 特征和标签关系可视化
  3. 箱线图美化--->直方图

作业:去针对其他特征绘制单特征图和特征和标签的关系图,并且试图观察出一些有意思的结论

import pandas as pd data = pd.read_csv(r'D:\课程\课程文件1\pythonstudy\pythonx训练营\python-60days-challenge\data.csv') data.head()

continous_features = [] discrete_features = [] for i in data.columns: if data[i].dtype == 'object': continous_features.append(i) else: discrete_features.append(i) print(continous_features) print(discrete_features)
['Home Ownership', 'Years in current job', 'Purpose', 'Term'] ['Id', 'Annual Income', 'Tax Liens', 'Number of Open Accounts', 'Years of Credit History', 'Maximum Open Credit', 'Number of Credit Problems', 'Months since last delinquent', 'Bankruptcies', 'Current Loan Amount', 'Current Credit Balance', 'Monthly Debt', 'Credit Score', 'Credit Default']
import seaborn as sns import matplotlib.pyplot as plt import pandas as pd #箱线图 sns.boxplot(x = data['Home Ownership']) plt.title('Home Ownership 的箱线图') plt.xlabel('Home Ownership') plt.show() plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicode_minus'] = False

#直方图 sns.histplot(data['Current Credit Balance']) plt.title('当前信用余额 直方图') plt.xlabel('当前信用余额') plt.ylabel('员工数量') plt.show()

#特征与标签的关系 # 可视化方式:箱线图 plt.figure(figsize=(8, 16)) sns.boxplot(x='Current Credit Balance', y='Home Ownership', data=data) plt.title('Home Ownership vs. Current Credit Balance') plt.xlabel('Current Credit Balance') plt.ylabel('Current Credit Balance') plt.show()

# 另一种可视化方式:小提琴图 plt.figure(figsize=(8, 16)) sns.violinplot(x='Current Credit Balance', y='Home Ownership', data=data) plt.title('Home Ownership vs. Current Credit Balance') plt.xlabel('Current Credit Balance') plt.ylabel('Current Credit Balance') plt.show()

# 绘制 Current Credit Balance 和 Credit Default 的关系图 plt.figure(figsize=(18, 16)) sns.histplot(x='Current Credit Balance', hue='Home Ownership', data=data, kde=True, element="step") #,kde表示核密度,kde=True表示使用核密度估计来平滑边缘,element="step"表示使用阶梯状的直方图 plt.title('Current Credit Balance vs. Home Ownership') plt.xlabel('Current Credit Balance') plt.ylabel('Count') plt.show()

浙大疏锦行

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/12 11:29:03

腾讯混元Hunyuan-Large:混合专家架构引领大模型效率革命

腾讯混元Hunyuan-Large:混合专家架构引领大模型效率革命 【免费下载链接】Tencent-Hunyuan-Large 项目地址: https://ai.gitcode.com/hf_mirrors/tencent/Tencent-Hunyuan-Large 导语 腾讯正式开源Hunyuan-Large大模型,以3890亿总参数、520亿激…

作者头像 李华
网站建设 2026/4/11 6:29:22

Windows Defender完全禁用指南:2025年系统优化终极方案

Windows Defender完全禁用指南:2025年系统优化终极方案 【免费下载链接】windows-defender-remover 项目地址: https://gitcode.com/gh_mirrors/win/windows-defender-remover 你是否厌倦了Windows Defender无休止的资源占用和性能拖累?是否在追…

作者头像 李华
网站建设 2026/4/15 18:44:26

DeepSeek-V3.1:混合模式与UE8M0 FP8双引擎驱动大模型效率革命

导语 【免费下载链接】DeepSeek-V3.1-Base DeepSeek-V3.1 是一款支持思考模式与非思考模式的混合模型 项目地址: https://ai.gitcode.com/hf_mirrors/deepseek-ai/DeepSeek-V3.1-Base DeepSeek-V3.1通过创新的混合思考模式与UE8M0 FP8量化技术,重新定义了大语…

作者头像 李华
网站建设 2026/4/10 17:26:18

用Wan2.2-T2V-A14B打造高端广告生成平台的完整路径

用Wan2.2-T2V-A14B打造高端广告生成平台的完整路径 在品牌营销节奏越来越快的今天,一条广告从创意构思到上线投放,往往需要经历脚本撰写、拍摄执行、后期剪辑等多个环节,动辄耗费数天甚至数周。而当市场热点稍纵即逝、用户注意力日益碎片化时…

作者头像 李华
网站建设 2026/4/14 18:14:57

阿里Qwen3-Omni全模态大模型:重构人机交互的技术革命与产业价值

导语 【免费下载链接】Qwen3-Omni-30B-A3B-Thinking 项目地址: https://ai.gitcode.com/hf_mirrors/Qwen/Qwen3-Omni-30B-A3B-Thinking 阿里通义千问团队推出的Qwen3-Omni全模态大模型,通过创新架构实现文本、图像、音频、视频的原生融合处理,在…

作者头像 李华