예제 #1
0
def checker():
    # Connect to mongodb
    db, connection = dbHandler.connectDB()

    # Show which users' tweets in the db
    print("• Users that the db contains: ")
    twitter_users = list(db.retweetPrediction.find().distinct("username"))
    twitter_users.sort()

    print(twitter_users, end=' -- ')
    print(len(twitter_users))

    # Disconnect to mongodb
    dbHandler.closeDB(connection)
        date = np.array(date)

        fig = plt.figure()
        ax1 = fig.add_subplot(1, 1, 1)
        ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y'))
        ax1.plot(date, retweets, 'g.', fillstyle='none')
        ax1.plot(date,
                 normalNumberofRetweets,
                 'r.',
                 label='Theil-Sen',
                 markersize=2.0)
        ax1.plot(date,
                 normalNumberofRetweetsHUBER,
                 'b.',
                 label='Huber Loss',
                 markersize=2.0)
        ax1.legend(loc='best', frameon=False)
        plt.title('User ' + str(user))
        plt.xlabel('date')
        plt.ylabel('Number of Retweets')
        fig.autofmt_xdate(rotation=45)
        # pylab.show()
        # manager = plt.get_current_fig_manager()
        # manager.frame.Maximize(True)
        plt.tight_layout()
        plt.savefig(str(user) + ".png")
        plt.clf()

    # Disconnect to mongodb
    dbHandler.closeDB(connection)