Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
424954a0
Commit
424954a0
authored
Sep 03, 2018
by
高雅喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
return one day stat
parent
71498ed7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
89 deletions
+90
-89
grayStat.py
eda/gray_stat/grayStat.py
+90
-89
No files found.
eda/gray_stat/grayStat.py
View file @
424954a0
...
@@ -62,94 +62,95 @@ class GrayStat(object):
...
@@ -62,94 +62,95 @@ class GrayStat(object):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
date_list
=
get_between_day
(
'2018-08-20'
,
'2018-08-29'
)
# date_list = get_between_day('2018-08-20','2018-08-29')
for
my_date
in
date_list
:
# for my_date in date_list:
print
(
"开始获取ffm中的灰度非灰度比例"
)
start
=
time
.
time
()
print
(
"开始获取ffm中的灰度非灰度比例"
)
#1.ffm中的灰度非灰度(ios和安卓一样):
start
=
time
.
time
()
# 灰度:_6
#1.ffm中的灰度非灰度(ios和安卓一样):
# 非灰度:_8
# 灰度:_6
result1
=
[]
# 非灰度:_8
#1.1获取ios和android平台的数据
result1
=
[]
platforms
=
[
'ios'
,
'android'
]
#1.1获取ios和android平台的数据
grays
=
[
'6'
,
'8'
]
platforms
=
[
'ios'
,
'android'
]
for
platform
in
platforms
:
grays
=
[
'6'
,
'8'
]
for
gray
in
grays
:
for
platform
in
platforms
:
g_class
=
GrayStat
(
'diary'
,
gray
,
platform
,
my_date
)
for
gray
in
grays
:
uid_count
=
g_class
.
get_uid_count
()
g_class
=
GrayStat
(
'diary'
,
gray
,
platform
)
uid_clk_times
=
g_class
.
get_uid_clk_times
()
uid_count
=
g_class
.
get_uid_count
()
uid_imp_times
=
g_class
.
get_uid_imp_times
()
uid_clk_times
=
g_class
.
get_uid_clk_times
()
uid_clk_rate
=
round
(
uid_clk_times
/
uid_imp_times
,
4
)
if
uid_imp_times
!=
0
else
0
uid_imp_times
=
g_class
.
get_uid_imp_times
()
result1
.
append
([
g_class
.
ndays
,
g_class
.
cid_type
,
platform
,
gray
,
uid_count
,
\
uid_clk_rate
=
round
(
uid_clk_times
/
uid_imp_times
,
4
)
if
uid_imp_times
!=
0
else
0
uid_clk_times
,
uid_imp_times
,
uid_clk_rate
])
result1
.
append
([
g_class
.
ndays
,
g_class
.
cid_type
,
platform
,
gray
,
uid_count
,
\
result1
.
append
([
g_class
.
ndays
,
g_class
.
cid_type
,
platform
,
'all'
,
\
uid_clk_times
,
uid_imp_times
,
uid_clk_rate
])
result1
[
-
1
][
4
]
+
result1
[
-
2
][
4
],
\
result1
.
append
([
g_class
.
ndays
,
g_class
.
cid_type
,
platform
,
'all'
,
\
result1
[
-
1
][
5
]
+
result1
[
-
2
][
5
],
\
result1
[
-
1
][
4
]
+
result1
[
-
2
][
4
],
\
result1
[
-
1
][
6
]
+
result1
[
-
2
][
6
],
\
result1
[
-
1
][
5
]
+
result1
[
-
2
][
5
],
\
round
((
result1
[
-
1
][
5
]
+
result1
[
-
2
][
5
])
/
(
result1
[
-
1
][
6
]
+
result1
[
-
2
][
6
]),
4
)])
if
(
result1
[
-
1
][
6
]
+
result1
[
-
2
][
6
])
!=
0
else
0
result1
[
-
1
][
6
]
+
result1
[
-
2
][
6
],
\
#1.2获取所有平台的数据
round
((
result1
[
-
1
][
5
]
+
result1
[
-
2
][
5
])
/
(
result1
[
-
1
][
6
]
+
result1
[
-
2
][
6
]),
4
)])
if
(
result1
[
-
1
][
6
]
+
result1
[
-
2
][
6
])
!=
0
else
0
labels
=
[
'6'
,
'8'
,
'all'
]
#1.2获取所有平台的数据
for
i
in
range
(
3
):
labels
=
[
'6'
,
'8'
,
'all'
]
result1
.
append
([
g_class
.
ndays
,
g_class
.
cid_type
,
'all'
,
labels
[
i
],
\
for
i
in
range
(
3
):
result1
[
i
][
4
]
+
result1
[
i
+
3
][
4
],
\
result1
.
append
([
g_class
.
ndays
,
g_class
.
cid_type
,
'all'
,
labels
[
i
],
\
result1
[
i
][
5
]
+
result1
[
i
+
3
][
5
],
\
result1
[
i
][
4
]
+
result1
[
i
+
3
][
4
],
\
result1
[
i
][
6
]
+
result1
[
i
+
3
][
6
],
\
result1
[
i
][
5
]
+
result1
[
i
+
3
][
5
],
\
round
((
result1
[
i
][
5
]
+
result1
[
i
+
3
][
5
])
/
(
result1
[
i
][
6
]
+
result1
[
i
+
3
][
6
]),
4
)])
if
(
result1
[
i
][
6
]
+
result1
[
i
+
3
][
6
])
!=
0
else
0
result1
[
i
][
6
]
+
result1
[
i
+
3
][
6
],
\
#1.3把一天所有的数据存入文件
round
((
result1
[
i
][
5
]
+
result1
[
i
+
3
][
5
])
/
(
result1
[
i
][
6
]
+
result1
[
i
+
3
][
6
]),
4
)])
if
(
result1
[
i
][
6
]
+
result1
[
i
+
3
][
6
])
!=
0
else
0
output1
=
OUTPUT_PATH
+
"gray_ffm.csv"
#1.3把一天所有的数据存入文件
with
open
(
output1
,
'a+'
)
as
f
:
output1
=
OUTPUT_PATH
+
"gray_ffm.csv"
for
line
in
result1
:
with
open
(
output1
,
'a+'
)
as
f
:
line
=
[
str
(
i
)
for
i
in
line
]
for
line
in
result1
:
str_line
=
','
.
join
(
line
)
+
'
\n
'
line
=
[
str
(
i
)
for
i
in
line
]
f
.
write
(
str_line
)
str_line
=
','
.
join
(
line
)
+
'
\n
'
f
.
write
(
str_line
)
#2.实际中的灰度非灰度:
# ios:
#2.实际中的灰度非灰度:
# 灰度:6|8
# ios:
#非灰度:^68
# 灰度:6|8
# android:
#非灰度:^68
# 灰度:0|1|2|6|8
# android:
#非灰度:^01268
# 灰度:0|1|2|6|8
print
(
"开始获取实际中的灰度非灰度比例"
)
#非灰度:^01268
result2
=
[]
print
(
"开始获取实际中的灰度非灰度比例"
)
#2.1获取ios和android平台的数据
result2
=
[]
platforms
=
[
'ios'
,
'android'
]
#2.1获取ios和android平台的数据
for
platform
in
platforms
:
platforms
=
[
'ios'
,
'android'
]
#TODO 对于(安卓灰度放到 0 1 2 6 8;iOS灰度保持 6 8)问题,做一个id判断即可
for
platform
in
platforms
:
if
platform
==
'ios'
:
#TODO 对于(安卓灰度放到 0 1 2 6 8;iOS灰度保持 6 8)问题,做一个id判断即可
grays
=
[
'6|8'
,
'^68'
]
if
platform
==
'ios'
:
else
:
grays
=
[
'6|8'
,
'^68'
]
grays
=
[
'0|1|2|6|8'
,
'^01268'
]
else
:
for
gray
in
grays
:
grays
=
[
'0|1|2|6|8'
,
'^01268'
]
g_class
=
GrayStat
(
'diary'
,
gray
,
platform
,
my_date
)
for
gray
in
grays
:
uid_count
=
g_class
.
get_uid_count
()
g_class
=
GrayStat
(
'diary'
,
gray
,
platform
)
uid_clk_times
=
g_class
.
get_uid_clk_times
()
uid_count
=
g_class
.
get_uid_count
()
uid_imp_times
=
g_class
.
get_uid_imp_times
()
uid_clk_times
=
g_class
.
get_uid_clk_times
()
uid_clk_rate
=
round
(
uid_clk_times
/
uid_imp_times
,
4
)
if
uid_imp_times
!=
0
else
0
uid_imp_times
=
g_class
.
get_uid_imp_times
()
result2
.
append
([
g_class
.
ndays
,
g_class
.
cid_type
,
platform
,
gray
,
uid_count
,
\
uid_clk_rate
=
round
(
uid_clk_times
/
uid_imp_times
,
4
)
if
uid_imp_times
!=
0
else
0
uid_clk_times
,
uid_imp_times
,
uid_clk_rate
])
result2
.
append
([
g_class
.
ndays
,
g_class
.
cid_type
,
platform
,
gray
,
uid_count
,
\
result2
.
append
([
g_class
.
ndays
,
g_class
.
cid_type
,
platform
,
'all'
,
\
uid_clk_times
,
uid_imp_times
,
uid_clk_rate
])
result2
[
-
1
][
4
]
+
result2
[
-
2
][
4
],
\
result2
.
append
([
g_class
.
ndays
,
g_class
.
cid_type
,
platform
,
'all'
,
\
result2
[
-
1
][
5
]
+
result2
[
-
2
][
5
],
\
result2
[
-
1
][
4
]
+
result2
[
-
2
][
4
],
\
result2
[
-
1
][
6
]
+
result2
[
-
2
][
6
],
\
result2
[
-
1
][
5
]
+
result2
[
-
2
][
5
],
\
round
((
result2
[
-
1
][
5
]
+
result2
[
-
2
][
5
])
/
(
result2
[
-
1
][
6
]
+
result2
[
-
2
][
6
]),
4
)])
if
(
result2
[
-
1
][
6
]
+
result2
[
-
2
][
6
])
!=
0
else
0
result2
[
-
1
][
6
]
+
result2
[
-
2
][
6
],
\
#2.2获取所有平台的数据
round
((
result2
[
-
1
][
5
]
+
result2
[
-
2
][
5
])
/
(
result2
[
-
1
][
6
]
+
result2
[
-
2
][
6
]),
4
)])
if
(
result2
[
-
1
][
6
]
+
result2
[
-
2
][
6
])
!=
0
else
0
labels
=
[
'gray'
,
'not gray'
,
'all'
]
#2.2获取所有平台的数据
for
i
in
range
(
3
):
labels
=
[
'gray'
,
'not gray'
,
'all'
]
result2
.
append
([
g_class
.
ndays
,
g_class
.
cid_type
,
'all'
,
labels
[
i
],
\
for
i
in
range
(
3
):
result2
[
i
][
4
]
+
result2
[
i
+
3
][
4
],
\
result2
.
append
([
g_class
.
ndays
,
g_class
.
cid_type
,
'all'
,
labels
[
i
],
\
result2
[
i
][
5
]
+
result2
[
i
+
3
][
5
],
\
result2
[
i
][
4
]
+
result2
[
i
+
3
][
4
],
\
result2
[
i
][
6
]
+
result2
[
i
+
3
][
6
],
\
result2
[
i
][
5
]
+
result2
[
i
+
3
][
5
],
\
round
((
result2
[
i
][
5
]
+
result2
[
i
+
3
][
5
])
/
(
result2
[
i
][
6
]
+
result2
[
i
+
3
][
6
]),
4
)])
if
(
result2
[
i
][
6
]
+
result2
[
i
+
3
][
6
])
!=
0
else
0
result2
[
i
][
6
]
+
result2
[
i
+
3
][
6
],
\
#2.3把一天所有的数据写入文件
round
((
result2
[
i
][
5
]
+
result2
[
i
+
3
][
5
])
/
(
result2
[
i
][
6
]
+
result2
[
i
+
3
][
6
]),
4
)])
if
(
result2
[
i
][
6
]
+
result2
[
i
+
3
][
6
])
!=
0
else
0
output2
=
OUTPUT_PATH
+
"gray_all.csv"
#2.3把一天所有的数据写入文件
with
open
(
output2
,
'a+'
)
as
f
:
output2
=
OUTPUT_PATH
+
"gray_all.csv"
for
line
in
result2
:
with
open
(
output2
,
'a+'
)
as
f
:
line
=
[
str
(
i
)
for
i
in
line
]
for
line
in
result2
:
str_line
=
','
.
join
(
line
)
+
'
\n
'
line
=
[
str
(
i
)
for
i
in
line
]
f
.
write
(
str_line
)
str_line
=
','
.
join
(
line
)
+
'
\n
'
f
.
write
(
str_line
)
end
=
time
.
time
()
print
(
"程序执行时间:{}s"
.
format
(
end
-
start
))
end
=
time
.
time
()
print
(
"程序执行时间:{}s"
.
format
(
end
-
start
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment