Skip to content

Commit

Permalink
add genResult
Browse files Browse the repository at this point in the history
finish some data exploration, add the genResult method
  • Loading branch information
JeremyLi28 committed Aug 26, 2015
1 parent 7957a79 commit 89c2ffe
Show file tree
Hide file tree
Showing 8 changed files with 3,593 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ data/weibo_predict_data.txt
test.py

*.pyc

data/*

result/*
9 changes: 9 additions & 0 deletions .ipynb_checkpoints/OfflineTest-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"metadata": {
"name": "",
"signature": "sha256:480a61f83fafd9111c6a52450d3a81014ae1526eb4f01a61b956bf134e17ba02"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": []
}
2,882 changes: 2,878 additions & 4 deletions DataExploration.ipynb

Large diffs are not rendered by default.

687 changes: 687 additions & 0 deletions OfflineTest.ipynb

Large diffs are not rendered by default.

Binary file added document/1202.0332v1.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions weiboPredict/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
# Author: Chen Li
import pandas as pd
import csv
import re

weibo_train_data = None
weibo_predict_data = None

def loadData():
global weibo_train_data
weibo_train_data= pd.read_csv('data/weibo_train_data.txt',sep='\t',
Expand All @@ -13,5 +16,17 @@ def loadData():
weibo_predict_data = pd.read_csv('data/weibo_predict_data.txt',sep='\t',
quoting=csv.QUOTE_NONE,names=['uid','mid','time','context'])

def genResult(file, data):
data.to_csv('result/'+file+'.csv',sep=',',float_format='%d')
data.to_csv('result/'+file+'.txt',sep=',',float_format='%d',index=False,header=False)
f=open('result/'+file+'.txt','r')
context = f.read()
f.close()
context = re.sub(',(?=\w\w)','\t',context)
context = re.sub(',(?=\d,\d,\d)','\t',context)
f=open('result/test.txt','w')
f.write(context)
f.close()

if __name__ == "__main__":
loadData()

0 comments on commit 89c2ffe

Please sign in to comment.