上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 49 下一页
摘要: 线性回归重要概念: 损失函数:预测值偏离真实值的度量,损失越小,拟合越好 损失函数的两种求解方式: 最小二乘法:直接求解,使用于小样本量,小于10w,sklearn的API:from sklearn.linear_model import LinearRegression 梯度下降:适合大样本量,大 阅读全文
posted @ 2020-03-26 21:23 kog_maw 阅读(666) 评论(0) 推荐(0)
摘要: import geventfrom gevent import monkeyimport timemonkey.patch_all() # 将程序中用到的耗时模块操作的代码,换为gevent中自己实现的模块def f(n): for x in range(n): print(gevent.getcu 阅读全文
posted @ 2020-03-26 16:57 kog_maw 阅读(127) 评论(0) 推荐(0)
摘要: import timedef test1(): while True: print('.....1......') time.sleep(0.2) yielddef test2(): while True: print('......2......') time.sleep(0.2) yieldde 阅读全文
posted @ 2020-03-26 16:56 kog_maw 阅读(157) 评论(0) 推荐(0)
摘要: # def create_num(all_num):# a, b = 0, 1# current_num = 0# while current_num <= all_num:# yield a# a, b = b, a+b# current_num += 1# return 'ok....'## o 阅读全文
posted @ 2020-03-26 16:55 kog_maw 阅读(185) 评论(0) 推荐(0)
摘要: def create_num(all_num): a, b = 0, 1 current_num = 0 while current_num <= all_num: yield a # 如果一个函数中有yield语句,那么这个就不再是一个函数,而是一个生成器模板 a, b = b, a+b curr 阅读全文
posted @ 2020-03-26 16:54 kog_maw 阅读(153) 评论(0) 推荐(0)
摘要: 1 from collections.abc import Iterable 2 3 ''' 4 迭代器的作用,通过迭代器生成需要的数据,而不是事先放进一个列表里存储,节省大量内存空间 5 ''' 6 7 # 比如想要从1到1000的数字,不是提前准备一个列表,而是需要的时候临时用xrange(10 阅读全文
posted @ 2020-03-26 16:53 kog_maw 阅读(140) 评论(0) 推荐(0)
摘要: 1 from collections.abc import Iterable 2 from collections.abc import Iterator 3 4 # 判断是否是可迭代对象 5 print(isinstance([11, 22, 33], Iterable)) 6 7 class C 阅读全文
posted @ 2020-03-26 16:52 kog_maw 阅读(160) 评论(0) 推荐(0)
摘要: 1 import os 2 import multiprocessing 3 import os 4 import time 5 6 def copy_file(old_file, new_file, q): 7 """拷贝数据""" 8 old_f = open(old_file, 'rb') 9 阅读全文
posted @ 2020-03-26 16:51 kog_maw 阅读(161) 评论(0) 推荐(0)
摘要: 1 from multiprocessing.pool import Pool 2 import os, time, random 3 4 def worker(msg): 5 t_start = time.time() 6 print('%s开始执行,进程号为%d' % (msg, os.getp 阅读全文
posted @ 2020-03-26 16:50 kog_maw 阅读(115) 评论(0) 推荐(0)
摘要: 1 import multiprocessing 2 3 ''' 4 q = multiprocessing.Queue(3) 5 q.put(1) 6 q.put_nowait(0) 7 q.get() 8 q.get_nowait() 9 q.full() 10 q.empty() 11 # 放 阅读全文
posted @ 2020-03-26 16:49 kog_maw 阅读(105) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 49 下一页