# Protocol Documentation

## Table of Contents

## algorithm_id.proto

Top

### AlgorithmId

Name | Number | Description
UNKNOWN_ALGORITHM | 0 |
Neal2 | 1 |
Neal3 | 2 |
Neal8 | 3 |
BlockedGibbs | 4 |
SplitMerge | 5 |
Slice | 6 |

## algorithm_params.proto

Top

### AlgorithmParams

Field | Type | Label | Description
algo_id | string |  |
rng_seed | uint32 |  |
iterations | uint32 |  |
burnin | uint32 |  |
init_num_clusters | uint32 |  |
neal8_n_aux | uint32 |  |

## algorithm_state.proto

Top

### AlgorithmState

Field | Type | Label | Description
cluster_states | AlgorithmState.ClusterState | repeated |
cluster_allocs | int32 | repeated |
mixing_state | MixingState |  |
iteration_num | int32 |  |

### AlgorithmState.ClusterState

Field | Type | Label | Description
uni_ls_state | UniLSState |  |
multi_ls_state | MultiLSState |  |
lin_reg_uni_ls_state | LinRegUniLSState |  |
cardinality | int32 |  |

## distribution.proto

Top

### BetaDistribution

Field | Type | Label | Description
shape_a | double |  |
shape_b | double |  |

### GammaDistribution

Field | Type | Label | Description
shape | double |  |
rate | double |  |

### InvWishartDistribution

Field | Type | Label | Description
deg_free | double |  |
scale | Matrix |  |

### MultiNormalDistribution

Field | Type | Label | Description
mean | Vector |  |
var | Matrix |  |

### UniNormalDistribution

Field | Type | Label | Description
mean | double |  |
var | double |  |

## hierarchy_id.proto

Top

### HierarchyId

Name | Number | Description
UNKNOWN_HIERARCHY | 0 |
NNIG | 1 |
NNW | 2 |
LinRegUni | 3 |

## hierarchy_prior.proto

Top

### LinRegUniPrior

Field | Type | Label | Description
fixed_values | LinRegUniPrior.FixedValues |  |

### LinRegUniPrior.FixedValues

Field | Type | Label | Description
mean | Vector |  |
var_scaling | Matrix |  |
shape | double |  |
scale | double |  |

### NNIGPrior

Field | Type | Label | Description
fixed_values | NNIGPrior.FixedValues |  |
normal_mean_prior | NNIGPrior.NormalMeanPrior |  |
ngg_prior | NNIGPrior.NGGPrior |  |

### NNIGPrior.FixedValues

Field | Type | Label | Description
mean | double |  |
var_scaling | double |  |
shape | double |  |
scale | double |  |

### NNIGPrior.NGGPrior

Field | Type | Label | Description
mean_prior | UniNormalDistribution |  |
var_scaling_prior | GammaDistribution |  |
shape | double |  |
scale_prior | GammaDistribution |  |

### NNIGPrior.NormalMeanPrior

Field | Type | Label | Description
mean_prior | UniNormalDistribution |  |
var_scaling | double |  |
shape | double |  |
scale | double |  |

### NNWPrior

Field | Type | Label | Description
fixed_values | NNWPrior.FixedValues |  |
normal_mean_prior | NNWPrior.NormalMeanPrior |  |
ngiw_prior | NNWPrior.NGIWPrior |  |

### NNWPrior.FixedValues

Field | Type | Label | Description
mean | Vector |  |
var_scaling | double |  |
deg_free | double |  |
scale | Matrix |  |

### NNWPrior.NGIWPrior

Field | Type | Label | Description
mean_prior | MultiNormalDistribution |  |
var_scaling_prior | GammaDistribution |  |
deg_free | double |  |
scale_prior | InvWishartDistribution |  |

### NNWPrior.NormalMeanPrior

Field | Type | Label | Description
mean_prior | MultiNormalDistribution |  |
var_scaling | double |  |
deg_free | double |  |
scale | Matrix |  |

## ls_state.proto

Top

### LinRegUniLSState

Field | Type | Label | Description
regression_coeffs | Vector |  |
var | double |  |

### MultiLSState

Field | Type | Label | Description
mean | Vector |  |
prec | Matrix |  |
prec_chol | Matrix |  |

### UniLSState

Field | Type | Label | Description
mean | double |  |
var | double |  |

## matrix.proto

Top

### Matrix

Field | Type | Label | Description
rows | int32 |  |
cols | int32 |  |
data | double | repeated |
rowmajor | bool |  |

### Vector

Field | Type | Label | Description
size | int32 |  |
data | double | repeated |

## mixing_id.proto

Top

### MixingId

