04hive数仓内外部表复杂数据类型与分区分桶

hive内部表和外部表
  1. 默认为内部表,外部表的关键字 :external
  2. 内部表:对应的文件夹就在默认路径下 /user/hive/warehouse/库名.db/
  3. 外部表:数据文件在哪里都行,无须移动数据
# students.txt
1,Lucy,girl,23
2,Tom,boy,23
3,Jim,boy,35【1】创建外部表并查看(location指映射的文件路径)
hive> create external table studenttab(id int,name string,sex string, age int )row format delimited fields terminated by ',' location '/stu';【2】上传文件并测试hadoop fs -mkdir /stuhadoop fs -put students.txt /stuhive>select * from studenttab;发现已经存在了数据,而且在默认路径下根本就没有文件夹【3】 删除表2.1)删除内部表 drop table t2; 元数据和具体数据全部删除2.2)删除外部表 drop table studenttab; 发现数据还在,只是删除了元数据# 内部表是受hive管理的表,外部表是不受hive管理的表,
# 实际工作中外部表使用较多,先在分布式文件系统中传文件,然后管理

内部表和外部表区别总结

【1】内部表无external关键字,外部表有
【2】内部表由Hive自身管理,外部表由HDFS管理
【3】内部表/user/hive/warehouse位置,外部表存在hdfs中任意位置
【4】内部表元数据及存储数据一起删除,外部表会删除元数据,HDFS上不会被删除

Hive练习

在电商网站上,当我们进入到某电商页面浏览商品时,就会产生用户对商品访问情况的数据,包含两个字段(商品id,点击次数),以逗号分隔,由于数据量很大,所以为了方便统计,我们只截取了一部分数据,内容如下:

1010031,100
1010102,100
1010152,97
1010178,96
1010280,104
1010320,103
1010510,104
1010603,96
1010637,97

问题1: 实现文件和表的映射

create table product_tab(
goods_id int,
goods_click int
)row format delimited fields terminated by ',';load data local inpath '/root/product.txt' into table product_tab;select goods_click,goods_id from product_tab order by goods_click; # 实现排序
Hive复杂数据类型
array

1.1 特点为集合里的每一个字段都是一个具体的信息,不会是那种key与values的关系

1.2 建表时,字段名 array

1.3 建表时,collection items terminated by ‘分隔符’

1.4 详情请见如下示例,比如文件内容如下:

# 数据样本 array.txt
yaya	beijing,shanghai,tianjin,hangzhou # 姓名  (\t分割)  工作地点
lucy	shanghai,chengdu,wuhan,shenzhen# 2. 将本地文件上传至hdfs
hadoop fs -mkdir /stuinfo
hadoop fs -put array.txt /stuinfo# 3. 建表测试   array<string>
create external table array_tab(name string, work_locations array<string>) row format delimited fields terminated by '\t' collection items terminated by ',' location '/stuinfo';# 4. 基本查询
hive> select * from array_tab;
yaya    ["beijing","shanghai","tianjin","hangzhou"]
lucy    ["shanghai","chengdu","wuhan","shenzhen"]# 5. 查询在天津工作过的用户信息
hive> select * from array_tab where array_contains(work_locations, 'tianjin');
yaya    ["beijing","shanghai","tianjin","hangzhou"]# 6. 查询所有人的第一工作城市
hive> select name,work_locations[0] from array_tab;
yaya    beijing
lucy    shanghai# 7. 查询 array_contains()函数
#查询在天津工作过的用户信息
hive> select * from array_tab where array_contains(work_locations, 'tianjin');
yaya    ["beijing","shanghai","tianjin","hangzhou"]
map

样本中部分字段基于 key-value 模型

delimited fields terminated by ','
collection items terminated by '#' 
map keys terminated by ':';
# 1. 数据样本:map.txt
# 编号(id)   姓名(name)   家庭成员(member)  年龄(age)
1,yaya,father:yababa#mother:yamama#brother:daya,28
2,pandas,father:panbaba#mother:panmama#brother:dapan,25
3,ai,father:aibaba#mother:aimama#brother:daai,30
4,ds,father:dsbaba#mother:dsmama#brother:dads,29# 2. 创建对应表
create table map_tab(
id int,
name string,
members map<string,string>,
age int
)row format delimited fields terminated by ','
collection items terminated by '#' 
map keys terminated by ':';# 3. 数据映射
load data local inpath '/root/map.txt' into table map_tab;# 4. 基本查询
select * from map_tab;
1       yaya    {"father":"yababa","mother":"yamama","brother":"daya"}  28
2       pandas  {"father":"panbaba","mother":"panmama","brother":"dapan"}       25
3       ai      {"father":"aibaba","mother":"aimama","brother":"daai"}  30
4       ds      {"father":"dsbaba","mother":"dsmama","brother":"dads"}  29# 5. 查询 yaya 的爸爸是谁
select members['father'] from map_tab where name='yaya';
yababa
struct

