Skip to content

Commit 49b089c

Browse files
author
王小辉
committed
Updated XGBoost model and related document
1 parent 5be0212 commit 49b089c

File tree

7 files changed

+37
-14
lines changed

7 files changed

+37
-14
lines changed

Android/demo_myna/src/main/java/com/talkingdata/myna/demo/DataScientistActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void onResult(@NonNull RecognizedActivityResult detectedResults) {
7979
}
8080

8181
private void doAsDataScientist(){
82-
handHolding();
82+
xgBoost();
8383
}
8484

8585
private void randomForest(){
-203 KB
Binary file not shown.

Android/lib-Myna/src/main/java/com/talkingdata/myna/tools/Statistics.java

+13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.talkingdata.myna.tools;
22

3+
import java.util.Arrays;
4+
35
public class Statistics {
46

57
public static float getMean(float[] data) {
@@ -90,4 +92,15 @@ private static float getVariance(float[] data, int ddof) {
9092
return temp / (data.length - ddof);
9193
}
9294
}
95+
96+
public static float getMedian(float[] data){
97+
Arrays.sort(data);
98+
float median;
99+
if (data.length % 2 == 0)
100+
median = (data[data.length/2] + data[data.length/2 - 1])/2;
101+
else
102+
median = data[data.length/2];
103+
return median;
104+
105+
}
93106
}

README.md

+23-13
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Android 平台情景感知框架
55
[![GitHub license](http://og41w30k3.bkt.clouddn.com/apache2.svg)](./LICENSE)
66

77

8-
![](http://p1.bqimg.com/562611/952bd822efce378b.png)
8+
![](images/myna.png)
99

1010

1111
Myna 项目中包含一个测试 Demo 工程:demo-myna, 将该工程和 Myna 项目本身导入到 Android Studio 中,就可以开始调试了。
@@ -15,14 +15,15 @@ Myna 提供了两套接口:
1515
- 面向开发者的接口:开发者只需要简单的接口调用,就能在应用程序中获取实时识别的用户行为状态。
1616
- 面向数据科学家的接口:数据科学家可以很方便地添加新的识别算法,在运行时调整订阅的传感器类型、采样频率和采样时长,而无需关心 Android 系统相关的传感器数据订阅细节。
1717

18-
## 更新 2017-06-19
18+
## 更新 2017-07-12
1919

2020
- 支持下面五种行为类型:
2121
1. Walking
2222
2. Running
2323
3. Bus
2424
4. Subway
2525
5. Car
26+
6. Stationary
2627
- 新增 XGBoost 和基于 Tensorflow 的 LSTM 分类模型。
2728
1. `Dataset` 目录下有数据集下载链接、数据处理脚本和 XGBoost 模型训练脚本。
2829
2. 使用 LSTM 模型需要时需要提供训练好的模型和 Tensorflow 的动态库以及 Java Interface 包,预训练模型已经包含在 Myna 中,Tensorflow 动态库和 Java Interface 比较大,没有放在 repo 中,可以从 [Google Drive](https://drive.google.com/open?id=0B2hKiPsUlgibbklJaEh4V1o1MlU) 下载,或者按照官方文档提供的教程自己编译,放在 `lib-Myna/libs` 目录下就可以运行测试工程了。
@@ -35,26 +36,35 @@ Myna 使用随机森林分类算法的一种开源实现--**Dice** 进行的实
3536

3637
当使用 XGBoost 进行分类时。模型的 metrics 为:
3738

38-
Precision 0.964143858121
39-
Recall 0.964285714286
40-
f1_score 0.963936330023
39+
Precision 0.909969288145
40+
Recall 0.908256880734
41+
f1_score 0.90816711949
4142
confusion_matrix
42-
[[67 0 0 0 0]
43-
[ 0 75 0 0 0]
44-
[ 0 0 52 1 3]
45-
[ 0 0 0 39 0]
46-
[ 0 0 5 1 37]]
43+
[[ 93 0 1 0 0 0]
44+
[ 0 115 1 1 1 0]
45+
[ 0 0 102 3 5 0]
46+
[ 3 0 9 84 6 2]
47+
[ 2 0 7 11 85 1]
48+
[ 0 0 4 3 0 115]]
49+
predicting, classification error=0.091743
50+
51+
Confusion matrix:
52+
53+
![](images/confusionmatrix.png)
54+
55+
ROC:
56+
57+
![](images/roc.png)
4758

4859
## 集成文档
4960

5061
[快速集成文档](/QuickStart.md)
5162

5263
## Roadmap
5364

54-
2017 年 6 月
65+
2017 年
5566

56-
1. 增加手持状态检测能力。
57-
2. 增加对更多行为的识别能力。
67+
- 增加对更多行为的识别能力。
5868

5969

6070
## License

images/confusionmatrix.png

-55.3 KB
Loading

images/myna.png

5.81 KB
Loading

images/roc.png

58.8 KB
Loading

0 commit comments

Comments
 (0)