xuejieyu

数据可视化方法

数据可视化可以提供对数据的直观感受,这个有时是很难通过表格的形式把握到的。机器学习问题可以分为两类:回归问题与分类问题,两者的数据可视化有所区别。而本文将介绍分类问题的可视化方法。

 数据可视化的第一步就是获取数据,下面是用“岩石vs水雷数据集”为例,展示数据获取方法。

 1 import pandas as pd
 2 
 3 target_url = ("https://archive.ics.uci.edu/ml/machine-learning"
 4               "-databases/undocumented/connectionist-bench/sonar/sonar.all-data")
 5 
 6 df = pd.read_csv(target_url, header=None, prefix=\'V\')
 7 
 8 print("数据集规模:",df.shape)
 9 print("\n数据集类型:\n",df.get_dtype_counts())
10 print(df.describe())
getData

 运行结果如下:

代码解析:

  1. 该数据获取使用了python的pandas库,python3.7版本,urlllib2库已无法调用,过去的 urlopen()方法无法再用,使用pandas库的read_csv()的方法代替。
  2. . .shape
  3. .describe(): 生成简要的统计信息

 

分类:

技术点:

相关文章:

  • 2021-09-17
  • 2021-11-30
  • 2021-08-21
  • 2021-09-21
  • 2021-08-11
  • 2022-01-15
  • 2021-11-03
猜你喜欢
  • 2021-09-21
  • 2021-11-13
  • 2021-11-23
  • 2021-10-19
  • 2021-10-07
相关资源
相似解决方案