def lightlda_estimate_state(data, k, input_folder="<STR_LIT>", threads=<NUM_LIT:8>, max_iters=<NUM_LIT>, prepare_data=True, init_means=None, init_weights=None, lightlda_folder=None, data_capacity=<NUM_LIT:1000>):
if lightlda_folder is None:<EOL><INDENT>lightlda_folder = LIGHTLDA_FOLDER<EOL><DEDENT>if prepare_data:<EOL><INDENT>prepare_lightlda_data(data, input_folder, lightlda_folder)<EOL><DEDENT>if ((init_means is not None) and (init_weights is None)) or ((init_means is None) and (init_weights is not None)):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>warm_start = False<EOL>if (init_means is not None) and (init_weights is not None):<EOL><INDENT>warm_start = True<EOL>init_means = init_means/init_means.sum(<NUM_LIT:0>)<EOL>init_weights = init_weights/init_weights.sum(<NUM_LIT:0>)<EOL>create_model_file("<STR_LIT>", init_means)<EOL>create_model_file("<STR_LIT>", init_weights.T)<EOL>print(init_means)<EOL>print("<STR_LIT>")<EOL><DEDENT>print("<STR_LIT>")<EOL>train_args = (os.path.join(lightlda_folder, "<STR_LIT>"), "<STR_LIT>", str(data.shape[<NUM_LIT:0>]), "<STR_LIT>",<EOL>str(k), "<STR_LIT>", str(max_iters), "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT:2>",<EOL>"<STR_LIT>", str(threads), "<STR_LIT>", "<STR_LIT:1>", "<STR_LIT>", str(data.shape[<NUM_LIT:1>]),<EOL>"<STR_LIT>", input_folder, "<STR_LIT>", str(data_capacity))<EOL>if warm_start:<EOL><INDENT>print("<STR_LIT>")<EOL>train_args = train_args + ("<STR_LIT>",)<EOL><DEDENT>subprocess.call(train_args)<EOL>print("<STR_LIT>")<EOL>print(data.shape)<EOL>M = parse_model_file("<STR_LIT>", k, data.shape[<NUM_LIT:0>])<EOL>W = parse_result_file("<STR_LIT>", k)<EOL>M = M * (np.mean(data) / np.mean(M))<EOL>W = W/W.sum(<NUM_LIT:0>)<EOL>print("<STR_LIT>")<EOL>print(M.shape)<EOL>print(W.shape)<EOL>if sparse.issparse(data):<EOL><INDENT>ll = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>ll = poisson_objective(data, M, W)<EOL><DEDENT>return M, W, ll<EOL>
Runs LDA on the given dataset (can be an 2-D array of any form - sparse
or dense, as long as it can be indexed). If the data has not already been
prepared into LDA format, set "prepare_data" to TRUE. If "prepare_data" is
FALSE, the method assumes that the data has already been preprocessed into
LightLDA format and is located at the given "input_folder".