随笔分类 -  Python

摘要:机器学习:pandas统计只能针对小部分数据,小维度, 从过去的大量的数据中总结出来泛化规律,用于新数据预测 给我一堆数据,我怎么根据数据总结规律呢? 监督学习: 给一堆数据,然后给出标准答案,训练建立新的模型,然后用新的数据使用该模型,做出预测 分类问题:不同类别的预测,离散的,是属于哪一类?是还 阅读全文
posted @ 2018-03-06 14:55 88aa123
摘要:分词 1 import jieba 2 3 seg_list=jieba.cut("我在学习自然语言处理",cut_all=True) 4 print("/ ".join(seg_list)) #全模式 5 #我/ 在/ 学习/ 自然/ 自然语言/ 语言/ 处理 6 7 seg_list=jieba 阅读全文
posted @ 2018-03-06 10:26 88aa123
摘要:re模块 在线验证工具:http://regexr.com/ 练习:https://alf.nu/RegexGolf 1 import re 2 m=re.match(r'(\w+) (\w+)(?P<sign>.*)','hello hanxiaoyang!') 3 print(m.string) 阅读全文
posted @ 2018-03-05 10:05 88aa123
摘要:英文字符串操作 1 import operator 2 str='hello world' 3 str1='nihao' 4 #去空格以及特殊字符 5 print(str.strip()) 6 7 #链接字符串 8 print(str+str1) 9 10 #查找字符 11 print(str.in 阅读全文
posted @ 2018-03-05 09:22 88aa123
摘要:http://tushare.org/ 财经数据 http://archive.ics.uci.edu/ml 机器学习 文本数据 csv和txt 读取 import pandas as pd df=pd.read_csv('xx.csv') df=pd.read_table('xx.csv',sep 阅读全文
posted @ 2018-03-03 16:24 88aa123 阅读(198) 评论(0) 推荐(0)
摘要:画直线图 基本画图 1 import numpy as np 2 import matplotlib.pyplot as plt 3 from pylab import * 4 5 # 定义数据部分 6 x = np.arange(0., 10, 0.2) 7 y1 = np.cos(x) 8 y2 阅读全文
posted @ 2018-03-03 11:30 88aa123 阅读(159) 评论(0) 推荐(0)
摘要:Series一行,有列名 1 from pandas import Series 2 3 print('用数组生成Series') 4 obj=Series([4,7,-5,3]) 5 ''' 6 0 4 7 1 7 8 2 -5 9 3 3 10 ''' 11 print(obj) #dtype: 阅读全文
posted @ 2018-03-02 17:19 88aa123
摘要:ndarray 生成数组 1 import numpy as np 2 3 #使用普通一维数组生成NumPy一维数组 4 data=[6,7.5,8,0,1] 5 arr=np.array((data)) #[6. 7.5 8. 0. 1. ] 6 print(arr) 7 print(arr.dt 阅读全文
posted @ 2018-03-02 01:02 88aa123
摘要:容器 列表 1 # 容器 2 li=[1,2,3,'abc',4.5,[2,3,4],{1:'one'}] 3 4 print(len(li)) 5 6 print(li[0]) 7 print(li[-1]) #{1:'one'} 8 9 li=[1,2,3] 10 li.append('a') 阅读全文
posted @ 2018-03-01 18:57 88aa123 阅读(163) 评论(0) 推荐(0)