Example #1
0
  ell = []
  for i in range(len(theta)):
    pos = theta[i].mean
    vals,vecs = _eigsorted(theta[i].var)
    th = np.degrees(np.arctan2(*vecs[:,0][::-1]))
    for v in vol:
      width,height = 2.0*np.sqrt(chi2.ppf(v,2))*np.sqrt(vals)
      ell.append(Ellipse(xy=pos,width=width,height=height,angle=th))
  for i,e in enumerate(ell):
    ax.add_artist(e)
    e.set_facecolor(my_color_map(i))
    e.set_alpha(0.5)

  ax.set_xlim(xmin, xmax)
  ax.set_ylim(ymin, ymax)
  plt.show()

if __name__ == '__main__':
  from generate_data import generate_timeseries_set as gtss

  nStates = 4
  dim = 2
  NumTS = 5
  theta, truestates, data = gtss(nStates,dim,NumTS,minl=50, maxl=100)

  generate_Fplot(nStates,truestates)
  generate_timeseriesplot(data,truestates)
  generate_emissions(theta,data)

Example #2
0
from plotter import *
from parameters import *

# -------------------------------------------------   CREATE TOY DATA!
if __name__ == '__main__':
    print 'Creating some toy data...\n'
    nStates = 4
    numTS = 5
    dim = 2
    # First, we'll create some toy data
    #   5 sequences, each of length between 50 and 500.
    #   Each sequences selects from 4 behaviors,
    #     and switches among its selected set over time.
    #     We'll use num=4 behaviors, each of which defines a distinct Gaussian
    #     emission distribution (with dim=2 dimensions).
    emissions, trueStates, data = gtss(nStates, dim, numTS, minl=50, maxl=500)
    # Visualize the raw data time series
    # with background colored by "true" hidden state
    '''generate_timeseriesplot(data,trueStates)

  # Visualize the "true" generating parameters
  # Feat matrix F (binary numTS x nStates matrix )
  generate_Fplot(nStates,trueStates)

  # Emission parameters theta (Gaussian 2D contours)
  generate_emissions(emissions,data)

  # -------------------------------------------------   RUN MCMC INFERENCE!
  modelP = ModelParams_BPHMM(data)
  modelP.bpM.gamma = 2
Example #3
0
from plotter import *
from parameters import *

# -------------------------------------------------   CREATE TOY DATA!
if __name__ == '__main__':
  print 'Creating some toy data...\n'
  nStates = 4
  numTS   = 5
  dim     = 2
  # First, we'll create some toy data
  #   5 sequences, each of length between 50 and 500.
  #   Each sequences selects from 4 behaviors,
  #     and switches among its selected set over time.
  #     We'll use num=4 behaviors, each of which defines a distinct Gaussian
  #     emission distribution (with dim=2 dimensions).
  emissions, trueStates, data  = gtss(nStates, dim, numTS, minl=50, maxl=500)
  # Visualize the raw data time series
  # with background colored by "true" hidden state
  '''generate_timeseriesplot(data,trueStates)

  # Visualize the "true" generating parameters
  # Feat matrix F (binary numTS x nStates matrix )
  generate_Fplot(nStates,trueStates)

  # Emission parameters theta (Gaussian 2D contours)
  generate_emissions(emissions,data)

  # -------------------------------------------------   RUN MCMC INFERENCE!
  modelP = ModelParams_BPHMM(data)
  modelP.bpM.gamma = 2
Example #4
0
    ell = []
    for i in range(len(theta)):
        pos = theta[i].mean
        vals, vecs = _eigsorted(theta[i].var)
        th = np.degrees(np.arctan2(*vecs[:, 0][::-1]))
        for v in vol:
            width, height = 2.0 * np.sqrt(chi2.ppf(v, 2)) * np.sqrt(vals)
            ell.append(Ellipse(xy=pos, width=width, height=height, angle=th))
    for i, e in enumerate(ell):
        ax.add_artist(e)
        e.set_facecolor(my_color_map(i))
        e.set_alpha(0.5)

    ax.set_xlim(xmin, xmax)
    ax.set_ylim(ymin, ymax)
    plt.show()


if __name__ == '__main__':
    from generate_data import generate_timeseries_set as gtss

    nStates = 4
    dim = 2
    NumTS = 5
    theta, truestates, data = gtss(nStates, dim, NumTS, minl=50, maxl=100)

    generate_Fplot(nStates, truestates)
    generate_timeseriesplot(data, truestates)
    generate_emissions(theta, data)