这个数据类型的特点就是可以包含各种各样的数据类型。但是struct可以是任意数据类型,在写struct数据类型时,在<>中要写清楚struct字段中的字段名称跟数据类型

delimited fields terminated by ','
collection items terminated by '#' 
# 1. 数据样本:struct.txt
# IP         用户信息
192.168.1.1#yaya:30
192.168.1.2#pandas:50
192.168.1.3#tiger:60
192.168.1.4#lion:70# 2. 创建对应表
create table struct_tab(
ip string,
userinfo struct<name:string,age:int>
)row format delimited fields terminated by '#'
collection items terminated by ':';# 3. 数据映射
load data local inpath '/root/struct.txt' into table struct_tab;# 4. 查询所有数据
select * from struct_tab;# 5. 查询所有用户的名字
select userinfo.name from struct_tab;# 6. 查询访问过192.168.1.1的用户的名字
select userinfo.name from struct_tab where ip='192.168.1.1';
hive分区表
  1. 有些时候数据是有组织的,比方按日期/类型等分类,如查询具体某一天的数据时,不需要扫描全部目录,所以会明显优化性能

  2. 一个Hive表在HDFS上是有一个对应的目录来存储数据,普通表的数据直接存储在这个目录下,而分区表数据存储时,是再划分子目录来存储的

    #原始表
    /user/hive/warehouse/test2024.db/logtab/{t1.log,t2.log,t3.log}# 分区表
    /user/hive/warehouse/test2024.db/logtab/t1/t1.log
    /user/hive/warehouse/test2024.db/logtab/t2/t2.log
    /user/hive/warehouse/test2024.db/logtab/t3/t3.log
    
  3. 使用partioned by (xxx)来创建表的分区

  4. 分区表示例

    # 1. 样本数据 - employee.txt,按天来做管理,1天一个分区,意义在于优化查询
    # 员工编号(id)    员工姓名(name)   员工工资(salary)
    1,赵丽颖,100000
    2,超哥哥,12000
    3,迪丽热巴,130000
    4,宋茜,800000# 2. 创建分区表 - 内部表
    create table employee(
    id int,
    name string,
    salary decimal(20,2)
    ) partitioned by (date1 string) row format delimited fields terminated by ',';# 3. 添加分区并查看 - 此时在hdfs中已经创建了该分区的对应目录
    hive> alter table employee add partition(date1='2000-01-01');hive> show partitions employee;   # date1=2000-01-01
    hive> desc employee;
    OK
    id                      int
    name                    string
    salary                  decimal(20,2)
    date1                   string# Partition Information
    # col_name              data_type               commentdate1                   string# 4. 加载数据到分区
    hive> load data local inpath '/root/employ1.txt' into table employee partition(date1='2000-01-01');# 5. 查询确认
    hive> select * from employee where date1='2000-01-01';
    
  5. 分区表的用途&常用指令

    1. 避免全表扫描
    2. 一般的应用是以天为单位,一天是一个分区,比如2000-01-01是一个目录,对应的表的一个分区
    
    1. show partitions 表名;
    2. alter table 表名 add partition(date1='2000-01-02');
    3. msck repair table 表名;     此为修复分区
    4. alter table 表名 drop partition(date1='2000-01-02');
    
  6. 添加分区的两种方式

    【1】添加分区方式一 先创分区,再load(hive操作)# 准备新的文件,employee2.txt,内容如下5,赵云,50006,张飞,60001.1) alter table employee add partition(date1='2000-01-02');1.2) load data local inpath '/root/employ2.txt' into table employee partition(date1='2000-01-02');1.3) select * from employee;【2】添加分区方式二 先创建上传(hadoop操作),再刷新(hive操作)# 准备新的文件,employee3.txt,内容如下7,司马懿,80008,典韦,78002.1) hadoop fs -mkdir /user/hive/warehouse/test2024.db/employee/date1=2000-01-032.2) hadoop fs -put '/root/employ3.txt' /user/hive/warehouse/test2024.db/employee/date1=2000-01-032.3) hive> msck repair table employee;		#修复分区表hive> show partitions employee; hive> select * from employee;
    

    练习-创建外部表分区表

    【1】创建数据存放目录hadoop fs -mkdir /webloghadoop fs -mkdir /weblog/reporttime=2000-01-01hadoop fs -mkdir /weblog/reporttime=2000-01-02【2】准备两个文件
    # data1.txt
    1 rose 200
    2 tom 100
    3 lucy 200
    # data2.txt
    4 yaya 300
    5 nono 100
    6 doudou 200【3】将文件存入对应分区目录hadoop fs -put data1.txt /weblog/reporttime=2020-01-01hadoop fs -put data2.txt /weblog/reporttime=2020-01-02【4】创建外部表create external table w1(id int, name string, score int) partitioned by(reporttime string) row format delimited fields terminated by ' ' location '/weblog';【5】修复分区msck repair table w1;【6】确认分区	show partitions w1;【7】查询确认select * from w1;
    
