This commit is contained in:
2026-06-25 16:18:22 +08:00
parent 04c510a471
commit 59495f7500
13 changed files with 485 additions and 0 deletions

1
q3/q3_3_质量自评.md Normal file
View File

@@ -0,0 +1 @@

105
q4/q4_1/movies.json Normal file
View File

@@ -0,0 +1,105 @@
{
"ID": "B-20260625-3464",
"movies": [
{
"id": 1,
"title": "霸王别姬",
"director": "Frank Darabont",
"year": 2004,
"rating": 6.8,
"duration": 179,
"genre": "科幻",
"actors_count": 3
},
{
"id": 2,
"title": "放牛班的春天",
"director": "陈凯歌",
"year": 2019,
"rating": 6.7,
"duration": 117,
"genre": "喜剧",
"actors_count": 5
},
{
"id": 3,
"title": "泰坦尼克号",
"director": "Robert Zemeckis",
"year": 2015,
"rating": 9.1,
"duration": 177,
"genre": "爱情",
"actors_count": 4
},
{
"id": 4,
"title": "三傻大闹宝莱坞",
"director": "James Cameron",
"year": 2024,
"rating": 7.6,
"duration": 117,
"genre": "冒险",
"actors_count": 5
},
{
"id": 5,
"title": "阿甘正传",
"director": "宫崎骏",
"year": 2016,
"rating": 8.0,
"duration": 146,
"genre": "喜剧",
"actors_count": 3
},
{
"id": 6,
"title": "星际穿越",
"director": "Christopher Nolan",
"year": 2010,
"rating": 9.2,
"duration": 168,
"genre": "爱情",
"actors_count": 2
},
{
"id": 7,
"title": "忠犬八公的故事",
"director": "Lasse Hallström",
"year": 2016,
"rating": 9.3,
"duration": 106,
"genre": "悬疑",
"actors_count": 5
},
{
"id": 8,
"title": "肖申克的救赎",
"director": "Rajkumar Hirani",
"year": 2018,
"rating": 7.3,
"duration": 107,
"genre": "剧情",
"actors_count": 4
},
{
"id": 9,
"title": "千与千寻",
"director": "Christophe Barratier",
"year": 2019,
"rating": 7.3,
"duration": 118,
"genre": "动画",
"actors_count": 4
},
{
"id": 10,
"title": "盗梦空间",
"director": "Christopher Nolan",
"year": 2008,
"rating": 9.3,
"duration": 111,
"genre": "动画",
"actors_count": 5
}
]
}

19
q4/q4_1/q4_1.py Normal file
View File

@@ -0,0 +1,19 @@
import json
import matplotlib.pyplot as plt
movies = json.load(open('movies.json', encoding='utf-8'))['movies']
# print(movies)
genres = {}
for m in movies:
g = m['genre']
if g in genres:
genres[g] = genres[g] + 1
else:
genres[g] = 1
print(genres)
plt.figure(figsize=(8,5))
plt.bar(genres.keys(), genres.values())
plt.title('类型电影数量分布')
plt.xlabel('类型')
plt.ylabel('数量')
plt.savefig('q4_1_bar.png', dpi=150)

BIN
q4/q4_1/q4_1_bar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

105
q4/q4_2/movies.json Normal file
View File