Name | Number | Description
UNKNOWN_MIXING | 0 |
DP | 1 |
PY | 2 |
LogSB | 3 |
TruncSB | 4 |

## mixing_prior.proto

Top

### DPPrior

Field | Type | Label | Description
fixed_value | DPPrior.FixedValue |  |
gamma_prior | DPPrior.GammaPrior |  |

### DPPrior.FixedValue

Field | Type | Label | Description
totalmass | double |  |

### DPPrior.GammaPrior

Field | Type | Label | Description
totalmass_prior | GammaDistribution |  |

### LogSBPrior

Field | Type | Label | Description
normal_prior | MultiNormalDistribution |  |
step_size | double |  | TODO move?
num_components | uint32 |  |

### PYPrior

Field | Type | Label | Description
fixed_values | PYPrior.FixedValues |  |

### PYPrior.FixedValues

Field | Type | Label | Description
strength | double |  |
discount | double |  |

### TruncSBPrior

Field | Type | Label | Description
beta_priors | TruncSBPrior.BetaPriors |  |
dp_prior | TruncSBPrior.DPPrior |  |
py_prior | TruncSBPrior.PYPrior |  |
num_components | uint32 |  |

### TruncSBPrior.BetaPriors

Field | Type | Label | Description
beta_distributions | BetaDistribution | repeated |

### TruncSBPrior.DPPrior

Field | Type | Label | Description
totalmass | double |  |

### TruncSBPrior.PYPrior

Field | Type | Label | Description
strength | double |  |
discount | double |  |

## mixing_state.proto

Top

### DPState

Field | Type | Label | Description
totalmass | double |  |

### LogSBState

Field | Type | Label | Description
regression_coeffs | Matrix |  |

### MixingState

Field | Type | Label | Description
dp_state | DPState |  |
py_state | PYState |  |
log_sb_state | LogSBState |  |
trunc_sb_state | TruncSBState |  |

### PYState

Field | Type | Label | Description
strength | double |  |
discount | double |  |

### TruncSBState

Field | Type | Label | Description
sticks | Vector |  |
logweights | Vector |  |

## semihdp.proto

Top

### SemiHdpParams

Field | Type | Label | Description
pseudo_prior | SemiHdpParams.PseudoPriorParams |  |
dirichlet_concentration | double |  |
rest_allocs_update | string |  | Either "full", "metro_base", "metro_dist"
totalmass_rest | double |  |
totalmass_hdp | double |  |
w_prior | SemiHdpParams.WPriorParams |  |

### SemiHdpParams.PseudoPriorParams

Field | Type | Label | Description
card_weight | double |  |
mean_perturb_sd | double |  |
var_perturb_frac | double |  |

### SemiHdpParams.WPriorParams

Field | Type | Label | Description
shape1 | double |  |
shape2 | double |  |

### SemiHdpState

Field | Type | Label | Description
restaurants | SemiHdpState.RestaurantState | repeated |
groups | SemiHdpState.GroupState | repeated |
taus | SemiHdpState.ClusterState | repeated |
c | int32 | repeated |
w | double |  |

### SemiHdpState.ClusterState

Field | Type | Label | Description
uni_ls_state | UniLSState |  |
multi_ls_state | MultiLSState |  |
lin_reg_uni_ls_state | LinRegUniLSState |  |
cardinality | int32 |  |

### SemiHdpState.GroupState

Field | Type | Label | Description
cluster_allocs | int32 | repeated |

### SemiHdpState.RestaurantState

Field | Type | Label | Description
theta_stars | SemiHdpState.ClusterState | repeated |
n_by_clus | int32 | repeated |
table_to_shared | int32 | repeated |
table_to_idio | int32 | repeated |

## Scalar Value Types

.proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby
double |  | double | double | float | float64 | double | float | Float
float |  | float | float | float | float32 | float | float | Float
int32 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required)
int64 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. | int64 | long | int/long | int64 | long | integer/string | Bignum
uint32 | Uses variable-length encoding. | uint32 | int | int/long | uint32 | uint | integer | Bignum or Fixnum (as required)
uint64 | Uses variable-length encoding. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum or Fixnum (as required)
sint32 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required)
sint64 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. | int64 | long | int/long | int64 | long | integer/string | Bignum
fixed32 | Always four bytes. More efficient than uint32 if values are often greater than 2^28. | uint32 | int | int | uint32 | uint | integer | Bignum or Fixnum (as required)
fixed64 | Always eight bytes. More efficient than uint64 if values are often greater than 2^56. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum
sfixed32 | Always four bytes. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required)
sfixed64 | Always eight bytes. | int64 | long | int/long | int64 | long | integer/string | Bignum
bool |  | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass
string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8)
bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT)