hive sql多表练习

hive sql多表练习

准备原始数据集

学生表 student.csv
讲师表 teacher.csv
课程表 course.csv
分数表 score.csv

学生表 student.csv

001,彭于晏,1995-05-16,男
002,胡歌,1994-03-20,男
003,周杰伦,1995-04-30,男
004,刘德华,1998-08-28,男
005,唐国强,1993-09-10,男
006,陈道明,1992-11-12,男
007,陈坤,1999-04-09,男
008,吴京,1994-02-06,男
009,郭德纲,1992-12-05,男
010,于谦,1998-08-23,男
011,潘长江,1995-05-27,男
012,杨紫,1996-12-21,女
013,蒋欣,1997-11-08,女
014,赵丽颖,1990-01-09,女
015,刘亦菲,1993-01-14,女
016,周冬雨,1990-06-18,女
017,范冰冰,1992-07-04,女
018,李冰冰,1993-09-24,女
019,邓紫棋,1994-08-31,女
020,宋丹丹,1991-03-01,女

讲师表 teacher.csv

1001,张高数
1002,李体音
1003,王子文
1004,刘丽英

课程表 course.csv

01,语文,1003
02,数学,1001
03,英语,1004
04,体育,1002
05,音乐,1002

分数表 score.csv

001,01,94
002,01,74
004,01,85
005,01,64
006,01,71
007,01,48
008,01,56
009,01,75
010,01,84
011,01,61
012,01,44
013,01,47
014,01,81
015,01,90
016,01,71
017,01,58
018,01,38
019,01,46
020,01,89
001,02,63
002,02,84
004,02,93
005,02,44
006,02,90
007,02,55
008,02,34
009,02,78
010,02,68
011,02,49
012,02,74
013,02,35
014,02,39
015,02,48
016,02,89
017,02,34
018,02,58
019,02,39
020,02,59
001,03,79
002,03,87
004,03,89
005,03,99
006,03,59
007,03,70
008,03,39
009,03,60
010,03,47
011,03,70
012,03,62
013,03,93
014,03,32
015,03,84
016,03,71
017,03,55
018,03,49
019,03,93
020,03,81
001,04,54
002,04,100
004,04,59
005,04,85
007,04,63
009,04,79
010,04,34
013,04,69
014,04,40
016,04,94
017,04,34
020,04,50
005,05,85
007,05,63
009,05,79
015,05,59
018,05,87

创建数据库和数据表

create database chap05;
use chap05;
-- 学生表 student.csv
create external table student (stu_id string comment '学生ID',stu_name string comment '学生姓名',birthday string comment '出生日期',gender string comment '学生性别'
)row format delimited fields terminated by ','lines terminated by '\n'stored as textfilelocation '/quiz03/student';load data local inpath '/root/data/data02/student.csv' overwrite into table student;select * from student;-- 讲师表 teacher.csv
create external table teacher (tea_id string comment '课程ID',tea_name string comment '课程名称'
)row format delimited fields terminated by ','lines terminated by '\n'stored as textfilelocation '/quiz03/teacher';load data local inpath '/root/data/data02/teacher.csv' overwrite into table teacher;select * from teacher;-- 课程表 course.csv
create external table course (course_id string comment '课程ID',course_name string comment '课程名称',tea_id string comment '讲师ID'
)row format delimited fields terminated by ','lines terminated by '\n'stored as textfilelocation '/quiz03/course';load data local inpath '/root/data/data02/course.csv' overwrite into table course;select * from course;-- 分数表 score.csv
create external table score (stu_id string comment '学生ID',course_id string comment '课程ID',score int comment '成绩'
)row format delimited fields terminated by ','lines terminated by '\n'stored as textfilelocation '/quiz03/score';load data local inpath '/root/data/data02/score.csv' overwrite into table score;

SQL练习