@@ -0,0 +1,105 @@
{
"ID": "B-20260625-3464",
"movies": [
{
"id": 1,
"title": "霸王别姬",
"director": "Frank Darabont",
"year": 2004,
"rating": 6.8,
"duration": 179,
"genre": "科幻",
"actors_count": 3
},
{
"id": 2,
"title": "放牛班的春天",
"director": "陈凯歌",
"year": 2019,
"rating": 6.7,
"duration": 117,
"genre": "喜剧",
"actors_count": 5
},
{
"id": 3,
"title": "泰坦尼克号",
"director": "Robert Zemeckis",
"year": 2015,
"rating": 9.1,
"duration": 177,
"genre": "爱情",
"actors_count": 4
},
{
"id": 4,
"title": "三傻大闹宝莱坞",
"director": "James Cameron",
"year": 2024,
"rating": 7.6,
"duration": 117,
"genre": "冒险",
"actors_count": 5
},
{
"id": 5,
"title": "阿甘正传",
"director": "宫崎骏",
"year": 2016,
"rating": 8.0,
"duration": 146,
"genre": "喜剧",
"actors_count": 3
},
{
"id": 6,
"title": "星际穿越",
"director": "Christopher Nolan",
"year": 2010,
"rating": 9.2,
"duration": 168,
"genre": "爱情",
"actors_count": 2
},
{
"id": 7,
"title": "忠犬八公的故事",
"director": "Lasse Hallström",
"year": 2016,
"rating": 9.3,
"duration": 106,
"genre": "悬疑",
"actors_count": 5
},
{
"id": 8,
"title": "肖申克的救赎",
"director": "Rajkumar Hirani",
"year": 2018,
"rating": 7.3,
"duration": 107,
"genre": "剧情",
"actors_count": 4
},
{
"id": 9,
"title": "千与千寻",
"director": "Christophe Barratier",
"year": 2019,
"rating": 7.3,
"duration": 118,
"genre": "动画",
"actors_count": 4
},
{
"id": 10,
"title": "盗梦空间",
"director": "Christopher Nolan",
"year": 2008,
"rating": 9.3,
"duration": 111,
"genre": "动画",
"actors_count": 5
}
]
}

17
q4/q4_2/q4_2.py Normal file
View File

@@ -0,0 +1,17 @@
import json
import matplotlib.pyplot as plt
movies = json.load(open('movies.json', encoding='utf-8'))['movies']
# print(movies)
ratings = []
durations = []
for m in movies:
ratings.append(m['rating'])
durations.append(m['duration'])
plt.figure(figsize=(8,5))
plt.scatter(durations,ratings,color='red',alpha=0.6)
plt.title('时长与评分关系散点图')
plt.xlabel('duration')
plt.ylabel('rating')
plt.savefig('q4_2_scatter.png', dpi=150)

BIN
q4/q4_2/q4_2_scatter.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

105
q4/q4_3a/movies.json Normal file
View File

@@ -0,0 +1,105 @@
{
"ID": "B-20260625-3464",
"movies": [
{
"id": 1,
"title": "霸王别姬",
"director": "Frank Darabont",
"year": 2004,
"rating": 6.8,
"duration": 179,
"genre": "科幻",
"actors_count": 3
},
{
"id": 2,
"title": "放牛班的春天",
"director": "陈凯歌",
"year": 2019,
"rating": 6.7,
"duration": 117,
"genre": "喜剧",
"actors_count": 5
},
{
"id": 3,
"title": "泰坦尼克号",
"director": "Robert Zemeckis",
"year": 2015,
"rating": 9.1,
"duration": 177,
"genre": "爱情",
"actors_count": 4
},
{
"id": 4,
"title": "三傻大闹宝莱坞",
"director": "James Cameron",
"year": 2024,
"rating": 7.6,
"duration": 117,
"genre": "冒险",
"actors_count": 5
},
{
"id": 5,
"title": "阿甘正传",
"director": "宫崎骏",
"year": 2016,
"rating": 8.0,
"duration": 146,
"genre": "喜剧",
"actors_count": 3
},
{
"id": 6,
"title": "星际穿越",
"director": "Christopher Nolan",
"year": 2010,
"rating": 9.2,
"duration": 168,
"genre": "爱情",
"actors_count": 2
},
{
"id": 7,
"title": "忠犬八公的故事",
"director": "Lasse Hallström",
"year": 2016,
"rating": 9.3,
"duration": 106,
"genre": "悬疑",
"actors_count": 5
},
{
"id": 8,
"title": "肖申克的救赎",
"director": "Rajkumar Hirani",
"year": 2018,
"rating": 7.3,
"duration": 107,
"genre": "剧情",
"actors_count": 4
},
{
"id": 9,
"title": "千与千寻",
"director": "Christophe Barratier",
"year": 2019,
"rating": 7.3,
"duration": 118,
"genre": "动画",
"actors_count": 4
},
{
"id": 10,
"title": "盗梦空间",
"director": "Christopher Nolan",
"year": 2008,
"rating": 9.3,
"duration": 111,
"genre": "动画",
"actors_count": 5
}
]
}

