六种分类算法的比较 | 您所在的位置:网站首页 › 多分类问题用什么算法好 › 六种分类算法的比较 |
在这篇机器学习入门教程中,我们将使用Python中最流行的机器学习工具scikit- learn,在Python中实现几种机器学习算法。使用简单的数据集来训练分类器区分不同类型的水果。 水果数据集由爱丁堡大学的Iain Murray博士创建。他买了几十个不同种类的橘子、柠檬和苹果,并把它们的尺寸记录在一张桌子上。密歇根大学的教授们对水果数据进行了些微的格式化,可以从这里下载。 下载地址:https://github.com/susanli2016/Machine-Learning-with-Python/blob/master/fruit_data_with_colors.txt 让我们先看一看数据的前几行。 import numpy as np import pandas as pd import matplotlib.pyplot as plt fruits = pd.read_csv('fruit_data_with_colors.txt',sep='\t') print(fruits.head())
在数据集中有59个水果和7个特征: print(fruits.shape)(59, 7) 在数据集中有四种水果: print(fruits['fruit_name'].unique())[“苹果”柑橘”“橙子”“柠檬”] 除了柑橘,数据是相当平衡的。我们只好接着进行下一步。 print(fruits.groupby('fruit_name').size())
显示各属性的直方图 #显示各属性的直方图 import pylab as pl fruits.drop('fruit_label' ,axis=1).hist(bins=30, figsize=(9,9)) pl.suptitle("Histogram for each numeric input variable") plt.savefig('fruits_hist') plt.show()
|
今日新闻 |
推荐新闻 |
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 |