随机森林
机器学习相关概率与统计知识和代码
飞行codes
资浅程序员,博士
展开
-
生成一维高斯曲线和噪声数据
高斯函数定义为 (1) 我们生成高斯数据和曲线: import numpy as np import matplo...原创 2020-09-30 09:04:36 · 1794 阅读 · 0 评论 -
python划简技巧sort, index, set
有时查找、排序等常用功能,我们习惯for循环,其实有很多python自带的方法可以简洁的实现。 排序 f=[1,3,4,1,8,5] f.sort() 1, 1, 3, 4, 5, 8 f2 = np.random.permutation(10) f2 = np.sort(f2) array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) 查找/索引 knigh...原创 2019-04-12 12:02:13 · 367 阅读 · 0 评论 -
np.where()巨型指导
涉及bool运算其实有点绕,官网太简洁,不好懂。 Return elements, either fromxory, depending oncondition. If onlyconditionis given, returncondition.nonzero(). 1,一维数组情形 import numpy as np x=np.random.randn(10) y=...原创 2019-11-25 11:13:22 · 642 阅读 · 0 评论 -
生成随机数语法速查
import tensorflow as tf w1=tf.Variable(tf.random_uniform([2,2],-1,1)) with tf.Session() as sess: init = tf.global_variables_initializer() sess.run(init) print(sess.run(w1)) 输出得 [[ 0.9...原创 2018-11-27 15:52:28 · 254 阅读 · 0 评论 -
numpy.random.choice()函数用法与应用场景
函数用法 Generates a random sample from a given 1-D array import numpy numpy.random.choice(100, 3) 输出:array([83, 80, 65]) numpy.random.choice([1,0.2,7,'c'],2) 输出:array(['c', '0.2'], dtype='|S32...原创 2019-01-24 17:19:47 · 865 阅读 · 0 评论 -
训练集、验证集和测试集随机划分实现代码
VALIDATION_PERCENTAGE = 10 TEST_PERCENTAGE = 10 validation_images=[] validation_labels=[] testing_images=[] testing_labels=[] training_images=[] training_labels=[] chance = np.random.randint(100) i...原创 2018-12-29 11:38:51 · 10959 阅读 · 0 评论 -
python随机打乱代码实现
train_data 和 train_label保持对应 state = np.random.get_state() np.random.shuffle(train_data) np.random.set_state(state) np.random.shuffle(train_label) 原理 numpy.random.set_state(state) Set the internal...原创 2018-12-27 14:13:58 · 702 阅读 · 0 评论