def compute_lcbmf_one_user(user_id):
	file_name = "lcbmf_user_"+str(user_id)
	print "loading matrix user "+str(user_id)+"..."
	data_matrix = MDataExtractor.load_matrix(user_id)
	rows_labels =  MDataExtractor.load_labels_vector(user_id)
	columns_labels = MDataExtractor.load_time_vector(user_id)
	importance_scores = MDataExtractor.load_importance_scores(user_id)
	
	print "user "+str(user_id)+" has "+str(len(rows_labels))+" features (rows) and "+str(len(columns_labels))+" realization (columns)"
	
	#compute the lcbmf
	lcbmf_comp = LCBMFComputer(data_matrix, "idf", "[0,1]", "positive, sum=1", 10)
	print "computing LCBMF for user "+str(user_id)+"..."
	lcbmf_comp.compute()
	
	
	print "constructing interpretable output for user "+str(user_id)+"..."
	lcbmf_comp.construct_rows_interpretable_output(rows_labels, disp_m)
	r_output = lcbmf_comp.rows_interpretable_output
	
	#write the result
	print "writing LCBMF result for user "+str(user_id)+"..."
	JsonLogsFileWriter.write(r_output, file_name)
	
	
	
	
	
		
	
	
	
示例#2
0
	def train(self, train_data_matrix):
		#transform of the matrix and save the transformations applied by feature (we do it here and not inside the LCBMFComupter class because we need to revert
		#back the transformation for the test set samples
		[transformed_trainset, self.transformation_scores_by_feature] = self.apply_pretransformation(train_data_matrix, self.pretransformation_name)
		
		#compute the a and b matrixes on the train set
		lcbmf = LCBMFComputer(transformed_trainset, None, self.a_constrains_name, self.b_constrains_name, self.k)
		[self.a_matrix, self.b_matrix] = lcbmf.compute()
示例#3
0
def compute_lcbmf_one_user(user_id):
    file_name = "lcbmf_user_" + str(user_id)
    print "loading matrix user " + str(user_id) + "..."
    data_matrix = MDataExtractor.load_matrix(user_id)
    rows_labels = MDataExtractor.load_labels_vector(user_id)
    columns_labels = MDataExtractor.load_time_vector(user_id)
    importance_scores = MDataExtractor.load_importance_scores(user_id)

    print "user " + str(user_id) + " has " + str(
        len(rows_labels)) + " features (rows) and " + str(
            len(columns_labels)) + " realization (columns)"

    #compute the lcbmf
    lcbmf_comp = LCBMFComputer(data_matrix, "idf", "[0,1]", "positive, sum=1",
                               10)
    print "computing LCBMF for user " + str(user_id) + "..."
    lcbmf_comp.compute()

    print "constructing interpretable output for user " + str(user_id) + "..."
    lcbmf_comp.construct_rows_interpretable_output(rows_labels, disp_m)
    r_output = lcbmf_comp.rows_interpretable_output

    #write the result
    print "writing LCBMF result for user " + str(user_id) + "..."
    JsonLogsFileWriter.write(r_output, file_name)