-- 查询所有学生信息
select * from student;-- 查询周姓学生信息
select * from student where stu_name like '周%';-- 查询周姓学生数量
select count(*) from student where stu_name like '周%';-- 查询 学生ID 004 的分数 超过 85 的成绩
select stu.stu_id, stu_name, birthday, gender, course_id, score from student stu inner join score son stu.stu_id = 004 and stu.stu_id = s.stu_id and score > 85;-- 查询 学生程ID 004 的成绩降序
select stu.stu_id, stu_name, birthday, gender, course_id, score from student stu inner join score son stu.stu_id = 004  and  stu.stu_id = s.stu_id order by score desc;-- 查询 数学成绩不及格学生及其对应的成绩 学生成绩
select stu.stu_id, stu_name, birthday, gender, course_name, score from student stuinner join score s inner join course c on s.course_id = c.course_id and  stu.stu_id = s.stu_idand c.course_name = '数学' and score < 60 order by score;-- 查询男女生人数
select gender,count(*) from student group by gender;-- 查询编号为 02 的课程平均成绩
select round(avg(score),2) from score where course_id = 02;-- 查询每科课程平均成绩
select course_id,round(avg(score),2) from score group by course_id;-- 查询参加考试学生人数
select count(distinct stu_id) from score where score is not null and score >= 0;
select count(stu_id) from (select stu_id from score where score is not null and score >= 0 group by stu_id) t;-- 查询每科有多少学生参加考试
select course_id,count(stu_id) from score where score is not null and score >= 0 group by course_id;-- 查询未参加考试的学生信息
select * from student where stu_id in (select stu.stu_id from student stuleft join score s on stu.stu_id = s.stu_idgroup by stu.stu_id having count(*) != (select count(*) from course)
);-- 查询选修至少 4 门 以上课程学生的学号
select stu_id,count(course_id) course_count from scoregroup by stu_idhaving course_count >= 4;-- 查询姓氏相同学生名单 并且同姓人数大于 2 的姓氏
select first_name ,count(*) first_name_count from (select stu_id,stu_name,substr(stu_name,1,1) as first_namefrom student
) tsgroup by ts.first_namehaving first_name_count > 1;-- 查询每门功课的学生的平均成绩 按照平均成绩升序 平均成绩相同按照课程编号降序
select course_id, avg(score) avg_scorefrom scoregroup by course_idorder by avg_score,course_id desc;-- 统计参加考试人数大于等于 15 的学科
select course_id,count(*) as stu_count from score group by course_id having stu_count > 15;-- 查询学生总成绩并按照总成绩降序排序
select stu_id, sum(score) sum_scorefrom scoregroup by stu_idorder by sum_score desc;-- 按照指定格式显示 stu_id 语文 数学 英语 选课数 平均成绩
selects.stu_id,sum(`if`(c.course_name='语文',score,0)) as `语文`,sum(`if`(c.course_name='数学',score,0)) as `数学`,sum(`if`(c.course_name='英语',score,0)) as `英语`,count(s.course_id) as `选课数`,avg(s.score) as `平均成绩`from course c left join score son c.course_id = s.course_idgroup by s.stu_idorder by `平均成绩` desc;-- 查询一共参加了三门功课且其中一门为语文的学生id 和 姓名
select s.stu_id,stu_name from
(select t1.stu_id ,count(t1.course_id) course_count  from(select stu_id,course_id from scorewhere stu_id in ( select stu_id from score where course_id = "01")) t1 group by  t1.stu_id having course_count >=3
) t2 join student s on t2.stu_id = s.stu_id;
-- 分解
-- 查询该学生的姓名
select s.stu_id,stu_name from
-- 成绩表中学习科目数量 >=3 科的学生
(select t1.stu_id ,count(t1.course_id) course_count  from--  报名了语文的学生还报名了那些学科(select stu_id,course_id from scorewhere stu_id in (-- 查询报名了语文的学生IDselect stu_id from score where course_id = "01")) t1 group by  t1.stu_id having course_count >=3
) t2 join student s on t2.stu_id = s.stu_id;-- 查询两门以上的课程不及格学生的学号及其平均成绩
-- 1、先按照学生分组 过滤出成绩低于60的数量 大于1
-- 2、计算所有学生的平均成绩
-- 3、两个子查询相互join
select  t1.stu_id,t2.avg_score from
(select stu_id, sum(if(score < 60, 1, 0)) as result from score group by stu_id having result > 1) t1left join
(select stu_id,avg(score) as avg_score from score group by stu_id) t2 on t1.stu_id =t2.stu_id;-- 查询所有学生的学号、姓名、选课数、总成绩
selectstu.stu_id,stu.stu_name,count(s.course_id) count_course ,nvl(sum(s.score),0) total_score
from student stu left join score s on stu.stu_id = s.stu_id
group by stu.stu_id, stu.stu_name order by stu.stu_id;-- 平均成绩大于 85 的所有学生的学号、姓名、平均成绩
selectstu.stu_id,stu.stu_name ,nvl(avg(s.score),0) as `avg_score`
from student stu left join score s on stu.stu_id = s.stu_id
group by stu.stu_id, stu.stu_name having nvl(avg(s.score),0) > 85 order by stu.stu_id-- 查询学生的选课情况:学号,姓名,课程号,课程名称
select student.stu_id,student.stu_name,c.course_id,c.course_name from student
right join score s on student.stu_id = s.stu_id
left join course c on s.course_id = c.course_id-- 查询学生的没有选课情况:学号,姓名
select stu_id,stu_name from
(
select student.stu_id,student.stu_name, s.course_id from student
left join score s on student.stu_id = s.stu_id
left join course c on s.course_id = c.course_id
) t where course_id is null-- 查询出每门课程的及格人数和不及格人数
select c.course_id,course_name,pass,fail
from course c join
(
selectcourse_id,sum(if(score >= 60,1,0)) as `pass`, sum(if(score < 60,1,0)) as `fail`from score group by course_id
) t on c.course_id = t.course_id-- 查询课程编号为03且课程成绩在80分以上的学生的学号和姓名及课程信息
select t1.stu_id,s.stu_name,t1.course_id,c.course_name,t1.score from
(select * from score where course_id = '03' and score > 80) t1
left join student s on s.stu_id = t1.stu_id
left join course c on t1.course_id = c.course_id-- 查询语文成绩低于平均分数的学生是谁,教师是谁
select t3.stu_id,t3.stu_name,t3.`avg_score`,t.tea_name from
(select t2.stu_id,t2.`avg_score`,s.stu_name,t2.course_id,c.tea_id from(select t1.stu_id,t1.course_id,t1.`avg_score` from(select stu_id,s.course_id, avg(score) as `avg_score` from score s right join(select course_id from course where course_name = '语文') t1 on t1.course_id = s.course_idgroup by stu_id,s.course_id) t1where t1.`avg_score` < (select avg(score) as `avg_score` from score s right join (select course_id from course where course_name = '语文') t1 on t1.course_id = s.course_id)) t2 left join student s on t2.stu_id = s.stu_idleft join course c on t2.course_id = c.course_id
)t3 left join teacher t on t3.tea_id = t.tea_id;-- 查询所有学生总成绩和平均成绩,
-- 且他们的总成绩低于平均成绩的有多少个人,
-- 高于平均成绩的有多少人,
-- 低于平均成绩的男生和女生分别有多少人,
-- 且他们的任课老师是谁。-- 统计各科成绩各分数段人数:课程编号,课程名称,[100-85],[85-75],[70-60],[0-60]及所占百分比
select c.course_id, course_name, a, b, c, d from course c left join (select course_id,concat(round((sum(`if`(score >= 85,1,0)) / count(*)) * 100,2), '%') as a,concat(round((sum(`if`(score between 75 and 84,1,0)) / count(*)) * 100,2), '%') as b,concat(round((sum(`if`(score between 60 and 74,1,0)) / count(*)) * 100,2), '%') as c,concat(round((sum(`if`(score < 60,1,0)) / count(*)) * 100,2), '%') as dfrom score group by course_id
) t on t.course_id = c.course_id;-- 查询各科成绩最高分、最低分和平均分,以如下形式显示:
-- 课程ID,课程name,最高分,最低分,平均分,中下率,中等率,优良率,优秀率
-- 及格为>=60,中等为:70-80,优良为:80-90,优秀为:>=90
select c.course_id, course_name, `最高分`,`最低分`,`平均分`,`优秀率`, `优良率`, `中等率`, `中下率`,`芸芸众生` from course c left join (select course_id,max(score) `最高分`,min(score) `最低分`,round(avg(score),2) `平均分`,concat(round((sum(`if`(score >= 90,1,0)) / count(*)) * 100,2), '%') as `优秀率`,concat(round((sum(`if`(score between 80 and 89,1,0)) / count(*)) * 100,2), '%') as `优良率`,concat(round((sum(`if`(score between 70 and 79,1,0)) / count(*)) * 100,2), '%') as `中等率`,concat(round((sum(`if`(score between 60 and 69,1,0)) / count(*)) * 100,2), '%') as `中下率`,concat(round((sum(`if`(score < 60,1,0)) / count(*)) * 100,2), '%') as `芸芸众生`from score group by course_id
) t on t.course_id = c.course_id;-- 查询每门课程的男生和女生的比例是多少
select t1.course_id,t1.gender, concat(round((count_gender / count_course_student) * 100,2), '%') as proportion from(select course_id,gender,count(*) count_gender from score s1 inner join student s2 on s1.stu_id = s2.stu_id group by course_id,gender) t1inner join(select course_id,count(*) count_course_student from score s1 inner join student s2 on s1.stu_id = s2.stu_id group by course_id) t2on t2.course_id = t1.course_id;-- 每门学科的成绩是男生比较优一些还是女生比较优一些,并且每门课程的最高分是谁。
select battle_t.course_id,male_avg_score, female_avg_score, battle, max_stu_id,min_stu_id, max_score, min_score from(select male_t.course_id,round(male_avg_score,2) male_avg_score,round(female_avg_score,2) female_avg_score,casewhen male_avg_score > female_avg_score then '男性优秀'when male_avg_score < female_avg_score then '女性优秀'else '势均力敌'end battlefrom(select course_id,avg(score) male_avg_score from score s1 inner join student s2 on s1.stu_id = s2.stu_id and gender = '男' group by course_id) male_tinner join(select course_id,avg(score) female_avg_score from score s1 inner join student s2 on s1.stu_id = s2.stu_id and gender = '女' group by course_id) female_ton male_t.course_id = female_t.course_id) battle_tinner join(select max_t.course_id,max_t.stu_id max_stu_id,max_score,min_t.stu_id min_stu_id,min_score from(select stu_id, s.course_id, max_score from score sinner join(select course_id, max(score) max_score from score group by course_id) ton s.course_id = t.course_id and max_score = score) max_tfull join(select stu_id, s.course_id, min_score from score sinner join(select course_id,min(score) min_score from score group by course_id) ton s.course_id = t.course_id and min_score = score) min_ton max_t.course_id = min_t.course_id) infoon battle_t.course_id = info.course_id;-- 课程编号为"01"且课程分数小于60,按分数降序排列的学生信息select s.stu_id, stu.stu_name, stu.birthday, stu.gender,s.scorefrom score s join student stu on s.stu_id = stu.stu_idwhere s.score < 60  order by s.score desc;-- 查询所有课程成绩在70分以上的学生的姓名、课程名称和分数,按分数升序
select stu.stu_name, c.course_name, s2.scorefrom student stu join(select s.stu_id, sum(`if`(s.score >= 70, 0, 1)) as `is_ok` from score s group by s.stu_id having is_ok = 0) t1on stu.stu_id = t1.stu_id left join score s2 on stu.stu_id = s2.stu_id left join course c on s2.course_id = c.course_idorder by s2.score;-- 查询某学生不同课程的成绩相同的学生编号、课程编号、学生成绩
select s1.stu_id,collect_list(s1.course_id) as course_id,collect_set(s1.score) as scorefrom score s1 join score s2 on s1.stu_id = s2.stu_idand s1.course_id != s2.course_idand s1.score == s2.scoregroup by s1.stu_id;

