Python全系列 教程
3567个小节阅读:5930.9k
目录
鸿蒙应用开发
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
xxxxxxxxxx
41import numpy as np
2import pandas as pd
3import matplotlib.pyplot as plt
4import seaborn as sns
xxxxxxxxxx
51# 设置必要的环境
2# 设置图表支持中文
3plt.rcParams['font.family'] = ['Microsoft Yahei']
4# 设置图表支持负号
5plt.rcParams['axes.unicode_minus'] = False
x1# 加载训练集和测试集
2# 字段名
3headers = ['age', 'workclass', 'fnlwgt',
4 'education', 'education-num',
5 'marital-status', 'occupation',
6 'relationship', 'race', 'sex',
7 'capital-gain', 'capital-loss',
8 'hours-per-week', 'native-country',
9 'predclass']
10
11# 加载训练集
12training_raw = pd.read_csv('data/adult.data',
13 names=headers,
14 na_values=["?"])
15# 加载测试集
16test_raw = pd.read_csv('data/adult.test',
17 names=headers,
18 na_values=["?"],
19 skiprows=1)
xxxxxxxxxx
21training_raw.shape
2test_raw.shape
xxxxxxxxxx
11df = pd.concat([training_row, test_row], axis=0)
xxxxxxxxxx
21df.iloc[32559:32562]
2df.reset_index(drop=True)