├── pic ├── 1 └── 1.png ├── code ├── README.md └── test.py └── README.md /pic/1: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /code/README.md: -------------------------------------------------------------------------------- 1 | 因该项目论文专利成果还未公布,待后期会对系统平台、实验数据集进行开源。 如有兴趣交流学习敬请联系我! email:anbo1024@163.com 2 | -------------------------------------------------------------------------------- /pic/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anbo1024/Human-behavior-recognition-system-based-on-WIFI-signal/HEAD/pic/1.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Human-behavior-recognition-system-based-on-WIFI-signal 2 | 本套行为识别系统是利用WIFI信道信息实现了对人体基本行为的在线识别。行为识别系统采用商用WIFI设备进行原始数据的采集,利用小波变换(DWT)、主成分分析(PCA)等进行特征提取。采用当下火热的机器学习和深度学习算法,支持向量机(SVM)、卷积神经网络(CNN)等进行模型训练,基于此模型实现对行为在线检测。研发的行为识别系统高精度的实现了人体行为的在线检测,并且系统具有较高的鲁棒性。 3 | This set of behavior recognition system uses the WIFI channel information to realize online recognition of the basic behavior of the human body. The behavior recognition system uses commercial WIFI equipment to collect raw data, and uses wavelet transform (DWT) and principal component analysis (PCA) to extract features. Using the current hot machine learning and deep learning algorithms, support vector machine (SVM), convolutional neural network (CNN) and other model training, based on this model to achieve online behavior detection. The developed behavior recognition system achieves high-precision online detection of human behavior, and the system has high robustness. 4 | 5 | ![linear svm ](https://github.com/anbo1024/Human-behavior-recognition-system-based-on-WIFI-signal/blob/master/pic/1.png) 6 | Because the patent results of the project papers have not yet been published, the system platform and experimental data set will be open source later. If you are interested in exchange and study, please contact me! Email: anbo1024@163.com .. 7 | 因该项目论文专利成果还未公布,待后期会对系统平台、实验数据集进行开源。 8 | 如有兴趣交流学习敬请联系我! 9 | email:anbo1024@163.com 10 | 11 | -------------------------------------------------------------------------------- /code/test.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Mon Feb 22 13:21:22 2016 4 | K-NearestNeighbor 5 | @author: liudiwei 6 | """ 7 | import numpy as np 8 | import operator 9 | 10 | class KNNClassifier(): 11 | """This is a Nearest Neighbor classifier. """ 12 | 13 | def __init__(self, k=3): 14 | self._k = k 15 | 16 | def _calEDistance(self, inSample, dataset): 17 | m = dataset.shape[0] 18 | diffMat = np.tile(inSample, (m,1)) - dataset 19 | sqDiffMat = diffMat**2 #每个元素平方 20 | sqDistances = sqDiffMat.sum(axis = 1) #求和 21 | distances = sqDistances ** 0.5 #开根号 22 | return distances.argsort() #按距离的从小到达排列的下标值 23 | 24 | def _classify0(self, inX, dataSet, labels): 25 | k = self._k 26 | dataSetSize = dataSet.shape[0] 27 | diffMat = np.tile(inX, (dataSetSize,1)) - dataSet 28 | sqDiffMat = diffMat**2 29 | sqDistances = sqDiffMat.sum(axis=1) 30 | distances = sqDistances**0.5 31 | sortedDistIndicies = distances.argsort() 32 | classCount={} 33 | for i in range(k): 34 | voteIlabel = labels[sortedDistIndicies[i]] 35 | classCount[voteIlabel] = classCount.get(voteIlabel,0) + 1 36 | sortedClassCount = sorted(classCount.iteritems(), key=operator.itemgetter(1), reverse=True) 37 | return sortedClassCount[0][0] 38 | 39 | #对一个样本进行分类 40 | def _classify(self, sample, train_X, train_y): 41 | #数据类型检测 42 | if isinstance(sample, np.ndarray) and isinstance(train_X, np.ndarray) \ 43 | and isinstance(train_y, np.ndarray): 44 | pass 45 | else: 46 | try: 47 | sample = np.array(sample) 48 | train_X = np.array(train_X) 49 | train_y = np.array(train_y) 50 | except: 51 | raise TypeError("numpy.ndarray required for train_X and ..") 52 | sortedDistances = self._calEDistance(sample, train_X) 53 | classCount = {} 54 | for i in range(self._k): 55 | oneVote = train_y[sortedDistances[i]] #获取最近的第i个点的类别 56 | classCount[oneVote] = classCount.get(oneVote, 0) + 1 57 | sortedClassCount = sorted(classCount.iteritems(),\ 58 | key=operator.itemgetter(1), reverse=True) 59 | #print "the sample :", sample, "is classified as",sortedClassCount[0][0] 60 | return sortedClassCount[0][0] 61 | 62 | 63 | def classify(self, test_X, train_X, train_y): 64 | results = [] 65 | #数据类型检测 66 | if isinstance(test_X, np.ndarray) and isinstance(train_X, np.ndarray) \ 67 | and isinstance(train_y, np.ndarray): 68 | pass 69 | else: 70 | try: 71 | test_X = np.array(test_X) 72 | train_X = np.array(train_X) 73 | train_y = np.array(train_y) 74 | except: 75 | raise TypeError("numpy.ndarray required for train_X and ..") 76 | d = len(np.shape(test_X)) 77 | if d == 1: 78 | sample = test_X 79 | result = self._classify(sample, train_X, train_y) 80 | results.append(result) 81 | else: 82 | for i in range(len(test_X)): 83 | sample = test_X[i] 84 | result = self._classify(sample, train_X, train_y) 85 | results.append(result) 86 | return results 87 | 88 | 89 | if __name__=="__main__": 90 | train_X = [[1, 2, 0, 1, 0], 91 | [0, 1, 1, 0, 1], 92 | [1, 0, 0, 0, 1], 93 | [2, 1, 1, 0, 1], 94 | [1, 1, 0, 1, 1]] 95 | train_y = [1, 1, 0, 0, 0] 96 | clf = KNNClassifier(k = 3) 97 | sample = [[1,2,0,1,0],[1,2,0,1,1]] 98 | result = clf.classify(sample, train_X, train_y) 99 | --------------------------------------------------------------------------------