分组排序取TopN

查询各科成绩前五名的学生

select a.course_id,a.stu_id,a.score from score aleft join score bon a.course_id = b.course_id and a.score <= b.scoregroup by a.stu_id,a.course_id,a.scorehaving count(a.stu_id) <=5order by a.course_id,a.score desc;
select S1.course_id,s1.stu_id,s1.score from score s1 where(select count(*) from score s2where s2.course_id=s1.course_id AND s2.score > s1.score) <= 5 order by s1.course_id,s1.score desc;

row_number

row_number() over () 连续序号
over()里头的分组以及排序的执行晚于 where 、group by、order by 的执行。

select * from(select course_id, stu_id,  score,row_number() over (partition by course_id order by score desc ) as mumfrom score) t where mum <= 5;

rank

rank() over () 排名 跳跃排序 序号不是连续的

select * from(select course_id, stu_id,  score,rank() over (partition by course_id order by score desc ) as mumfrom score) t where mum <= 5;

dense_rank

dense_rank() over () 排名 连续排序

select * from(select course_id, stu_id,  score,dense_rank() over (partition by course_id order by score desc ) as mumfrom score) t where mum <= 5;

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

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

相关文章

WMS重力式货架库位对应方法

鉴于重力式货架的特殊结构和功能&#xff0c;货物由高的一端存入&#xff0c;滑至低端&#xff0c;从低端取出。所以重力式货架的每个货位在物理上都会有一个进货口和一个出货口。因此&#xff0c;在空间上&#xff0c;对同一个货位执行出入库操作需要处于不同的位置。 比如对…

