problem2.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:Machine-Learning 作者: zjuzpz 项目源码 文件源码
def solution2():
    print("Start problem 2")
    print("Start data preparation for problem 2")
    dataPreparation()
    print("Results: ")
    tags = ['tweets_#gohawks', 'tweets_#gopatriots', 'tweets_#nfl', \
    'tweets_#patriots', 'tweets_#sb49', 'tweets_#superbowl']
    #tweets, retweets, sum of followers, maximum followers, time of the day
    for tag in tags:
        tweets, parameters = [], []
        f = open('problem 2 ' + tag + ' data.txt')
        line = f.readline()
        while len(line):
            p = line.split()
            tweets.append(float(p[0]))
            parameters.append([float(p[i]) for i in range(len(p))])
            line = f.readline()
        del(tweets[0])
        next_hour_tweets = tweets
        parameters.pop()
        res = sm.OLS(next_hour_tweets, parameters).fit()
        print("Result of " + tag)
        print(res.summary())
        f.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号