Example #1
0
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 20 20:46:26 2016

@author: ZJun
"""

from twitter_function import Import_Obj, GenerateDate, hinton

df_flu_related_twitter_in_place_loc = Import_Obj(
    './DF_Result/df_flu_related_twitter_in_place_loc')
df_twitter_in_place_loc = Import_Obj('./DF_Result/df_twitter_in_place_loc')
df_move_destination_in_place_loc = Import_Obj(
    './DF_Result/df_move_destination_in_place_loc')
df_flu_related_move_destination_in_place_loc = Import_Obj(
    './DF_Result/df_flu_related_move_destination_in_place_loc')
df_real_flu = Import_Obj('./DF_Result/df_real_flu')
df_where_to_where = Import_Obj('./DF_Result/df_where_to_where')
df_flu_where_to_where = Import_Obj('./DF_Result/df_flu_where_to_where')


def GetTransferProbability(df_where_to_where, df_twitter_in_place_loc):

    all_where_to_where = df_where_to_where.values[0] * 0

    for w2w in df_where_to_where.values:
        all_where_to_where += w2w

    # all_where_to_where  i to j  [i,j]

    num_all = df_twitter_in_place_loc.sum(0)
Example #2
0
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 23 19:24:30 2016

@author: ZJun
"""

from twitter_function import Import_Obj, GenerateDate, hinton, GetPartOfTimeSeries

population_2015 = dict(
    zip([
        'Cairns', 'Townsville', 'Mackay', 'Sunshine Coast', 'Brisbane',
        'Gold Coast'
    ], [147993, 180333, 85455, 302122, 2209453, 624918]))

df_flu_related_twitter_in_place_loc = Import_Obj(
    './DF_Result/df_flu_related_twitter_in_place_loc')[population_2015.keys()]
df_twitter_in_place_loc = Import_Obj('./DF_Result/df_twitter_in_place_loc')[
    population_2015.keys()]
df_move_destination_in_place_loc = Import_Obj(
    './DF_Result/df_move_destination_in_place_loc')[population_2015.keys()]
df_flu_related_move_destination_in_place_loc = Import_Obj(
    './DF_Result/df_flu_related_move_destination_in_place_loc')[
        population_2015.keys()]
df_real_flu = Import_Obj('./DF_Result/df_real_flu')[population_2015.keys()]
df_where_to_where = Import_Obj('./DF_Result/df_where_to_where')

df_flu_where_to_where = Import_Obj('./DF_Result/df_flu_where_to_where')
actual_days_in_week = Import_Obj('./Data/actual_days_in_week')

#a = df_where_to_where[GenerateDate(2015,1,12)]
#a.loc[population_2015.keys(),population_2015.keys()]
Example #3
0
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 14 22:01:06 2016

@author: ZJun
"""

from GetData import LoadData
from twitter_function import Import_Obj, GetPartOfTimeSeries, Sort_Dict_key
import pandas as pd
from GetFactors import GetTwitterInPlaceLoc, GetFluRelatedTwitterInPlaceLoc
from GetFactors import GetMoveDestinationInPlaceLoc, GetFluRelatedMoveDestinationInPlaceLoc, GetActuallDayInWeek
import matplotlib.pyplot as plt
from collections import Counter

week_move = Import_Obj('./Data/week_move')
week_user_flu_state = Import_Obj('./Data/week_user_flu_state')
Queensland_Flu = pd.read_csv('./Data/Queensland2015.csv')
from datetime import timedelta


def GetRealFlu(Queensland_Flu, location=None):
    first_week = pd.datetime(2015, 1, 5).date()
    t = [first_week]
    if location != None:
        x = Queensland_Flu[location].values
    else:
        x = Queensland_Flu.ix[:, 1:].sum(1).values
    for i in range(1, len(x)):
        t.append(first_week + timedelta(i * 7))
    ts = pd.Series(x, index=t[:len(x)])
Example #4
0
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from twitter_function import Import_Obj,GenerateDate,hinton,GetPartOfTimeSeries,Sort_Dict


n=6

population_2015 = dict(zip(['Cairns','Townsville','Mackay','Sunshine Coast','Brisbane','Gold Coast'],
                           [147993,180333,85455,302122,2209453,624918]))

     
P = Sort_Dict(population_2015)
Places = [i[0] for i in P][:n]

df_where_to_where = Import_Obj('./DF_Result/df_where_to_where')
actual_days_in_week = Import_Obj('./Data/actual_days_in_week')
df_real_flu = Import_Obj('./DF_Result/df_real_flu')[Places]
df_twitter_in_place_loc = Import_Obj('./DF_Result/df_twitter_in_place_loc')[Places]




TimeRange = [pd.datetime(2015,3,9).date(),pd.datetime(2015,10,12).date()]
            

real_flu_ = GetPartOfTimeSeries(df_real_flu,TimeRange)[Places]

Times = real_flu_.index

Example #5
0
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from twitter_function import Import_Obj, GenerateDate, hinton, GetPartOfTimeSeries, Sort_Dict

population_2015 = dict(
    zip([
        'Cairns', 'Townsville', 'Mackay', 'Sunshine Coast', 'Brisbane',
        'Gold Coast'
    ], [147993, 180333, 85455, 302122, 2209453, 624918]))

P = Sort_Dict(population_2015)
Places = [i[0] for i in P]

df_where_to_where = Import_Obj('./DF_Result/df_where_to_where')
actual_days_in_week = Import_Obj('./Data/actual_days_in_week')
df_real_flu = Import_Obj('./DF_Result/df_real_flu')[population_2015.keys()]
df_twitter_in_place_loc = Import_Obj('./DF_Result/df_twitter_in_place_loc')[
    population_2015.keys()]
'''
Queensland_Flu = pd.read_csv('./Data/Queensland2015.csv')
from datetime import timedelta
def GetRealFlu(Queensland_Flu,location=None):
    first_week = pd.datetime(2015,1,5).date()
    t = [first_week]
    if location != None:        
        x = Queensland_Flu[location].values
    else:
        x = Queensland_Flu.ix[:,1:].sum(1).values
    for i in range(1,len(x)):