使用python将多个PDF文件合并成一个

使用python将多个PDF文件合并成一个 前面需求是&#xff0c;将很多PDF文章内容整合成一个PDF文件 首先你要 pip install PyPDF2 安装好这个组件库 然后使用下面的代码 from PyPDF2 import PdfReader, PdfMerger import oswk_in_file_path rD:/items_python/pdfdoc/input/ #里…

【2023年csp-j第二轮】第一题解析

我们先看题目 题目描述 小 Y 的桌子上放着 n 个苹果从左到右排成一列&#xff0c;编号为从 11到 n。 小苞是小 Y 的好朋友&#xff0c;每天她都会从中拿走一些苹果。 每天在拿的时候&#xff0c;小苞都是从左侧第 1 个苹果开始、每隔 2 个苹果拿走 1 个苹果。随后小苞会将剩下的…

PostgreSQL 数据定义语言 DDL

文章目录 表创建主键约束非空唯一约束检查约束外键约束默认值约束 触发器表空间构建表空间 视图索引索引的基本概念索引的分类创建索引 物化视图 表创建 PostgreSQL表的构建语句与所有数据库都一样&#xff0c;结构如下&#xff0c;其核心在于构建表时&#xff0c;要指定上一些…

【算法挨揍日记】day29——139. 单词拆分、467. 环绕字符串中唯一的子字符串

