码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 【matplotlib】降维 可视化


    参见:sklearn.manifold
    https://scikit-learn.org/stable/modules/classes.html#module-sklearn.manifold

    下面是正文内容。

    这是scikit-learn的类和函数参考。有关详细资料,请参阅完整的用户指南,因为类别和功能的原始规格可能不足以提供有关其使用的完整指南。有关在API中重复出现的概念的参考,请参见常用术语和API元素术语表。

    常用降维方法

    Matplotlib 提供了多种降维方法,以下是常见的方法及其详细描述:

    1. row wise:每行一个数据点,每个数据点的value对应一个横坐标,一个纵坐标。

    使用方法:

    import matplotlib.pyplot as plt
    import numpy as np
    
    # 生成一个数据集
    x = np.linspace(0, 10, 100)
    y = np.sin(x)
    
    # 绘制降维图
    plt.plot(x, y)
    plt.xlabel('X 轴')
    plt.ylabel('Y 轴')
    plt.title('降维图')
    plt.show()
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    1. col wise:每列一个数据点,每个数据点的value对应一个横坐标,一个纵坐标。

    使用方法:

    import matplotlib.pyplot as plt
    import numpy as np
    
    # 生成一个数据集
    x = np.linspace(0, 10, 100)
    y = np.sin(x)
    
    # 绘制降维图
    plt.pcolor(x, y, cmap='gray')
    plt.xlabel('X 轴')
    plt.ylabel('Y 轴')
    plt.title('降维图')
    plt.show()
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    1. 图像降维:将数据集转换为图像,并将图像降维到指定的维数。

    使用方法:

    import matplotlib.pyplot as plt
    import numpy as np
    from matplotlib.image import imread
    
    # 读取图像
    img = imread('image.jpg')
    
    # 转换为灰度图像
    img = img[:, :, 0]
    
    # 降维到2维
    img_2d = np.reshape(img, (img.shape[0], img.shape[1]))
    
    # 绘制降维图
    plt.imshow(img_2d, cmap='gray')
    plt.xlabel('X 轴')
    plt.ylabel('Y 轴')
    plt.title('降维图')
    plt.show()
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    1. 折线降维:将数据集转换为折线图,并将折线降维到指定的维数。

    使用方法:

    import matplotlib.pyplot as plt
    import numpy as np
    
    # 生成一个数据集
    x = np.linspace(0, 10, 100)
    y = np.sin(x)
    
    # 绘制折线图
    plt.plot(x, y)
    
    # 降维到2维
    x_2d = np.reshape(x, (x.shape[0], 1))
    y_2d = np.reshape(y, (y.shape[0], 1))
    
    # 绘制降维图
    plt.plot(x_2d, y_2d)
    plt.xlabel('X 轴')
    plt.ylabel('Y 轴')
    plt.title('降维图')
    plt.show()
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    1. 折线面降维:将数据集转换为折线面图,并将折线面降维到指定的维数。

    使用方法:

    import matplotlib.pyplot as plt
    import numpy as np
    from matplotlib.collections import LineCollection
    
    # 生成一个数据集
    x = np.linspace(0,
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
  • 相关阅读:
    PolarDB-X 全局 Binlog 解读之性能篇(上)
    什么是关系选择器
    虚拟化+docker基本概念以及安装部署
    IDEA用maven和Spring模板分别创建SpringMVC项目
    商业化广告--体系学习-- 10 -- 业务实战篇 -- 效果优化:如何一步步从提升曝光量深入到提升销量?
    重入攻击和 DAO 被黑事件
    三、CSS基础-元素显示模式 行元素,块元素,行内块元素
    C++---类型转换
    【大数据技术】!重要!MySQL里按某字段指定内容顺序排序的几种实现方法
    redis报错Unrecoverable error: corrupted cluster config file.
  • 原文地址:https://blog.csdn.net/weixin_42468475/article/details/133440953
  • 最新文章
  • 沪漂五周年了:我越来越迷茫了
    Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
    MySQL-Seconds_behind_master的精度误差
    [MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
    AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
    Agent OS :五种驯服不确定性的范式
    PortSwigger SQL注入LAB11
    数据库即时编译JIT
    [Begin]AI Learn Data Day 0
    深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号