secretflow.ml.linear.ss_glm#
Classes:
|
- class secretflow.ml.linear.ss_glm.SSGLM(spu: SPU)[源代码]#
基类:
object
Methods:
__init__
(spu)fit_irls
(x, y, offset, weight, epochs, link, ...)Fit the model by IRLS(Iteratively reweighted least squares).
fit_sgd
(x, y, offset, weight, epochs, link, dist)Fit the model by SGD(stochastic gradient descent).
predict
(x[, o, to_pyu])Predict using the model.
- fit_irls(x: Union[FedNdarray, VDataFrame], y: Union[FedNdarray, VDataFrame], offset: Union[FedNdarray, VDataFrame], weight: Union[FedNdarray, VDataFrame], epochs: int, link: str, dist: str, tweedie_power: float = 1, scale: float = 1, eps: float = 0.0001) None [源代码]#
Fit the model by IRLS(Iteratively reweighted least squares).
- 参数:
x – {FedNdarray, VDataFrame} of shape (n_samples, n_features) Training vector, where n_samples is the number of samples and n_features is the number of features.
y – {FedNdarray, VDataFrame} of shape (n_samples,) Target vector relative to X.
offset – {FedNdarray, VDataFrame} of shape (n_samples,) Specify a column to use as the offset, Offsets are per-row “bias values” that are used during model training.
weight – {FedNdarray, VDataFrame} of shape (n_samples,) Specify a column to use for the observation weights, which are used for bias correction.
epochs – int iteration rounds.
link – str Specify a link function (Logit, Log, Reciprocal, Indentity)
dist – str Specify a probability distribution (Bernoulli, Poisson, Gamma, Tweedie)
tweedie_power –
float Tweedie distributions are a family of distributions that include normal, gamma, poisson and their combinations.
0: Specialized as normal 1: Specialized as poisson 2: Specialized as gamma (1,2): combinations of gamma and poisson
scale – float A guess value for distribution’s scale.
learning_rate – float, default=0.1 controls how much to change the model in one epoch.
batch_size – int, default=1024 how many samples use in one calculation.
iter_start_irls – int, default=0 run a few rounds of irls training as the initialization of w, 0 disable.
eps – float, default=1e-4 If the W’s change rate is less than this threshold, the model is considered to be converged, and the training stops early. 0 disable.
- fit_sgd(x: Union[FedNdarray, VDataFrame], y: Union[FedNdarray, VDataFrame], offset: Union[FedNdarray, VDataFrame], weight: Union[FedNdarray, VDataFrame], epochs: int, link: str, dist: str, tweedie_power: float = 1, scale: float = 1, learning_rate: float = 0.1, batch_size: int = 1024, iter_start_irls: int = 0, eps: float = 0.0001, decay_epoch: Optional[int] = None, decay_rate: Optional[float] = None) None [源代码]#
Fit the model by SGD(stochastic gradient descent).
- 参数:
x – {FedNdarray, VDataFrame} of shape (n_samples, n_features) Training vector, where n_samples is the number of samples and n_features is the number of features.
y – {FedNdarray, VDataFrame} of shape (n_samples,) Target vector relative to X.
offset – {FedNdarray, VDataFrame} of shape (n_samples,) Specify a column to use as the offset, Offsets are per-row “bias values” that are used during model training.
weight – {FedNdarray, VDataFrame} of shape (n_samples,) Specify a column to use for the observation weights, which are used for bias correction.
epochs – int iteration rounds.
link – str Specify a link function (Logit, Log, Reciprocal, Indentity)
dist – str Specify a probability distribution (Bernoulli, Poisson, Gamma, Tweedie)
tweedie_power –
float Tweedie distributions are a family of distributions that include normal, gamma, poisson and their combinations.
0: Specialized as normal 1: Specialized as poisson 2: Specialized as gamma (1,2): combinations of gamma and poisson
scale – float A guess value for distribution’s scale.
learning_rate – float, default=0.1 controls how much to change the model in one epoch.
batch_size – int, default=1024 how many samples use in one calculation.
iter_start_irls – int, default=0 run a few rounds of irls training as the initialization of w, 0 disable.
eps – float, default=1e-4 If the W’s change rate is less than this threshold, the model is considered to be converged, and the training stops early. 0 disable.
decay_rate (decay_epoch /) – int, default=None decay learning rate, learning_rate * (decay_rate ** floor(epoch / decay_epoch)). None disable
- predict(x: Union[FedNdarray, VDataFrame], o: Optional[Union[FedNdarray, VDataFrame]] = None, to_pyu: Optional[PYU] = None) Union[SPUObject, PYUObject] [源代码]#
Predict using the model.
- 参数:
x – {FedNdarray, VDataFrame} of shape (n_samples, n_features) Predict samples.
o – {FedNdarray, VDataFrame} of shape (n_samples,) Specify a column to use as the offset as per-row “bias values” use in predict
to_pyu – the prediction initiator if not None predict result is reveal to to_pyu device and save as FedNdarray otherwise, keep predict result in secret and save as SPUObject.
- 返回:
pred scores in SPUObject, shape (n_samples,)
secretflow.ml.linear.ss_glm.model#
Classes:
|
- class secretflow.ml.linear.ss_glm.model.SSGLM(spu: SPU)[源代码]#
基类:
object
Methods:
__init__
(spu)fit_irls
(x, y, offset, weight, epochs, link, ...)Fit the model by IRLS(Iteratively reweighted least squares).
fit_sgd
(x, y, offset, weight, epochs, link, dist)Fit the model by SGD(stochastic gradient descent).
predict
(x[, o, to_pyu])Predict using the model.
- fit_irls(x: Union[FedNdarray, VDataFrame], y: Union[FedNdarray, VDataFrame], offset: Union[FedNdarray, VDataFrame], weight: Union[FedNdarray, VDataFrame], epochs: int, link: str, dist: str, tweedie_power: float = 1, scale: float = 1, eps: float = 0.0001) None [源代码]#
Fit the model by IRLS(Iteratively reweighted least squares).
- 参数:
x – {FedNdarray, VDataFrame} of shape (n_samples, n_features) Training vector, where n_samples is the number of samples and n_features is the number of features.
y – {FedNdarray, VDataFrame} of shape (n_samples,) Target vector relative to X.
offset – {FedNdarray, VDataFrame} of shape (n_samples,) Specify a column to use as the offset, Offsets are per-row “bias values” that are used during model training.
weight – {FedNdarray, VDataFrame} of shape (n_samples,) Specify a column to use for the observation weights, which are used for bias correction.
epochs – int iteration rounds.
link – str Specify a link function (Logit, Log, Reciprocal, Indentity)
dist – str Specify a probability distribution (Bernoulli, Poisson, Gamma, Tweedie)
tweedie_power –
float Tweedie distributions are a family of distributions that include normal, gamma, poisson and their combinations.
0: Specialized as normal 1: Specialized as poisson 2: Specialized as gamma (1,2): combinations of gamma and poisson
scale – float A guess value for distribution’s scale.
learning_rate – float, default=0.1 controls how much to change the model in one epoch.
batch_size – int, default=1024 how many samples use in one calculation.
iter_start_irls – int, default=0 run a few rounds of irls training as the initialization of w, 0 disable.
eps – float, default=1e-4 If the W’s change rate is less than this threshold, the model is considered to be converged, and the training stops early. 0 disable.
- fit_sgd(x: Union[FedNdarray, VDataFrame], y: Union[FedNdarray, VDataFrame], offset: Union[FedNdarray, VDataFrame], weight: Union[FedNdarray, VDataFrame], epochs: int, link: str, dist: str, tweedie_power: float = 1, scale: float = 1, learning_rate: float = 0.1, batch_size: int = 1024, iter_start_irls: int = 0, eps: float = 0.0001, decay_epoch: Optional[int] = None, decay_rate: Optional[float] = None) None [源代码]#
Fit the model by SGD(stochastic gradient descent).
- 参数:
x – {FedNdarray, VDataFrame} of shape (n_samples, n_features) Training vector, where n_samples is the number of samples and n_features is the number of features.
y – {FedNdarray, VDataFrame} of shape (n_samples,) Target vector relative to X.
offset – {FedNdarray, VDataFrame} of shape (n_samples,) Specify a column to use as the offset, Offsets are per-row “bias values” that are used during model training.
weight – {FedNdarray, VDataFrame} of shape (n_samples,) Specify a column to use for the observation weights, which are used for bias correction.
epochs – int iteration rounds.
link – str Specify a link function (Logit, Log, Reciprocal, Indentity)
dist – str Specify a probability distribution (Bernoulli, Poisson, Gamma, Tweedie)
tweedie_power –
float Tweedie distributions are a family of distributions that include normal, gamma, poisson and their combinations.
0: Specialized as normal 1: Specialized as poisson 2: Specialized as gamma (1,2): combinations of gamma and poisson
scale – float A guess value for distribution’s scale.
learning_rate – float, default=0.1 controls how much to change the model in one epoch.
batch_size – int, default=1024 how many samples use in one calculation.
iter_start_irls – int, default=0 run a few rounds of irls training as the initialization of w, 0 disable.
eps – float, default=1e-4 If the W’s change rate is less than this threshold, the model is considered to be converged, and the training stops early. 0 disable.
decay_rate (decay_epoch /) – int, default=None decay learning rate, learning_rate * (decay_rate ** floor(epoch / decay_epoch)). None disable
- predict(x: Union[FedNdarray, VDataFrame], o: Optional[Union[FedNdarray, VDataFrame]] = None, to_pyu: Optional[PYU] = None) Union[SPUObject, PYUObject] [源代码]#
Predict using the model.
- 参数:
x – {FedNdarray, VDataFrame} of shape (n_samples, n_features) Predict samples.
o – {FedNdarray, VDataFrame} of shape (n_samples,) Specify a column to use as the offset as per-row “bias values” use in predict
to_pyu – the prediction initiator if not None predict result is reveal to to_pyu device and save as FedNdarray otherwise, keep predict result in secret and save as SPUObject.
- 返回:
pred scores in SPUObject, shape (n_samples,)