hive分桶表
  1. 分桶是相对分区进行更细粒度的划分。分桶将整个数据内容安装某列属性值的hash值进行区分,按照取模结果对数据分桶。如取模结果相同的数据记录存放到一个文件

  2. 桶表也是一种用于优化查询而设计的表类型。创建桶表时,指定桶的个数、分桶的依据字段,hive就可以自动将数据分桶存储。查询时只需要遍历一个桶里的数据,或者遍历部分桶,这样就提高了查询效率

  3. 桶表创建

    1. 分桶表创建之前需要开启分桶功能
    2. 分桶表创建的时候,分桶的字段必须是表中已经存在的字段,即要按照表中某个字段进行分开
    3. 针对分桶表的数据导入,load data的方式不能够导成分桶表的数据,没有分桶效果
    4. 用 insert + select ,插入
    
    # 样本数据 - 学生选课系统:course.txt
    # 学生编号(id)   学生姓名(name)  选修课程(course)
    1,佩奇,Python
    2,乔治,Hive
    3,丹尼,Python
    4,羚羊夫人,Hadoop
    5,奥特曼,AI
    6,怪兽,DS# 1. 先创建普通表,导入数据 - student,
    create table student(
    id int,
    name string,
    course string
    )row format delimited fields terminated by ',';load data local inpath '/root/course.txt' into table student;# 2. 开启分桶功能并指定桶的数量
    set hive.enforce.bucketing = true;
    set mapreduce.job.reduces=4;# 3. 创建分桶表 - stu_buck
    create table stu_buck(
    id int,
    name string,
    course string
    ) clustered by(id) into 4 buckets row format delimited fields terminated by ',';# 4. 分桶表数据导入
    insert into table stu_buck select * from student;  #会触发mapreduce
    select * from stu_buck;# 5. 到浏览器中查看,发现stu_buck文件夹中出现了4个桶表 
    000000_0  000001_0 000002_0 000003_0# 命令行查看
    [root@vm ~]# hadoop fs -text /user/hive/warehouse/test2024.db/stu_buck/000000_0
    4,羚羊夫人,Hadoop
    [root@vm ~]# hadoop fs -text /user/hive/warehouse/test2024.db/stu_buck/000001_0
    5,奥特曼,AI	
    1,佩奇,Python		# 根据id 对桶的个数取模了
    
  4. 关于分桶表

    4.1 想要把表格划分的更加细致

    4.2 分桶表的数据采用 insert + select ,插入的数据来自于查询结果(查询时候执行了mr程序)

    4.3 分桶表也是把表所映射的结构化数据文件分成更细致的部分,但是更多的是用在join查询提高效率之上,只需要把 join 的字段在各自表当中进行分桶操作即可

经常把连接查询经常用来做条件判断的字段(即on后面的字段)作为分桶的依据字段。

在这里插入图片描述

hive常用字符串操作函数
select length('hello2020');
select length(name) from employee; 用途: 比如说第一列为手机号,我来查证手机号是否合法select reverse('hello');select concat('hello', 'world')  # 假如说有一个表是三列,可以拼接列select concat(id,name) from w1;select concat(id,',',name)  from w1;select concat_ws('.', 'www', 'baidu', 'com'); # 只能操作字符串,不能有整型select substr('abcde', 2);  # 用途:截取身份证号的后四位?可以使用此方法select upper('ddfFKDKFdfd')select lower('dfdfKJKJ')	# 可以做数据的转换select trim("     dfadfd.   "); # 去除左右两侧的空白,可以加 l  和 r