139. 单词拆分 139. 单词拆分 题目描述&#xff1a; 给你一个字符串 s 和一个字符串列表 wordDict 作为字典。请你判断是否可以利用字典中出现的单词拼接出 s 。 注意&#xff1a;不要求字典中出现的单词全部都使用&#xff0c;并且字典中的单词可以重复使用。 解题思路&am…

(免费领源码)python+django+mysql线上兼职平台系统83320-计算机毕业设计项目选题推荐

摘 要 信息化社会内需要与之针对性的信息获取途径&#xff0c;但是途径的扩展基本上为人们所努力的方向&#xff0c;由于站在的角度存在偏差&#xff0c;人们经常能够获得不同类型信息&#xff0c;这也是技术最为难以攻克的课题。针对线上兼职等问题&#xff0c;对线上兼职进行…

【如何学习Python自动化测试】—— 页面元素定位

接上篇自动化测试环境搭建&#xff0c;现在我们介绍 webdriver 对浏览器操作的 API。 2、 页面元素定位 通过自动化操作 web 页面&#xff0c;首先要解决的问题就是定位到要操作的对象&#xff0c;比如要模拟用户在页面上的输入框中输入一段字符串&#xff0c;那就必须得定位到…

milvus数据库索引管理

一、建立向量索引 默认情况下&#xff0c;Milvus不会对小于1,024行的段进行索引。 1.准备索引参数 index_params {"metric_type":"L2","index_type":"IVF_FLAT","params":{"nlist":1024} } #"nlist"…

YOLOv8改进 | 如何在网络结构中添加注意力机制、C2f、卷积、Neck、检测头

一、本文介绍 本篇文章的内容是在大家得到一个改进版本的C2f一个新的注意力机制、或者一个新的卷积模块、或者是检测头的时候如何替换我们YOLOv8模型中的原有的模块&#xff0c;从而用你的模块去进行训练模型或者检测。因为最近开了一个专栏里面涉及到挺多改进的地方&#xff…

CSS特效014:模仿钟摆效果

