Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
strategy_embedding
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rank
strategy_embedding
Commits
16ec9503
Commit
16ec9503
authored
4 years ago
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add column names
parent
13456735
offic
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
24 deletions
+26
-24
get_data.py
personas_vector/get_data.py
+6
-6
to_vector.py
personas_vector/to_vector.py
+17
-16
files.py
utils/files.py
+3
-2
No files found.
personas_vector/get_data.py
View file @
16ec9503
...
...
@@ -18,13 +18,13 @@ if __name__ == "__main__":
days
=
5
# TODO days 30
start
,
end
=
get_ndays_before_no_minus
(
days
),
get_ndays_before_no_minus
(
1
)
click_df
=
get_click_data
(
spark
,
card_type
,
start
,
end
)
save_df_to_csv
(
click_df
,
"personas_tractate_click.csv"
)
print
(
click_df
.
shape
)
#
click_df = get_click_data(spark, card_type, start, end)
#
save_df_to_csv(click_df, "personas_tractate_click.csv")
#
print(click_df.shape)
exposure_df
=
get_exposure_data
(
spark
,
card_type
,
start
,
end
)
save_df_to_csv
(
exposure_df
,
"personas_tractate_exposure.csv"
)
print
(
exposure_df
.
shape
)
#
exposure_df = get_exposure_data(spark, card_type, start, end)
#
save_df_to_csv(exposure_df, "personas_tractate_exposure.csv")
#
print(exposure_df.shape)
device_feature_df
=
get_device_tags
(
spark
)
save_df_to_csv
(
device_feature_df
,
"personas_device_feature.csv"
)
...
...
This diff is collapsed.
Click to expand it.
personas_vector/
dssm_model
.py
→
personas_vector/
to_vector
.py
View file @
16ec9503
...
...
@@ -4,6 +4,7 @@ import sys
sys
.
path
.
append
(
os
.
path
.
realpath
(
"."
))
import
pandas
as
pd
from
gensim.models
import
Word2Vec
,
word2vec
from
utils.defs
import
nth_element
from
utils.files
import
get_df
...
...
@@ -17,23 +18,23 @@ TRACTATE_COLUMNS = [
def
device_tractae_fe
():
click_df
=
get_df
(
"personas_tractate_click.csv"
)
exposure_df
=
get_df
(
"personas_tractate_exposure.csv"
)
device_fe_df
=
get_df
(
"personas_device_feature.csv"
)
tractate_tags_df
=
get_df
(
"personas_tractate_tags.csv"
)
print
(
click_df
.
shape
)
print
(
exposure_df
.
shape
)
print
(
device_fe_df
.
shape
)
print
(
tractate_tags_df
.
shape
)
pass
if
__name__
==
"__main__"
:
click_df
=
get_df
(
"personas_tractate_click.csv"
)
exposure_df
=
get_df
(
"personas_tractate_exposure.csv"
)
device_fe_df
=
get_df
(
"personas_device_feature.csv"
)
tractate_tags_df
=
get_df
(
"personas_tractate_tags.csv"
)
print
(
click_df
.
shape
)
print
(
exposure_df
.
shape
)
print
(
device_fe_df
.
shape
)
print
(
tractate_tags_df
.
shape
)
device_fe_df
=
get_df
(
"personas_device_feature.csv"
,
columns
=
[
"cl_id"
,
"first_demands"
,
"first_solutions"
,
"first_positions"
,
"second_demands"
,
"second_solutions"
,
"second_positions"
,
"projects"
,
"business_tags"
,
])
print
(
device_fe_df
.
head
(
3
))
tractate_tags_df
=
get_df
(
"personas_tractate_tags.csv"
,
columns
=
[
"tractate_id"
,
"business_tags"
])
print
(
tractate_tags_df
.
head
(
3
))
This diff is collapsed.
Click to expand it.
utils/files.py
View file @
16ec9503
...
...
@@ -32,8 +32,9 @@ def save_dict_to_csv(d, file):
f
.
write
(
"{}|{}
\n
"
.
format
(
k
,
","
.
join
([
str
(
x
)
for
x
in
v
])))
def
get_df
(
file
):
def
get_df
(
file
,
sep
=
"|"
,
columns
=
[]
):
full_path
=
os
.
path
.
join
(
DATA_PATH
,
file
)
print
(
full_path
)
df
=
pd
.
read_csv
(
full_path
,
sep
=
"|"
)
df
=
pd
.
read_csv
(
full_path
,
sep
=
"|"
,
names
=
columns
)
print
(
df
.
shape
)
return
df
This diff is collapsed.
Click to expand it.
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