Hive之影评分析案例

数据说明

现有三份数据,具体数据如下:

  1. users.txt

    【1】数据格式(共有6040条数据)3:M:25:15:55117
    【2】对应字段用户id、 性别、  年龄、 职业、 邮政编码user_id  gender  age   work    coding
    
  2. movies.txt

    【1】数据格式(共有3883条数据)3:Grumpier Old Men (1995):Comedy|Romance
    【2】对应字段电影ID、 电影名字、电影类型movie_id   name    genres
    
  3. ratings.txt

    【1】数据格式(共有1000209条数据)1:661:3:978302109
    【2】对应字段用户ID、  电影ID、  评分、  评分时间戳user_id   movie_id  rating    times
    
案例说明
  1. 求被评分次数最多的10部电影,并给出评分次数(电影名,评分次数)
  2. 求movieid = 2116这部电影各年龄的平均影评(年龄,影评分)
  3. 分别求男性,女性当中评分最高的10部电影(性别,电影名,影评分)
  4. 求最喜欢看电影(影评次数最多)的那位女性评最高分的10部电影的平均影评分(观影者,电影名,影评分)
库表映射实现
  1. 建库

    create database movie;
    use movie;
    
  2. 创建t_user表并导入数据 - a

    create table t_user(
    user_id bigint,
    gender string,
    age int,
    work string,
    code string
    )row format delimited fields terminated by ':';load data local inpath '/home/tarena/hadoop/users.txt' into table t_user;
    
  3. 创建t_movie表并导入数据 - b

    create table t_movie(
    movie_id bigint,
    name string,
    genres string
    )row format delimited fields terminated by ':';load data local inpath '/home/tarena/hadoop/movies.txt' into table t_movie;
    
  4. 创建t_rating表并导入数据 - c

    create table t_rating(
    user_id bigint,
    movie_id bigint,
    rating double,
    times string
    )row format delimited fields terminated by ':';load data local inpath '/home/tarena/hadoop/ratings.txt' into table t_rating;
    
案例实现
  1. 求被评分次数最多的10部电影,并给出评分次数(电影名,评分次数)

    【1】需求字段1.1) 电影名: t_movie.name1.2) 评分次数: t_rating.rating
    【2】思路按照电影名进行分组统计,求出每部电影的评分次数并按照评分次数降序排序
    【3】实现
    create table result1 as
    select b.name as name,count(b.name) as total from t_movie b inner join t_rating c on b.movie_id=c.movie_id
    group by b.name
    order by total desc
    limit 10;
    
  2. 求movieid = 2116这部电影各年龄的平均影评(年龄,影评分)

    【1】需求字段1.1) 年龄: t_user.age1.2) 影评分: t_rating.rating
    【2】思路t_user和t_rating表进行联合查询,movie_id=2116过滤条件,年龄分组
    【3】实现
    create table result3 as
    select a.age as age, avg(c.rating) as avgrate from t_user a
    join t_rating c
    on a.user_id=c.user_id 
    where c.movie_id=2116 
    group by a.age;
    
  3. 分别求男性,女性当中评分最高的10部电影(性别,电影名,影评分)

    【1】需求字段1.1) 性别: t_user.gender1.2) 电影名:t_movie.name1.3) 影评分:t_rating.rating
    【2】思路2.1) 三表联合查询2.2) 按照性别过滤条件,电影名作为分组条件,影评分作为排序条件进行查询
    【3】实现
    3.1) 女性当中评分最高的10部电影
    create table result2_F as
    select 'F' as sex, b.name as name,  avg(c.rating) as avgrate 
    from t_rating c join t_user a on c.user_id=a.user_id
    join t_moive b on c.moive_id=b.movie_id
    where a.gender='F'
    group by b.name order by avgrate desc 
    limit 10;3.2) 男性当中评分最高的10部电影
    create table result2_M as
    select 'M' as sex, b.name as name,  avg(c.rating) as avgrate 
    from t_rating c join t_user a on c.user_id=a.user_id
    join t_moive b on c.moive_id=b.movie_id
    where a.gender='M'
    group by b.name order by avgrate desc 
    limit 10;
    
  4. 求最喜欢看电影(影评次数最多)的那位女性评最高分的10部电影的平均影评分(电影编号,电影名,影评分)

    【1】需求字段1.1) 电影编号: t_rating.movie_id1.2) 电影名: t_movie.name1.3) 影评分: t_rating.rating
    【2】思路2.1) 先找出最喜欢看电影的那位女性2.2) 根据2.1中的女性user_id作为where过滤条件,以看过的电影的影评分rating作为排序条件进行排序,找出评分最高的10部电影2.3) 求出2.2中10部电影的平均分【3】实现
    3.1) 最喜欢看电影的女性(t_rating.user_id, 次数)
    create table result4_A as 
    select c.user_id,count(c.user_id) as total from t_rating c 
    join t_user a on c.user_id=a.user_id 
    where a.gender='F'
    group by c.user_id order by total desc limit 1;3.2) 找出那个女人评分最高的10部电影
    create table result4_B as
    select c.movie_id, c.rating as rating from t_rating c
    where c.user_id=1150 order by rating desc limit 10;3.3) 求出10部电影的平均分
    select d.movie_id as movie_id, b.name as name,avg(c.rating) from result4_B d join t_rating on d.movie_id=c.movie_id
    join t_movie on c.movie_id=b.movie_id
    group by d.movie_id, b.name;
    

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/735889.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Python实战:Python常用IDE选择

