예제 #1
0
 def __init__(self, maker, MAX_DF=0.1, MAX_FEATURES=300, LSA_DIM=10, exclude_0=True):
     
     self.MAX_DF = MAX_DF
     self.MAX_FEATURES = MAX_FEATURES
     self.LSA_DIM = LSA_DIM
     
     self.data = db.get_maker_data(maker)
     if exclude_0:
         self.data = self.data[self.data['bids']>0]
         
     self.data = self.data[self.data['end_time'] < datetime.datetime(2014, 6, 7, 23, 59)]
     self.price = map((lambda x: x**(0.5)),  self.data['current_price'].values)
     data = self.data[['init_price', 'seller_point', 'condition']]
     data['init_price'] = data['init_price'].apply(lambda x: x**(0.5))
     data['condition'] = data['condition'].apply(condition)
     data = data.astype(float)
     
     self.title_list = []
     for i in self.data.index:
         self.title_list.append(self.data.ix[i, 'title']) 
     self.tf, self.vectorizer, self.lsa = self.to_vector(self.title_list)
     
     self.sum = np.sum(data.values**2.0, axis=0)
     self.other = Normalizer(copy=False).fit_transform(data.T).T
     self.x = np.hstack([self.tf, self.other])
예제 #2
0
    def __init__(self,
                 maker,
                 MAX_DF=0.1,
                 MAX_FEATURES=300,
                 LSA_DIM=10,
                 exclude_0=True):

        self.MAX_DF = MAX_DF
        self.MAX_FEATURES = MAX_FEATURES
        self.LSA_DIM = LSA_DIM

        self.data = db.get_maker_data(maker)
        if exclude_0:
            self.data = self.data[self.data['bids'] > 0]

        self.data = self.data[
            self.data['end_time'] < datetime.datetime(2014, 6, 4, 23, 59)]
        self.price = map((lambda x: x**(0.5)),
                         self.data['current_price'].values)
        data = self.data[['init_price', 'seller_point', 'condition']]
        data['init_price'] = data['init_price'].apply(lambda x: x**(0.5))
        data['condition'] = data['condition'].apply(condition)
        data = data.astype(float)

        self.title_list = []
        for i in self.data.index:
            self.title_list.append(self.data.ix[i, 'title'])
        self.tf, self.vectorizer, self.lsa = self.to_vector(self.title_list)

        self.sum = np.sum(data.values**2.0, axis=0)
        self.other = Normalizer(copy=False).fit_transform(data.T).T
        self.x = np.hstack([self.tf, self.other])
예제 #3
0
	def __init__(self,makers,date="2014-6-04 23:59:59",filters = True,show=False,no_below=5, no_above=0.75,num_topics=150):
		self.categoryID = categoryIDtoMaker()
		self.Auction_model ={}

		for maker in makers:
			data = get_maker_data(maker)
			data = FilterDate(data,date)
			self.Auction_model[maker] = Auction(data,maker,filters = filters,show=show,no_below=no_below, no_above=no_above)
			print "load model of ", maker
예제 #4
0
def LDA_initial(maker,
                date="2014-6-7 23:59:59",
                filters=True,
                show=False,
                no_below=5,
                no_above=0.75,
                num_topics=150):
    print "begin " + maker

    data = get_maker_data(maker)
    data = FilterDate(data, date)
    data_title = data["title"].values
    data_description = data["description"].values
    print "read data of" + maker

    title_lda = lda_parts(data_title)
    title_lda.dictionary_corpus(filter=filters,
                                show=show,
                                no_below=no_below,
                                no_above=no_above)

    #need to change
    title_lda.LDA_model(num_topics=num_topics,
                        save=("./model/" + maker + "_title.model"),
                        show=show,
                        set_matrix=False)
    print "titile's model of " + maker + " made"

    description_lda = lda_parts(data_description)
    description_lda.dictionary_corpus(filter=filters,
                                      show=show,
                                      no_below=no_below,
                                      no_above=no_above)

    #need to change
    description_lda.LDA_model(num_topics=num_topics,
                              save=("./model/" + maker + "_description.model"),
                              show=show,
                              set_matrix=False)

    print "description's model of " + maker + " made"
예제 #5
0
    def __init__(self,
                 makers,
                 date="2014-6-7 23:59:59",
                 filters=True,
                 show=False,
                 no_below=5,
                 no_above=0.75,
                 num_topics=150):
        self.categoryID = categoryIDtoMaker()
        self.Auction_model = {}

        for maker in makers:
            data = get_maker_data(maker)
            data = FilterDate(data, date)
            self.Auction_model[maker] = Auction(data,
                                                maker,
                                                filters=filters,
                                                show=show,
                                                no_below=no_below,
                                                no_above=no_above)
            print "load model of ", maker
예제 #6
0
def LDA_initial(maker,date="2014-6-04 23:59:59",filters = True,show=False,no_below=5, no_above=0.75,num_topics=150):
	print "begin "+maker

	data = get_maker_data(maker)
	data = FilterDate(data,date)
	data_title = data["title"].values
	data_description = data["description"].values
	print "read data of" + maker

	title_lda = lda_parts(data_title)
	title_lda.dictionary_corpus(filter=filters,show=show,no_below=no_below, no_above=no_above)

	#need to change
	title_lda.LDA_model(num_topics=num_topics,save=("./model/"+maker+"_title.model"),show=show,set_matrix=False)
	print "titile's model of "+maker +" made"


	description_lda = lda_parts(data_description)
	description_lda.dictionary_corpus(filter=filters,show=show,no_below=no_below, no_above=no_above)

	#need to change
	description_lda.LDA_model(num_topics=num_topics,save=("./model/"+maker+"_description.model"),show=show,set_matrix=False)
	      
	print "description's model of "+maker +" made"