
python机器学习及实战
llx1026
愿在人工智能界找到自己的一席之地。。。
展开
-
显示手写体数字图片经PCA压缩后的二维空间分布
import pandas as pdimport numpy as npdigits_train = pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/optdigits/optdigits.tra', header=None)digits_test = pd.read_csv('https://原创 2017-09-14 08:39:12 · 1317 阅读 · 0 评论 -
使用三种继承回归模型对美国波士顿房价训练数据进行学习,并对测试数据进行预测
from sklearn.model_selection import train_test_splitx_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.25, random_state=33)#25%数据用于测试,75%数据用于训练from sklearn.preprocessing import原创 2017-09-12 22:00:39 · 1882 阅读 · 0 评论 -
使用回归树对美国波士顿房价训练数据进行学习,并对测试数据进行预测
from sklearn.datasets import load_bostonboston = load_boston()#加载boston数据集import numpy as npx = boston.datay = boston.targetfrom sklearn.model_selection import train_test_splitx_train, x_test,原创 2017-09-12 21:41:25 · 2729 阅读 · 1 评论 -
使用两种不同配置的K近邻回归模型对美国波士顿房价数据进行回归预测
from sklearn.datasets import load_bostonimport numpy as npboston = load_boston()x = boston.datay = boston.targetfrom sklearn.model_selection import train_test_splitx_train, x_test, y_train, y_t原创 2017-09-12 20:50:24 · 957 阅读 · 0 评论 -
使用Tensorflow自定义一个线性分类器用于对“良/恶性乳腺癌肿瘤”进行预测
import tensorflow as tfimport numpy as npimport pandas as pdtrain = pd.read_csv('breast-cancer-train.csv')test = pd.read_csv('breast-cancer-test.csv')#分割特征与分类目标x_train = np.float32(train[['Clu原创 2017-09-20 17:04:01 · 818 阅读 · 0 评论 -
利用sklearn中的支持向量机回归模型(linear,poly,rbf三种核)对boston房价进行预测并作出评估
from sklearn.datasets import load_bostonboston = load_boston()print(boston.DESCR)import numpy as pdx = boston.datay = boston.targetfrom sklearn.model_selection import train_test_splitx_train,原创 2017-09-12 11:04:29 · 14257 阅读 · 0 评论 -
针对python机器学习与实战代码在python3上运行出现的错误分析和warning的修改代码34—38
#导入model_selection进行数据分割from sklearn.model_selection import train_test_splitimport numpy as npx = boston.datay = boston.targetx_train, x_test, y_train, y_test = train_test_split(x, y , test_size原创 2017-09-12 08:43:29 · 15296 阅读 · 7 评论 -
运行代码,出现TypeError: fit() missing 1 required positional argument: 'y',对其进行修改
from sklearn.datasets import load_bostonboston = load_boston()print(boston.DESCR)#导入model_selection进行数据分割from sklearn.model_selection import train_test_splitimport numpy as npx = boston.datay原创 2017-09-12 08:35:58 · 87671 阅读 · 1 评论 -
windows-64下安装xgboost
在这里安装的xgboost不需要在VS下进行编译,很简单先在http://www.lfd.uci.edu/~gohlke/pythonlibs/#xgboost下载对应版本的xgboost,将下载的xgboost-0.6-cp36-cp36m-win_amd64.whl放在合适的地方,根据自己的喜好然后打开电脑终端,在电脑里输入如下内容,注意路径根据自己的需要进行修改:这样就可原创 2017-09-19 21:35:41 · 393 阅读 · 0 评论 -
windows系统64位—在python3下安装nltk
在网上找了各种安装教程,都没有在python3下安装nltk,于是我自己尝试着安装,算是成功了1、首先,假设你的python3已经安装好,并且安装了numpy,matplotlib,pandas一些常用的库,当你安装nltk时,我相信你一定具备了一些python的常用技能,所以默认你已经安装了以上常用模块2、然后,用cmd打开电脑终端,然后输入D:\Python362\Scripts\pi原创 2017-09-19 20:28:53 · 3388 阅读 · 0 评论 -
使用单线程对文本分类的朴素贝叶斯模型的超参数组合执行网络搜索
from sklearn.datasets import fetch_20newsgroupsimport numpy as npnews = fetch_20newsgroups(subset='all')from sklearn.model_selection import train_test_splitx_train, x_test, y_train, y_test = trai原创 2017-09-19 18:01:02 · 884 阅读 · 1 评论 -
python机器学习及实战代码13-16,程序运行时出现提醒及修改
import pandas as pdimport numpy as npcolumn_names = ['Sample code number', 'Clump Thickness', 'Uniformity of Cell Size', 'Uniformity of Cell Shape', 'Marginal Adhesion', 'Single Epithelial Cell Siz原创 2017-09-10 10:38:24 · 1153 阅读 · 0 评论 -
python机器学习及实战-Python基础综合实践
#读取数据import pandas as pddf_train = pd.read_csv('breast-cancer-train.csv')df_test = pd.read_csv('breast-cancer-test.csv')#print(df_train.info())#print(df_test.info())df_test_negative = df_test.原创 2017-09-09 21:47:42 · 713 阅读 · 0 评论 -
python机器学习与实战中运行代码出现警告的处理
import pandas as pdimport numpy as npcolumn_names = ['Sample code number', 'Clump Thickness', 'Uniformity of Cell Size', 'Uniformity of Cell shape', 'Marginal Adhesion','Single Epithelial Cell Size原创 2017-08-31 14:50:47 · 2089 阅读 · 0 评论 -
分别使用1次,2次,4次多项式回归模型在比萨训练样本上进行拟合
import matplotlib.pyplot as pltx_train = [[6], [8], [10], [14], [18]]y_train = [[7], [9], [13], [17.5], [18]]from sklearn.linear_model import LinearRegressionregressor = LinearRegression()regre原创 2017-09-15 13:26:21 · 3382 阅读 · 0 评论 -
使用线性回归模型在比萨训练样本上进行拟合
训练数据和测试数据代码:x_train = [[6], [8], [10], [14], [18]]y_train = [[7], [9], [13], [17.5], [18]]from sklearn.linear_model import LinearRegressionregressor = LinearRegression()regressor.fit(x_train,原创 2017-09-15 10:52:09 · 801 阅读 · 0 评论 -
使用Titanic 数据集,通过特征筛选的方法一步步提升决策树的预测性能
运行python机器学习及实践代码59会出错,本人经过调试对其进行改进,主要原因是因为python 的版本不同,我的是python3源代码:import pandas as pdtitanic = pd.read_csv('http://biostat.mc.vanderbilt.edu/wiki/pub/Main/DataSets/titanic.txt')y = titanic[原创 2017-09-14 21:48:43 · 2601 阅读 · 3 评论 -
python3上skflow安装教程
本人之前按照网上的安装教程,一直安装不成功,后来索性自己尝试安装1、网上失败的安装过程,记录一下,以防重蹈覆辙第一,需要在https://github.com/tensorflow/skflow网站上下载skflow安装包,下载好之后放在python文件夹下第二,打开cmd终端,用cd/d+skflow路径将切换到setup.py文件夹下,如下图所示操作:然后按回车原创 2017-09-22 09:14:37 · 2513 阅读 · 0 评论