在Python编程的旅程中&#xff0c;选择一个合适的开发环境至关重要。本文将详细介绍三种流行的Python开发环境&#xff1a;PyCharm、VS Code和Jupyter Notebook。我们将探讨它们的特点、安装步骤、基本使用方法&#xff0c;并通过具体的代码示例来展示如何在这些环境中编写和运…

Python中,括号内部的for循环(列表推导式)

在Python中&#xff0c;括号内部的for循环通常用于列表推导式&#xff08;list comprehension&#xff09;&#xff0c;这是一种简洁创建列表的方式。列表推导式可以使用任何可迭代对象内的元素来创建新的列表元素。 列表推导式的基本语法结构如下&#xff1a; [expression f…

Kafka的分区机制

Kafka的分区机制是其核心功能之一&#xff0c;旨在提高可扩展性和并行处理能力。下面概述了Kafka分区的基本概念和工作原理&#xff1a; Kafka分区基本概念 分区&#xff08;Partition&#xff09;&#xff1a;Kafka中的主题&#xff08;Topic&#xff09;可以细分为多个分区…

政安晨:【深度学习处理实践】(五)—— 初识RNN-循环神经网络

RNN&#xff08;循环神经网络&#xff09;是一种在深度学习中常用的神经网络结构&#xff0c;用于处理序列数据。与传统的前馈神经网络不同&#xff0c;RNN通过引入循环连接在网络中保留了历史信息。 RNN中的每个神经元都有一个隐藏状态&#xff0c;它会根据当前输入和前一个时…

Java EE之wait和notify

一.多线程的执行顺序 由于多个线程执行是抢占式执行&#xff0c;就会导致顺序不同&#xff0c;同时就会导致出现问题&#xff0c;就比如俩个线程同时对同一个变量进行修改&#xff0c;我们难以预知执行顺序。 但在实际开发中&#xff0c;我们希望代码按一定的逻辑顺序执行&am…

AI辅助研发:引领科技创新的未来之路

随着人工智能技术的快速发展和广泛应用&#xff0c;AI辅助研发正逐渐成为科技界和工业界的焦点。2024年&#xff0c;作为AI技术进一步成熟的见证者&#xff0c;我们正处于AI辅助研发的黄金时代。从医药研发到汽车设计&#xff0c;从软件开发到材料科学&#xff0c;AI的影响力已…

计算机视觉——P2PNet基于点估计的人群计数原理与C++模型推理

简介 人群计数是计算机视觉领域的一个核心任务&#xff0c;旨在估算静止图像或视频帧中的行人数量。在过去几十年中&#xff0c;研究人员在这个领域投入了大量的精力&#xff0c;并在提高现有主流基准数据集性能方面取得了显著进展。然而&#xff0c;训练卷积神经网络需要大规…

matlab阶段学习笔记小节2

syms定义符号变量 求极限 第二题 第三题 limit(y,n,inf);求的的函数y关于自变量n在无穷处&#xff08;inf&#xff09;的极限 exp(2)即指数为2&#xff0c;底为e,也就是e^2 求导数 第一题 log(x)默认是以e为底的指数函数&#xff0c;也就是ln(x). 使用diff(f)对函数进行求…

今日份总结

1&#xff1a;标题 <h1>一级标题</h1> <h2>二级标题</h2> <h3>三级标题</h3> 可以用快捷键&#xff1a;h$*6 (表示一到六级标题) 2&#xff1a;段落 <p>这是一个段落</p> 3&#xff1a;换行 <p>这是一个段落&l…