14
q4/q4_3a/q4_3a.py Normal file
View File

@@ -0,0 +1,14 @@
import json
import matplotlib.pyplot as plt
movies = json.load(open('movies.json', encoding='utf-8'))['movies']
# print(movies)
ratings = []
durations = []
for m in movies:
ratings.append(m['rating'])
durations.append(m['duration'])
plt.figure(figsize=(8,5))
plt.hist(ratings, bins=5,color='blue')
plt.savefig('q4_3a_hist.png',dpi=150)

BIN
q4/q4_3a/q4_3a_hist.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

105
q4/q4_3b/movies.json Normal file
View File

@@ -0,0 +1,105 @@
{
"ID": "B-20260625-3464",
"movies": [
{
"id": 1,
"title": "霸王别姬",
"director": "Frank Darabont",
"year": 2004,
"rating": 6.8,
"duration": 179,
"genre": "科幻",
"actors_count": 3
},
{
"id": 2,
"title": "放牛班的春天",
"director": "陈凯歌",
"year": 2019,
"rating": 6.7,
"duration": 117,
"genre": "喜剧",
"actors_count": 5
},
{
"id": 3,
"title": "泰坦尼克号",
"director": "Robert Zemeckis",
"year": 2015,
"rating": 9.1,
"duration": 177,
"genre": "爱情",
"actors_count": 4
},
{
"id": 4,
"title": "三傻大闹宝莱坞",
"director": "James Cameron",
"year": 2024,
"rating": 7.6,
"duration": 117,
"genre": "冒险",
"actors_count": 5
},
{
"id": 5,
"title": "阿甘正传",
"director": "宫崎骏",
"year": 2016,
"rating": 8.0,
"duration": 146,
"genre": "喜剧",
"actors_count": 3
},
{
"id": 6,
"title": "星际穿越",
"director": "Christopher Nolan",
"year": 2010,
"rating": 9.2,
"duration": 168,
"genre": "爱情",
"actors_count": 2
},
{
"id": 7,
"title": "忠犬八公的故事",
"director": "Lasse Hallström",
"year": 2016,
"rating": 9.3,
"duration": 106,
"genre": "悬疑",
"actors_count": 5
},
{
"id": 8,
"title": "肖申克的救赎",
"director": "Rajkumar Hirani",
"year": 2018,
"rating": 7.3,
"duration": 107,
"genre": "剧情",
"actors_count": 4
},
{
"id": 9,
"title": "千与千寻",
"director": "Christophe Barratier",
"year": 2019,
"rating": 7.3,
"duration": 118,
"genre": "动画",
"actors_count": 4
},
{
"id": 10,
"title": "盗梦空间",
"director": "Christopher Nolan",
"year": 2008,
"rating": 9.3,
"duration": 111,
"genre": "动画",
"actors_count": 5
}
]
}

14
q4/q4_3b/q4_3b.py Normal file
View File

@@ -0,0 +1,14 @@
import json
import matplotlib.pyplot as plt
movies = json.load(open('movies.json', encoding='utf-8'))['movies']
# print(movies)
ratings = []
durations = []
for m in movies:
ratings.append(m['rating'])
durations.append(m['duration'])
plt.figure(figsize=(8,5))
plt.hist(durations, bins=5,color='blue')
plt.savefig('q4_3b_hist.png',dpi=150)

BIN
q4/q4_3b/q4_3b_hist.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB