mean

pandas实现sum()over()、count()over()等窗口函数

有些话、适合烂在心里 提交于 2020-02-10 11:17:17
pandas利用transform实现窗口函数 array = [ ['a', 2, 29], ['a', 1, 18], ['a', 0, 18], ['b', 2, 25], ['b', 4, 12], ['c', 6, 21], ] data = pd.DataFrame(array, columns=["name", "class", "score"]) # 去重计数:nunique data['nunique'] = data.groupby('name')['name'].transform('nunique') # 求和:sum data['sum'] = data.groupby('name')['score'].('sum') # 均值:mean data['mean'] = data.groupby('name')['score'].transform('mean') # 其余统计函数类似 来源: CSDN 作者: Alex.liu 链接: https://blog.csdn.net/longwei92/article/details/104244323

gethostbyname, gethostbyaddr

☆樱花仙子☆ 提交于 2020-02-09 01:29:29
gethostbyname取ip地址, gethostbyaddr取域名 #include <iostream> // #ifndef WIN32_LEAN_AND_MEAN // #define WIN32_LEAN_AND_MEAN // #endif #include <winsock2.h> #include <windows.h> #include <conio.h> #pragma comment(lib,"ws2_32.lib") using std::cout; using std::endl; using std::cerr; int main(int argc,char *argv[],char *envp[]) { int iretcode = 0; const char *pip_addr = "www.baidu.com";//or "220.181.38.148";// WSADATA wsa = {0}; iretcode = WSAStartup(MAKEWORD(2,2),&wsa); if(iretcode != 0) return iretcode;// WSAStartup function error. /////////////////////////////////////////////// // get address dwip

21Batch Normalization

眉间皱痕 提交于 2020-02-07 05:08:36
一、Batch Normalization概念 1.1 Batch Normalization概念 Batch Normalization:批标准化 批:一批数据,通常为mini-batch 标准化: 0均值, 1方差 优点: 可以用更大学习率,加速模型收敛 可以不用精心设计权值初始化 可以不用dropout或较小的dropout 可以不用L2或者较小的weight decay 可以不用LRN(local response normalization) 《 Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift》 计算方式: 输入:一个mini-batch数据(m个),两个待学习的参数 γ , β \gamma,\beta γ , β 输出: 求取mini-batch数据的均值和方差 对mini-batch中的每个数据标准化, ϵ \epsilon ϵ 是修正项,防止分母为0 对上一步数据进行affine transfrom,可理解为缩放和平移,增强Capacity 1.2 Internal Covariate Shift (ICS) ICS:可以简单理解为数据尺度或分布的变化 由上图中的D(H1)=n*D(x)*D(W)=1可知

tf.truncated_normal

拈花ヽ惹草 提交于 2020-02-07 01:08:18
tf.truncated_normal(shape, mean, stddev) :shape表示生成张量的维度,mean是均值,stddev是标准差。这个函数产生正太分布,均值和标准差自己设定。 和一般的正太分布的产生随机数据比起来,这个函数产生的随机数与均值的差距不会超过两倍的标准差。 c = tf.truncated_normal(shape=[5,5], mean=0, stddev=1) with tf.Session() as sess: print (sess.run(c)) [[-0.8753589 0.41450828 0.6864193 -1.4532009 -1.2428166 ] [ 1.6081111 -1.706497 -0.30391937 -1.9017276 0.5069634 ] [-0.44165823 -0.3769822 0.23718952 0.40979347 0.35884857] [-0.1833816 -0.58976877 0.70531815 -0.05325391 0.00815403] [-0.98096454 -0.12696017 -1.1716813 -0.02667531 1.141188 ]] 来源: https://www.cnblogs.com/hapyygril/p/10930936.html

winsock2.h(112) : error C2011: 'fd_set' : 'struct' type redefinition

ε祈祈猫儿з 提交于 2020-02-07 00:51:44
winsock2.h(112) : error C2011: 'fd_set' : 'struct' type redefinition <windows.h>中已经包含了早期版本的<winsock.h> (windows socket 1.1) 参照<stdafx.h>中的做法,在#include <windows.h> 前添加 #define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include <windows.h> #include <winsock2.h> #include <ws2tcpip.h> #pragma comment(lib,"ws2_32.lib") 来源: CSDN 作者: zing2000 链接: https://blog.csdn.net/zing2008/article/details/104200939

