Пример #1
0
def build_X_y(acount_name):

    fourNumControler = FourNumControler(acount_name)
    X = []
    y = []

    labels = range(0, 500, 100)
    print(len(labels))

    def make_class(num, labels):
        for index, label in enumerate(labels):
            if num < label:
                return index
        return len(labels)

    for four_num in fourNumControler.load_four_num():
        tweets = four_num[1]
        following = four_num[2]
        followers = four_num[3]
        favorites = four_num[4]
        X.append([tweets, following, favorites])

        followers_labeled = make_class(followers, labels)
        print(followers_labeled)
        y.append(followers_labeled)
    return X, y, ["tweets", "following", "favorites"]
Пример #2
0
def checkFourNumDataBank(acount_name):
    acountPickleControler = FourNumControler(acount_name)
    count = 0
    for i in acountPickleControler.load_four_num():
        print(i)
        count += 1
    print(count)
Пример #3
0
    def build_X(self):
        """
        return two data
        X and ["tweets", "following", "follower", "favorites"]
        """
        fourNumControler = FourNumControler(self.acount_name)
        X = []

        def make_class(num, labels):
            for index, label in enumerate( labels ):
                if num < label:
                    return index
            return len(labels)

        for four_num in fourNumControler.load_four_num():
            tweets = four_num[1]
            following = four_num[2]
            followers = four_num[3] 
            favorites = four_num[4]
            X.append( [tweets, following, followers, favorites] )

        return X, ["tweets", "following", "follower", "favorites"]
Пример #4
0
import pickle
import pprint
from queue import Queue
import traceback

Data = []
acount_name = "@viser0322"

q = Queue()

acountPickleControler = AcountPickleControler(acount_name)

for atmark_code in acountPickleControler.load_acount_database():
    q.put(atmark_code)

fourNumControler = FourNumControler(acount_name)
while not q.empty():
    atmark = q.get()
    try:
        four_num_and_atmarkcode = []

        four_num_and_atmarkcode.append(atmark)
        four_num_and_atmarkcode.extend(get_four_number_sleep1(atmark))
        print(four_num_and_atmarkcode)
        Data.append(four_num_and_atmarkcode)
        time.sleep(random.randint(0, 1))
    except KeyboardInterrupt:
        break
    except:
        q.put(atmark)
        fourNumControler.dump_four_num(Data)
from PickledDataBank.PickleControler import FourNumControler

from pprint import pprint
import numpy as np
from matplotlib.colors import ListedColormap
import matplotlib.pyplot as plt

from sklearn.cross_validation import train_test_split
from sklearn.ensemble import RandomForestClassifier

acount_name = "@kuromailserver_1"
fourNumControler = FourNumControler(acount_name)

oppi_data =  fourNumControler.load_clear_acount_database()


a_to_z = "abcdefghijklnmopqrstuvwxyz"
def get_a_to_z_num(string):
    row = []
    for char in a_to_z:
        row.append( string.count(char) )
    return row



X = []
y = []
for i, row in enumerate( oppi_data ):
    acount = row[0]
    X.append( get_a_to_z_num(acount) )