算法-双指针、BFS与图论-1113. 红与黑

题目 思路 本题相当于问BFS中的当前点所在的区域连通块有多少个 Flood Fill算法 &#xff08;可参考以下链接&#xff1a;洪水覆盖算法(Flood Fill)&#xff1a;颜色填充-CSDN博客&#xff09;本题用DFS实现Flood Fill算法DFS是否需要恢复现场&#xff1a;&#xff08;重要&am…

新IDEA电脑环境设置

1.设置UTF-8 2.Maven 3.JRE选对

【漏洞复现】华三用户自助服务产品dynamiccontent.properties.xhtml接口处存在RCE漏洞

免责声明&#xff1a;文章来源互联网收集整理&#xff0c;请勿利用文章内的相关技术从事非法测试&#xff0c;由于传播、利用此文所提供的信息或者工具而造成的任何直接或者间接的后果及损失&#xff0c;均由使用者本人负责&#xff0c;所产生的一切不良后果与文章作者无关。该…

VUE+HBuilder的uniapp技术路线开发应用使用总结

使用总结 本来想做一个记录日常数据的应用&#xff0c;主要在Android端使用&#xff0c;后来发现在uniapp中使用sqllite数据库不是像原生中那样简单(所以当前准备去进行另一个路线&#xff0c;就是给我使用的电脑都安装一个portalble的服务端&#xff0c;用来记录数据&#xf…

java中使用rabbitmq

文章目录 前言一、引入和配置1.引入2.配置 二、使用1.队列2.发布/订阅2.1 fanout(广播)2.2 direct(Routing/路由)2.3 Topics(主题)2.4 Headers 总结 前言 mq常用于业务解耦、流量削峰和异步通信,rabbitmq是使用范围较广,比较稳定的一款开源产品,接下来我们使用springboot的sta…

C#(C Sharp)学习笔记_变量常量与作用域【十二】

变量 变量是用来存储数据值的标识符。你可以将变量视为内存中的一个位置&#xff0c;这个位置可以保存不同类型的数据。同时&#xff0c;变量也被称作为类中的成员变量 在C#中声明变量时&#xff0c;你需要指定变量的类型&#xff0c;这告诉编译器你打算在变量中存储什么类型的…

角蜥优化算法 (Horned Lizard Optimization Algorithm ,HLOA)求解无人机路径优化

一、无人机路径规划模型介绍 无人机三维路径规划是指在三维空间中为无人机规划一条合理的飞行路径,使其能够安全、高效地完成任务。路径规划是无人机自主飞行的关键技术之一,它可以通过算法和模型来确定无人机的航迹,以避开障碍物、优化飞行时间和节省能量消耗。 二、算法介…

简单线性回归原理sklearn简单实现

1. 回归与分类 回归模型&#xff1a;针对于连续值的预测&#xff0c;即线性关系 分类模型&#xff1a;预测离散值&#xff0c;非线性&#xff0c;针对于分类问题2. 回归 回归算法是相对分类算法而言的&#xff0c;与我们想要预测的目标变量y的值类型有关。 如果目标变量y是分…

数据结构:图及相关算法讲解

图 1.图的基本概念2. 图的存储结构2.1邻接矩阵2.2邻接表2.3两种实现的比较 3.图的遍历3.1 图的广度优先遍历3.2 图的深度优先遍历 4.最小生成树4.1 Kruskal算法4.2 Prim算法4.3 两个算法比较 5.最短路径5.1两个抽象存储5.2单源最短路径--Dijkstra算法5.3单源最短路径--Bellman-…

Dataset 读取数据

Dataset 读取数据 from torch.utils.data import Dataset from PIL import Image import osclass Mydata(Dataset):def __init__(self,root_dir,label_dir):self.root_dir root_dir #根目录 dataset/trainself.label_dir label_dir #标签的后面链接目录 ants_ima…

windows系统玩游戏找不到d3dx9_43.dll缺失,无法启动此程序的解决方法

今日&#xff0c;我们要深入讨论d3dx9_43.dll文件的重要性及其缺失问题。最近&#xff0c;我也遇到了这个文件丢失的困扰&#xff0c;因此想借此机会与大家分享如何解决d3dx9_43.dll缺失的问题。 一.电脑d3dx9_43.dll丢失会提示什么&#xff1f; 关于电脑提示d3dx9_43.dll丢失…