摘要: import numpy as np #随机生成点 from sklearn.datasets import make_blobs #K-means:k均值聚类 cluster(一簇,一类) from sklearn.cluster import KMeans import matplotlib.pyplot as plt %matplotlib inline X_train,y_trai... 阅读全文
posted @ 2018-10-17 12:54 gugubeng 阅读(731) 评论(0) 推荐(0) 编辑
摘要: svr_linear = SVR('linear') #基于直线 svr_rbf = SVR('rbf') #基于半径 svr_poly = SVR('poly') #基于多项式 阅读全文
posted @ 2018-10-17 12:49 gugubeng 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 导入sklearn.feature_extraction.text.TfidfVectorizer用于转换字符串 from sklearn.feature_extraction.text import TfidfVectorizer # 创建对象 tf = TfidfVectorizer() # 训练 tf.fit(data) # transform 转化 data_result = tf... 阅读全文
posted @ 2018-10-17 12:44 gugubeng 阅读(289) 评论(0) 推荐(0) 编辑
摘要: from sklearn.model_selection import train_test_split X_train,X_test,y_train,y_test = train_test_split(face_up,face_down,test_size = 0.02) estimators = {'linear':LinearRegression(), 'ri... 阅读全文
posted @ 2018-10-17 12:40 gugubeng 阅读(479) 评论(0) 推荐(0) 编辑
摘要: 算法模型实现效果图 阅读全文
posted @ 2018-10-17 12:37 gugubeng 阅读(410) 评论(0) 推荐(0) 编辑
摘要: 现在考虑有一个 jsonline 格式的文件 file.txt 大小约为 10K,之前处理文件的代码如下所示: 现在要处理一个大小为 10G 的文件,但是内存只有 4G,如果在只修改 get_lines 函数而其他代码保持不变的情况下,应该如何实现?需要考虑的问题都有哪些? 说明 : 内存只有 4G 阅读全文
posted @ 2018-10-09 10:22 gugubeng 阅读(1813) 评论(0) 推荐(0) 编辑
摘要: 装饰器 最简装饰器 def deco(func): def wrap(*args, **kwargs): return func(*args, **kwargs) return wrap @deco def foo(a, b): return a ** b 原理 对比被装饰前后的 foo.__nam 阅读全文
posted @ 2018-10-08 16:39 gugubeng 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 迭代器, 生成器 练习: 说出如下代码的打印结果 >>> def foo(): ... print(111) ... yield 222 ... print(333) ... yield 444 ... print(555) ​ >>> n = foo() >>> next(n) >>> next( 阅读全文
posted @ 2018-10-08 16:36 gugubeng 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 1. * 和 ** 的用法 函数定义时接收不定长参数 def foo(*args, **kwargs): pass 参数传递 def foo(x, y, z, a, b): print(x) print(y) print(z) print(a) print(b) lst = [1, 2, 3] di 阅读全文
posted @ 2018-10-08 16:33 gugubeng 阅读(411) 评论(0) 推荐(0) 编辑
摘要: PEP8 编码规范, 及开发中的一些惯例和建议 练习: 规范化这段代码 from django.conf import settings from user.models import * import sys, os mod=0xffffffff def foo ( a , b = 123 ): 阅读全文
posted @ 2018-10-08 16:31 gugubeng 阅读(200) 评论(0) 推荐(0) 编辑