posts - 189,comments - 1,views - 10万
03 2018 档案
转化非正态分布数据
摘要:在对数据进行线性拟合时,常常要求该变量满足正态分布,通常变量不满足或者正态分布拟合的不是很好。 如何把这些数据转换成正态分布的数据? 1.使用log()函数通常能使数据集向正态分布靠近。 若数据集中数据存在负数,则需要对数据进行预处理: 大致预处理如下:1)对数据进行归一化,即把数据映射到[0,1] 阅读全文
posted @ 2018-03-18 22:45 郑哲 阅读(2518) 评论(0) 推荐(0) 编辑
使用NetworkX来进行数据可视化
摘要:1 %matplotlib notebook 2 3 import networkx as nx 4 import matplotlib.pyplot as plt 5 6 # 数据读取 7 G = nx.read_gpickle('major_us_cities') 1 # draw the graph using the default spring layout 2 plt.fig... 阅读全文
posted @ 2018-03-15 16:34 郑哲 阅读(4660) 评论(0) 推荐(2) 编辑
使用NetworkX进行社交分析
摘要:邻接表 G_adjlist.txt is the adjaceny list representation of G1. It can be read as follows: 0 1 2 3 5 →→ node 0 is adjacent to nodes 1, 2, 3, 5 1 3 6 →→ n 阅读全文
posted @ 2018-03-15 14:55 郑哲 阅读(917) 评论(0) 推荐(0) 编辑
文本情感分析
摘要:CountVectorizer AUC: 0.889951006492 AUC: 0.889951006492 AUC: 0.889951006492 AUC: 0.889951006492 AUC: 0.889951006492 1 feature_names = np.array(vect.ge 阅读全文
posted @ 2018-03-15 13:48 郑哲 阅读(782) 评论(0) 推荐(0) 编辑
使用NLTK进行基础的NLP处理
摘要:1 import nltk 2 from nltk.book import * *** Introductory Examples for the NLTK Book *** Loading text1, ..., text9 and sent1, ..., sent9 Type the name 阅读全文
posted @ 2018-03-15 13:24 郑哲 阅读(1363) 评论(0) 推荐(1) 编辑
使用pandas对文本数据进行处理
摘要:1 import pandas as pd 2 3 time_sentences = ["Monday: The doctor's appointment is at 2:45pm.", 4 "Tuesday: The dentist's appointment is at 11:30 am.", 5 "Wed... 阅读全文
posted @ 2018-03-15 12:53 郑哲 阅读(2019) 评论(0) 推荐(0) 编辑
文本处理
摘要:['#UNSG'] ['#UNSG'] ['#UNSG'] ['#UNSG'] ['#UNSG'] 1 [w for w in text6 if w.startswith('@')] ['@'] 1 text7 = '@UN @UN_Women "Ethics are built right int 阅读全文
posted @ 2018-03-15 09:52 郑哲 阅读(194) 评论(0) 推荐(0) 编辑
分类器可视化
摘要:这本笔记本的目的是让你可视化各种分类器的决策边界。 本笔记本中使用的数据基于存储在mushrooms.csv中的UCI蘑菇数据集。 为了更好地确定决策边界,我们将对数据执行主成分分析(PCA)以将维度降至2维。 降维将在本课程后面的模块中介绍。 玩弄不同的模型和参数,看看它们如何影响分类器的决策边界 阅读全文
posted @ 2018-03-15 09:41 郑哲 阅读(2074) 评论(0) 推荐(0) 编辑
无监督学习
摘要:数据准备 降维和流形学习 PCA 使用PCA查找乳腺癌数据集的前两个主要组成部分 画出各个因素对两个主成分的影响大小 PCA用于水果数据集(用于比较) 多种学习方法 水果数据集上的多维缩放(MDS) 乳腺癌上的多维缩放 t-SNE on the fruit dataset (结果不是很好) t-SN 阅读全文
posted @ 2018-03-14 15:10 郑哲 阅读(553) 评论(0) 推荐(0) 编辑
监督学习2
摘要:序言和数据集 贝叶斯分类器 Application to a real-world dataset 决策树集成 随机森林 Random forest: Fruit dataset Random Forests on a real-world dataset Gradient-boosted deci 阅读全文
posted @ 2018-03-14 14:44 郑哲 阅读(482) 评论(0) 推荐(0) 编辑
模型验证
摘要:对分类模型的检验 加载数据 Decision tree classifier (max_depth = 2) [[400 7] [ 17 26]] Decision tree classifier (max_depth = 2) [[400 7] [ 17 26]] Decision tree cl 阅读全文
posted @ 2018-03-12 10:16 郑哲 阅读(612) 评论(0) 推荐(0) 编辑
监督学习模型(线性回归,非线性回归,逻辑回归,SVM,决策树,岭回归,Losso回归)
摘要:一.数据产生 KNN分类 KNN回归预测 KNN参数k对回归预测的影响 线性回归预测模型 线性回归图示 多元线性回归预测 岭回归 Lasso 回归 逻辑回归正则化参数的影响 应用于真实数据 SVM 线性SVM Linear Support Vector Machine: C parameter 线性 阅读全文
posted @ 2018-03-11 22:57 郑哲 阅读(4479) 评论(0) 推荐(0) 编辑
关于xgboost找不到指定模块
摘要:解决方法: 阅读全文
posted @ 2018-03-10 13:51 郑哲 阅读(510) 评论(0) 推荐(0) 编辑
一个简单的分类模型knn
摘要:knn中聚类个数k对最后准确率的影响 knn对数据集train/test划分比例的敏感性 阅读全文
posted @ 2018-03-10 12:14 郑哲 阅读(1425) 评论(0) 推荐(0) 编辑
Seaborn
摘要:1 import numpy as np 2 import pandas as pd 3 import matplotlib.pyplot as plt 4 import seaborn as sns 5 6 %matplotlib notebook 1 np.random.seed(1234) 2 3 v1 = pd.Series(np.random.normal(0,10,1000)... 阅读全文
posted @ 2018-03-09 21:32 郑哲 阅读(341) 评论(0) 推荐(0) 编辑
Pandas可视化
摘要:DataFrame.plot 我们可以设置plot函数中的kind来决定我们想画什么 下面列举kind的的可选值 kind : 'line' : 直线(默认) 'bar' : 垂直条形图 'barh' : 水平条形图 'hist' : 直方图 'box' : 箱型图 'kde' : 核密度估计图 ' 阅读全文
posted @ 2018-03-09 21:18 郑哲 阅读(232) 评论(0) 推荐(0) 编辑
交互性(Interactivity)
摘要:1 plt.figure() 2 data = np.random.rand(10) 3 plt.plot(data) 4 #创建点击事件 5 def onclick(event): 6 plt.cla() 7 plt.plot(data) 8 plt.gca().set_title('Event at pixels {},{} \nand data {}... 阅读全文
posted @ 2018-03-09 20:50 郑哲 阅读(1109) 评论(0) 推荐(0) 编辑
动画(animation)
摘要:1 import matplotlib.animation as animation 2 3 n = 100 4 x = np.random.randn(n) 1 # create the function that will do the plotting, where curr is the current frame 2 def update(curr): 3 # ch... 阅读全文
posted @ 2018-03-09 20:44 郑哲 阅读(242) 评论(0) 推荐(0) 编辑
热图
摘要:1 plt.figure() 2 3 Y = np.random.normal(loc=0.0, scale=1.0, size=10000) 4 X = np.random.random(size=10000) #bins设置区间大小 5 _ = plt.hist2d(X, Y, bins=25) 1 plt.figure() 2 _ = plt.hist2d(X, Y, bins=1... 阅读全文
posted @ 2018-03-09 20:40 郑哲 阅读(195) 评论(0) 推荐(0) 编辑
箱型图
摘要:1 import pandas as pd 2 normal_sample = np.random.normal(loc=0.0, scale=1.0, size=10000) 3 random_sample = np.random.random(size=10000) 4 gamma_sample = np.random.gamma(2, size=10000) 5 6 #创建新... 阅读全文
posted @ 2018-03-09 20:34 郑哲 阅读(393) 评论(0) 推荐(0) 编辑
直方图
摘要:在图像上直方图和条形图相似,但是直方图是用来统计数据在某个值上的数量。 阅读全文
posted @ 2018-03-09 20:10 郑哲 阅读(358) 评论(0) 推荐(0) 编辑
图标位置
摘要:True 阅读全文
posted @ 2018-03-09 19:53 郑哲 阅读(171) 评论(0) 推荐(0) 编辑
柱形图
摘要:用线性数据画柱状图 1 plt.figure() 2 xvals = range(len(linear_data)) 3 plt.bar(xvals, linear_data, width = 0.3) 4 5 new_xvals = [] 6 7 # 创建new_xvals使横坐标向右移动0.3,用平方数据画红色的柱状图 8 for item in xvals: 9 ... 阅读全文
posted @ 2018-03-09 19:41 郑哲 阅读(200) 评论(0) 推荐(0) 编辑
Plots画线
摘要:错误代码 阅读全文
posted @ 2018-03-09 19:22 郑哲 阅读(172) 评论(0) 推荐(0) 编辑
Scatterplots画点
摘要:1 import numpy as np 2 3 x = np.array([1,2,3,4,5,6,7,8]) 4 y = x 5 6 plt.figure() 7 plt.scatter(x, y) # similar to plt.plot(x, y, '.'), but the underlying child objects in the axes are not Line2D ... 阅读全文
posted @ 2018-03-09 18:47 郑哲 阅读(654) 评论(0) 推荐(0) 编辑
matplotlib基础画线
摘要:%%html<img src='test.png' /> 阅读全文
posted @ 2018-03-06 15:38 郑哲 阅读(311) 评论(0) 推荐(0) 编辑
数据拷贝
摘要:1 r2 = r[:3,:3] 2 r2 array([[ 0, 1, 2], [ 6, 7, 8], [12, 13, 14]]) 1 r2[:] = 0 2 r2 array([[0, 0, 0], [0, 0, 0], [0, 0, 0]])此时r= array([[ 0, 0, 0, 3, 阅读全文
posted @ 2018-03-05 20:27 郑哲 阅读(185) 评论(0) 推荐(0) 编辑
数组索引
摘要:1 s = np.arange(13)**2 2 s array([ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144]) 1 s[0], s[4], s[-1] (0, 16, 144) 1 s[1:5] array([ 1, 4, 9, 16]) 阅读全文
posted @ 2018-03-05 20:24 郑哲 阅读(201) 评论(0) 推荐(0) 编辑
数组函数
摘要:1 a = np.array([-4, -2, 1, 3, 5]) 2 a.sum() 3 1 a.max() 5 1 a.min() -4 1 a.mean() 0.60 1 a.std() 3.26 1 a.argmax() 4 1 a.argmin() 0 阅读全文
posted @ 2018-03-05 20:19 郑哲 阅读(105) 评论(0) 推荐(0) 编辑
数组操作符
摘要:1 print(x + y) # elementwise addition [1 2 3] + [4 5 6] = [5 7 9] 2 print(x - y) # elementwise subtraction [1 2 3] - [4 5 6] = [-3 -3 -3] [5 7 9] [-3 阅读全文
posted @ 2018-03-05 20:17 郑哲 阅读(117) 评论(0) 推荐(0) 编辑
numpy
摘要:1 import numpy as np %通过链表创建数组1 mylist = [1, 2, 3] 2 x = np.array(mylist) 3 x array([1, 2, 3]) %直接创建数组1 y = np.array([4, 5, 6]) 2 y array([4, 5, 6]) %创建多维数组1 m = np.array([[7, 8, 9], [10, 11,... 阅读全文
posted @ 2018-03-05 20:13 郑哲 阅读(113) 评论(0) 推荐(0) 编辑
λ和列表解析
摘要:%下面是lambda的示例,它包含三个参数并添加前两个参数。1 my_function = lambda a, b, c : a + b 2 my_function(1, 2, 3) 3 1 my_list = [] 2 for number in range(0, 1000): 3 if numb 阅读全文
posted @ 2018-03-05 20:03 郑哲 阅读(112) 评论(0) 推荐(0) 编辑
object和map
摘要:1 class Person: 2 department = 'School of Information' #a class variable 3 4 def set_name(self, new_name): #a method 5 self.name = new_name 6 def set_ 阅读全文
posted @ 2018-03-05 20:00 郑哲 阅读(111) 评论(0) 推荐(0) 编辑
日期Dates时间Times
摘要:1 import datetime as dt 2 import time as tm %时间从纪元开始以秒为单位返回当前时间。(1970年1月1日)1 tm.time() 1520242063.03 1 dtnow = dt.datetime.fromtimestamp(tm.time()) 2 阅读全文
posted @ 2018-03-05 19:56 郑哲 阅读(223) 评论(0) 推荐(0) 编辑
csv文件的读写
摘要:Let's import our datafile mpg.csv, which contains fuel economy data for 234 cars. mpg : miles per gallon class : car classification cty : city mpg cyl 阅读全文
posted @ 2018-03-05 19:53 郑哲 阅读(494) 评论(0) 推荐(0) 编辑
更多关于字符串string
摘要:1 print('Chris' + 2) TypeError Traceback (most recent call last) <ipython-input-37-82ccfdd3d5d3> in <module>() > 1 print('Chris' + 2) TypeError: must 阅读全文
posted @ 2018-03-05 19:32 郑哲 阅读(112) 评论(0) 推荐(0) 编辑
解压序列
摘要:%解压序列到不同的变量中1 x = ('Christopher', 'Brooks', 'brooksch@umich.edu') 2 fname, lname, email = x 1 fname 'Christopher' 1 lname 'Brooks' %确保变量的数量和解压的值相同1 x = ('Christopher', 'Brooks', 'brooksch@umi... 阅读全文
posted @ 2018-03-05 19:30 郑哲 阅读(75) 评论(0) 推荐(0) 编辑
字典
摘要:%字典用keys来连接values1 x = {'Christopher Brooks': 'brooksch@umich.edu', 'Bill Gates': 'billg@microsoft.com'} 2 x['Christopher Brooks'] # Retrieve a value 阅读全文
posted @ 2018-03-05 19:28 郑哲 阅读(89) 评论(0) 推荐(0) 编辑
链表list和字符串string
摘要:list 阅读全文
posted @ 2018-03-05 19:20 郑哲 阅读(154) 评论(0) 推荐(0) 编辑
python类型和序列
摘要:NoneType int float function 阅读全文
posted @ 2018-03-05 18:51 郑哲 阅读(111) 评论(0) 推荐(0) 编辑
元组
摘要:tuple 阅读全文
posted @ 2018-03-05 18:51 郑哲 阅读(73) 评论(0) 推荐(0) 编辑
函数定义
摘要:输出:3 输出:3 6 输出: 输出:3 阅读全文
posted @ 2018-03-05 18:47 郑哲 阅读(138) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示