<commit_before>import numpy as np
from dora.regressors import gp
from dora.active_sampling import GaussianProcess as GPsampler
from dora.regressors.active_sampling import GaussianProcess as GPsampler
import logging
import pickle
import visvis

log = logging.getLogger(__name__)

path = 'logs/'
filename = 'sampler_2015_09_18__17_25_06.pkl'
data = pickle.load(open(path+filename, "rb"))

# Use the redis workers to evaluate an initial batch of jobs
X_train = np.asarray(data['X'])
y_train = np.asarray(data['y']).T
n_GP_slices = y_train[0].shape[0]
lower = list(np.min(X_train,axis=0))
upper = list(np.max(X_train,axis=0))

meany = np.mean(y_train)
# y_train -= np.mean(y_train)
log.info('Init Sampler')
# import ipdb; ipdb.set_trace()
sampler = GPsampler(lower, upper, X_train, y_train, mean=meany, n_stacks=n_GP_slices,
                    add_train_data=True)
qx, qy = np.mgrid[lower[0]:upper[0]:30j, lower[1]:upper[1]:30j]


def display_results(regressors, qx, qy, grid_qry):
    n_GP_slices = len(regressors)
    shape = qx.shape
    stacks = []
    for i in range(n_GP_slices):
        regressor = regressors[i]
        qz = i*np.ones(shape)
        mu = gp.mean(regressor, grid_qry).reshape(shape).T
        # print(mu)
        stacks.append(mu)
        vol = np.array(stacks)
    plt = visvis.volshow(vol, renderStyle='mip',clim=(-5., 5.))
    plt.colormap = visvis.CM_JET  #  HOT
    a = ((regressors[0].X - np.array([np.min(qx),np.min(qy)])[np.newaxis,:])/
         np.array([np.max(qx)-np.min(qx),np.max(qy)-np.min(qy)])[np.newaxis,:])  \
        * np.array(qx.shape)
    n = a.shape[0]
    a = np.hstack((a, (n_GP_slices+0.01)*np.ones((n, 1))))
    pp = visvis.Pointset(a)
    visvis.plot(pp, ms='.', mc='w', mw='9', ls='')
    visvis.use().Run()<commit_msg>Documentation in progress: raising concern in analyser_progress.<commit_after>"""
Analyser Progress.

.. note :: DOCUMENTATION INCOMPLETE. What does this do?
"""
import logging

import pickle

from dora.active_sampling import GaussianProcess as GPsampler

from dora.regressors import gp

# Why is GPsampler in regressors?
from dora.regressors.active_sampling import GaussianProcess as GPsampler

import numpy as np

import visvis

log = logging.getLogger(__name__)

path = 'logs/'
filename = 'sampler_2015_09_18__17_25_06.pkl'
data = pickle.load(open(path + filename, "rb"))

# Use the redis workers to evaluate an initial batch of jobs
X_train = np.asarray(data['X'])
y_train = np.asarray(data['y']).T
n_GP_slices = y_train[0].shape[0]
lower = list(np.min(X_train, axis=0))
upper = list(np.max(X_train, axis=0))

meany = np.mean(y_train)
# y_train -= np.mean(y_train)
log.info('Init Sampler')
# import ipdb; ipdb.set_trace()
sampler = GPsampler(lower, upper, X_train, y_train, mean=meany,
                    n_stacks=n_GP_slices, add_train_data=True)
qx, qy = np.mgrid[lower[0]:upper[0]:30j, lower[1]:upper[1]:30j]


def display_results(regressors, qx, qy, grid_qry):
    n_GP_slices = len(regressors)
    shape = qx.shape
    stacks = []
    for i in range(n_GP_slices):
        regressor = regressors[i]
        mu = gp.mean(regressor, grid_qry).reshape(shape).T
        # print(mu)
        stacks.append(mu)
        vol = np.array(stacks)
    plt = visvis.volshow(vol, renderStyle='mip', clim=(-5., 5.))
    plt.colormap = visvis.CM_JET
    a = ((regressors[0].X - np.array([np.min(qx),
         np.min(qy)])[np.newaxis, :]) /
         np.array([np.max(qx) - np.min(qx), np.max(qy) -
                  np.min(qy)])[np.newaxis, :]) * np.array(qx.shape)
    n = a.shape[0]
    a = np.hstack((a, (n_GP_slices + 0.01) * np.ones((n, 1))))
    pp = visvis.Pointset(a)
    visvis.plot(pp, ms='.', mc='w', mw='9', ls='')
    visvis.use().Run()
{'fraction_non_alphanumeric': 0.16069021299541655, 'fraction_numerical': 0.018873011593421408, 'mean_word_length': 3.732142857142857, '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': '5383335', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1492, 'n_words': 283}