myfm.MyFMOrderedProbit¶
- class myfm.MyFMOrderedProbit(rank: int, init_stdev: float = 0.1, random_seed: int = 42, alpha_0: float = 1, beta_0: float = 1, gamma_0: float = 1, mu_0: float = 0, reg_0: float = 1, fit_w0: bool = True, fit_linear: bool = True)[source]¶
Bases:
myfm.gibbs.MyFMGibbsBase
Bayesian Factorization Machines for Ordinal Regression Tasks.
- __init__(rank: int, init_stdev: float = 0.1, random_seed: int = 42, alpha_0: float = 1, beta_0: float = 1, gamma_0: float = 1, mu_0: float = 0, reg_0: float = 1, fit_w0: bool = True, fit_linear: bool = True)[source]¶
Setup the configuration.
- Parameters
rank (int) – The number of factors.
init_stdev (float, optional (defalult = 0.1)) – The standard deviation for initialization. The factorization machine weights are randomely sampled from Normal(0, init_stdev ** 2).
random_seed (integer, optional (default = 0.1)) – The random seed used inside the whole learning process.
alpha_0 (float, optional (default = 1.0)) – The half of alpha parameter for the gamma-distribution prior for alpha, lambda_w and lambda_V. Together with beta_0, the priors for these parameters are alpha, lambda_w, lambda_v ~ Gamma(alpha_0 / 2, beta_0 / 2)
beta_0 (float, optional (default = 1.0)) – See the explanation for alpha_0 .
gamma_0 (float, optional (default = 1.0)) – Inverse variance of the prior for mu_w, mu_v. Together with mu_0, the priors for these parameters are mu_w, mu_v ~ Normal(mu_0, 1 / gamma_0)
mu_0 (float, optional (default = 0.0)) – See the explanation for gamma_0.
reg_0 (float, optional (default = 0.0)) – Inverse variance of the prior for w0. w0 ~ Normal(0, 1 / reg_0)
fit_w0 (bool, optional (default = True)) – whether to fit w0, by default True.
fit_linear (bool, optional (default = True)) – whether to fit linear coefficients, by default True.
Methods
__init__
(rank[, init_stdev, random_seed, ...])Setup the configuration.
fit
(X, y[, X_rel, X_test, y_test, ...])get_hyper_trace
()predict
(X[, X_rel])Predict the class outcome according to the class probability.
predict_proba
(X[, X_rel, n_workers])Compute the ordinal class probability.
Attributes
Obtain the Gibbs samples for factorized quadratic coefficient V.
Obtain samples for the cutpoints.
Obtain samples for global bias w0.
Obtain the Gibbs samples for linear coefficients w.
- property V_samples: Optional[object]¶
Obtain the Gibbs samples for factorized quadratic coefficient V. Returns None if the model is not fit yet.
- Returns:
Samples for lienar coefficients. The first dimension is for the sample index, the second for the feature index, and the third for the factorized dimension.
- property cutpoint_samples: Optional[object]¶
Obtain samples for the cutpoints. If the model is not fit yet, return None.
- Returns:
Samples for cutpoints.
- predict(X: Union[numpy.ndarray, scipy.sparse.csr.csr_matrix], X_rel: List[myfm._myfm.RelationBlock] = []) object [source]¶
Predict the class outcome according to the class probability.
- Parameters
X (array_like) – The input data.
X_rel (List[RelationBlock], optional) – Relational Block part of the data., by default []
- Returns
The class prediction
- Return type
np.int64
- predict_proba(X: Union[numpy.ndarray, scipy.sparse.csr.csr_matrix], X_rel: List[myfm._myfm.RelationBlock] = [], n_workers: Optional[int] = None) numpy.ndarray [source]¶
Compute the ordinal class probability.
- Parameters
X (array_like) – The input data.
X_rel (List[RelationBlock], optional) – Relational Block part of the data., by default []
- Returns
The class probability
- Return type
np.float
- property w0_samples: Optional[object]¶
Obtain samples for global bias w0. If the model is not fit yet, return None.
- Returns:
Samples for lienar coefficients.
- property w_samples: Optional[object]¶
Obtain the Gibbs samples for linear coefficients w. Returns None if the model is not fit yet.
- Returns:
Samples for lienar coefficients. The first dimension is for the sample index, and the second for the feature index.