<commit_before>import numpy as np

from matplotlib import pyplot

import mdp

import fpp

from envs import env_swiss_roll_3d

if __name__ == '__main__':

    # parameters
    k = 5
    N = 5000
    iterations = 1
    seed = None
    
    # data
    env = env_swiss_roll_3d.EnvSwissRoll3D()
    data, _, labels = env.do_random_steps(num_steps=N)

    # model    
    model = fpp.FPPnl(output_dim=2,
                      k=k,
                      iterations=iterations,
                      iteration_dim=10,
                      minimize_variance=False,
                      normalized_objective=True)

    # train & plot
            
    # current algorithm
    print "%s" % (model.__class__.__name__)

    # train
    model.train(data)
    model.stop_training()
    print model.U
    #result = model.execute(data)

    # plot
    #pyplot.subplot(1, 4, 2*e+m+1)
    pyplot.scatter(x=model.U[:-1,1], y=model.U[:-1,2], c=labels, s=50, cmap=pyplot.cm.get_cmap('Blues'))
    pyplot.title(model.__class__.__name__)

    # show plot
    print 'finish'
    pyplot.show()<commit_msg>manifold learning with linear gPFA and expansion<commit_after>import numpy as np

from matplotlib import pyplot

import mdp

import fpp

from envs.env_swiss_roll_3d import EnvSwissRoll3D

if __name__ == '__main__':

    # parameters
    k = 5
    N = 5000
    whitening = True
    iterations = 1
    expansion_degree = 2
    seed = None
    
    # data
    env = EnvSwissRoll3D()
    data, _, labels = env.do_random_steps(num_steps=N)
    
    # expansion
    expansion = mdp.nodes.PolynomialExpansionNode(degree=expansion_degree)
    data = expansion.execute(data)

    # whitening
    if whitening:
        whitening_node = mdp.nodes.WhiteningNode()
        whitening_node.train(data)
        data = whitening_node.execute(data)

    # algorithms
    model = fpp.FPP(output_dim=2,
                    k=k,
                    iterations=iterations,
                    iteration_dim=2,
                    minimize_variance=False,
                    normalized_objective=True)

    # train & plot        

    # current algorithm
    print "%s" % (model.__class__.__name__)

    # train
    model.train(data)
    result = model.execute(data)

    # plot
    pyplot.scatter(x=result[1:,0], y=result[1:,1], c=labels, s=50, cmap=pyplot.cm.get_cmap('Blues'))
    pyplot.title(model.__class__.__name__)

    # show plot
    print 'finish'
    pyplot.show()
{'fraction_non_alphanumeric': 0.09901396877567789, 'fraction_numerical': 0.016433853738701727, 'mean_word_length': 2.195538057742782, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4806827', 'n_tokens_mistral': 855, 'n_tokens_neox': 813, 'n_words': 158}