CSS常用示例100专栏目录 本专栏记录的是经常使用的CSS示例与技巧&#xff0c;主要包含CSS布局&#xff0c;CSS特效&#xff0c;CSS花边信息三部分内容。其中CSS布局主要是列出一些常用的CSS布局信息点&#xff0c;CSS特效主要是一些动画示例&#xff0c;CSS花边是描述了一些CSS…

buuctf-web-p6 [NPUCTF2020]web 狗

java: HelloWorld.class import java.io.PrintStream;public class HelloWorld {public static void main(String[] paramArrayOfString){System.out.println("众所周知&#xff0c;你是一名WEB选手&#xff0c;掌握javaweb也是一项必备技能&#xff0c;那么逆向个java应…

Shell脚本:Linux Shell脚本学习指南(第一部分Shell基础)一

你好&#xff0c;欢迎来到「Linux Shell脚本」学习专题&#xff0c;你将享受到免费的 Shell 编程资料&#xff0c;以及很棒的浏览体验。 这套 Shell 脚本学习指南针对初学者编写&#xff0c;它通俗易懂&#xff0c;深入浅出&#xff0c;不仅讲解了基本知识&#xff0c;还深入底…

高阶数据结构---树状数组

文章目录 楼兰图腾一个简单的整数问题 一个简单的整数问题2谜一样的牛 一、楼兰图腾OJ链接 二、一个简单的整数问题OJ链接 三、一个简单的整数问题2OJ链接 四、谜一样的牛OJ链接

云原生微服务架构图

云原生微服务架构的具体架构图会根据应用程序的需求、规模和业务场景而有所不同。以下是一个通用的云原生微服务架构图&#xff0c;具体每层的组件可能有所不同&#xff1a; 用户界面层&#xff1a; Web应用或移动应用&#xff1a; 提供用户访问和交互的前端应用。API Gateway&…

【深度学习实验】网络优化与正则化(六):逐层归一化方法——批量归一化、层归一化、权重归一化、局部响应归一化

文章目录 一、实验介绍二、实验环境1. 配置虚拟环境2. 库版本介绍 三、优化算法0. 导入必要的库1. 随机梯度下降SGD算法a. PyTorch中的SGD优化器b. 使用SGD优化器的前馈神经网络 2.随机梯度下降的改进方法a. 学习率调整b. 梯度估计修正 3. 梯度估计修正&#xff1a;动量法Momen…

Elasticsearch 应用

Elasticsearch 的应用 本文使用的版本为&#xff1a;7.14.0 todo:前端部分 Kibana的开发工具 IK分词器粗粒度 # 请求,通过【ik_smart】最粗粒度划分 GET _analyze {"analyzer": "ik_smart","text":"中国共产党" }# 返回 {"to…

Linux:进程替换和知识整合

文章目录 进程程序替换替换原理进程替换的理解 环境变量与进程替换命令行解释器实现逻辑 进程程序替换 前面已经学习了子进程的创建&#xff0c;但是子进程的创建不管怎么说&#xff0c;都是父进程代码的一部分&#xff0c;那么实际上如果想要子进程执行新的程序呢&#xff1f…

GDPU 数据结构 天码行空10

目录 数据结构实验十 树遍历应用一、【实验目的】二、【实验内容】三、【实验源代码】⭐ CPP版⭐ c语言版 四、实验结果 数据结构实验十 树遍历应用 一、【实验目的】 1、了解树的建立方法 2、掌握树与二叉树的转化及其遍历的基本方法 3、掌握递归二叉树遍历算法的应用 二、…

UiPath Studio 2023.10 Crack

UiPath Studio是一款功能强大且用户友好的集成开发环境 (IDE)&#xff0c;专为机器人流程自动化 (RPA) 设计。它由自动化技术领域的领先公司UiPath开发。 以下是 UiPath Studio 的一些主要功能和组件&#xff1a; 图形用户界面 (GUI)&#xff1a;UiPath Studio 具有直观且用户友…

【机器学习】 逻辑回归算法:原理、精确率、召回率、实例应用(癌症病例预测)

1. 概念理解 逻辑回归&#xff0c;简称LR&#xff0c;它的特点是能够将我们的特征输入集合转化为0和1这两类的概率。一般来说&#xff0c;回归不用在分类问题上&#xff0c;但逻辑回归却能在二分类(即分成两类问题)上表现很好。 逻辑回归本质上是线性回归&#xff0c;只是在特…