标准化数据-StandardScaler

别等时光非礼了梦想. 提交于 2020-02-06 02:58:18
StandardScaler----计算训练集的平均值和标准差,以便测试数据集使用相同的变换 官方文档: class sklearn.preprocessing. StandardScaler ( copy=True , with_mean=True , with_std=True ) Standardize features by removing the mean and scaling to unit variance 通过删除平均值和缩放到单位方差来标准化特征 The standard score of a sample x is calculated as: 样本x的标准分数计算如下: z = (x - u) / s   where u is the mean of the training samples or zero if with_mean=False , and s is the standard deviation of the training samples or one if with_std=False .   其中u是训练样本的均值,如果with_mean=False,则为0   s是训练样本的标准偏差,如果with_std=False,则为1 Centering and scaling happen independently on each

逻辑回归 - 欺诈检测

梦想与她 提交于 2020-02-03 11:40:02
import pandas as pd import matplotlib.pyplot as plt import numpy as np creditcard = 'C:/Users/Amber/Documents/唐宇迪-机器学习课程资料/机器学习算法配套案例实战/逻辑回归-信用卡欺诈检测/逻辑回归-信用卡欺诈检测/creditcard.csv' data = pd.read_csv(creditcard) print(data.head()) Time V1 V2 V3 ... V27 V28 Amount Class 0 0.0 -1.359807 -0.072781 2.536347 ... 0.133558 -0.021053 149.62 0 1 0.0 1.191857 0.266151 0.166480 ... -0.008983 0.014724 2.69 0 2 1.0 -1.358354 -1.340163 1.773209 ... -0.055353 -0.059752 378.66 0 3 1.0 -0.966272 -0.185226 1.792993 ... 0.062723 0.061458 123.50 0 4 2.0 -1.158233 0.877737 1.548718 ... 0.219422 0.215153 69.99 0 [5

逻辑回归-信用卡欺诈检测

浪尽此生 提交于 2020-02-01 03:11:07
数据集: import matplotlib.pyplot as plt import numpy as np import pandas as pd data=pd.read_csv("creditcard.csv") print(data.head()) import matplotlib.pyplot as plt import numpy as np import pandas as pd data=pd.read_csv("creditcard.csv") #print(data.head()) count_classes=pd.value_counts(data['Class'],sort=True).sort_index() count_classes.plot(kind='bar') plt.title("Fraud class histogram") plt.xlabel("Class") plt.ylabel("Frequency") plt.show() #数据预处理: import matplotlib.pyplot as plt import numpy as np import pandas as pd data=pd.read_csv("creditcard.csv") #print(data.head()) count_classes=pd

cyclic dependency detected in mongoose + nodeJS

拟墨画扇 提交于 2020-01-30 11:31:45
问题 I'm getting error like below. Error: cyclic dependency detected at serializeObject (F:\Full Stack course\code_base\meanhotel\node_modules\bson\lib\bson\parser\serializer.js:331:34) The code is as below.. In db.connection.js const mongoose = require("mongoose"); mongoose.connect("mongodb://localhost:27017/mean"); require("./hotel.model"); In hotel.schema.js const mongoose = require("mongoose"); const Schema = mongoose.Schema; const HotelSchema = new Schema({ name : { type : String, required :

cyclic dependency detected in mongoose + nodeJS

微笑、不失礼 提交于 2020-01-30 11:31:26
问题 I'm getting error like below. Error: cyclic dependency detected at serializeObject (F:\Full Stack course\code_base\meanhotel\node_modules\bson\lib\bson\parser\serializer.js:331:34) The code is as below.. In db.connection.js const mongoose = require("mongoose"); mongoose.connect("mongodb://localhost:27017/mean"); require("./hotel.model"); In hotel.schema.js const mongoose = require("mongoose"); const Schema = mongoose.Schema; const HotelSchema = new Schema({ name : { type : String, required :