base

Base classes for all estimators and experiments.

class s3l.base.BaseEstimator[source]

Bases: abc.ABC

Base class for all estimators in s3l. .. rubric:: Notes

All estimators should specify all the parameters that can be set at the class level in their __init__ as explicit keyword arguments (no *args or **kwargs).

get_params(deep=True)[source]

Get parameters for this estimator.

Parameters:deep (boolean, optional) – If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns:params – Parameter names mapped to their values.
Return type:mapping of string to any
set_params(param)[source]

Update the parameters of the estimator and release old results to prepare for new training.

class s3l.base.BaseExperiments(transductive=True, n_jobs=1, all_class=True)[source]

Bases: object

The base class for all experiments. You can inherit this class to design you own experiment process.

append_configs(configs)[source]

Append estimators configs to self.config

Parameters:configs (list of (name, estimator, param_dict)) – In which name: string, estimator: object of estimator, param_dict: dict of parameters for corresponding estimator.
append_datasets(datasets)[source]

Append datasets file names to self.datasets

Parameters:datasets (list of (name,feature_file,label_file,split_path,graph_file)) –

Detais:

name: string
    Name of the dataset. Arbitrary
feature_file: string or None
    Absolute file name of the feature file. Can be any thing if
label_file: string or None
    Absolute file name of the label file.
split_path: string or None
    Absolute path in which store the split files. Should be None if
    no split files is provided.
graph_file: string or None
    Absolute file name of the graph files. Should be None if no
    graph is provided.
append_evaluate_metric(performance_metric='accuracy_score', kwargs={})[source]

Append the metric for evaluation.

Parameters:
  • performace_metric (str) – The query performance-metric function. Giving str to use a pre-defined performance-metric.
  • kwargs (dict, optional) – The args used in performance-metric. if kwargs is None,the pre-defined performance will init in the default way. Note that, each parameters should be static.
get_evaluation_results()[source]
set_metric(performance_metric='accuracy_score', metric_large_better=True, param_dict=None)[source]

Set the metric for experiment.

Parameters:
  • performace_metric (str) – The query performance-metric function. Giving str to use a pre-defined performance-metric.
  • kwargs (dict, optional) – The args used in performance-metric. if kwargs is None,the pre-defined performance will init in the default way. Note that, each parameters should be static.
class s3l.base.InductiveEstimatorWOGraph[source]

Bases: s3l.base.BaseEstimator

fit(X, y, l_ind, **kwargs)[source]

Takes X, y, label_index

predict(X, **kwargs)[source]

Takes X

class s3l.base.InductiveEstimatorwithGraph[source]

Bases: s3l.base.BaseEstimator

fit(X, y, l_ind, W, **kwargs)[source]

Takes X, y, label_index, affinity matrix

predict(X, **kwargs)[source]

Takes X

class s3l.base.SaferEnsemble[source]

Bases: s3l.base.BaseEstimator

Base class for SaferEnsemble for semi-supervised learning. .. rubric:: Notes

All estimators should specify all the parameters that can be set at the class level in their __init__ as explicit keyword arguments (no *args or **kwargs).

fit(X, y, l_ind, **kwargs)[source]

Fit the model with base semi-supervised predictions.

predict(u_ind, baseline_pred=None)[source]

Should provide baseline prediction. Can only make safer prediction with given ones, so it’s transductive.

class s3l.base.SupervisedEstimator[source]

Bases: s3l.base.BaseEstimator

Supervised estimator of single-label task.

fit(X, y, l_ind=None, **kwargs)[source]

Takes X, y, label_index.

predict(X, **kwargs)[source]

Takes X

predict_log_proba(X)[source]
predict_proba(X)[source]
set_params(param)[source]

Update the parameters of the estimator and release old results to prepare for new training.

class s3l.base.TransductiveEstimatorWOGraph[source]

Bases: s3l.base.BaseEstimator

fit(X, y, l_ind, **kwargs)[source]

Takes X, y, label_index

predict(u_ind, **kwargs)[source]

Takes unlabel_index

class s3l.base.TransductiveEstimatorwithGraph[source]

Bases: s3l.base.BaseEstimator

fit(X, y, l_ind, W, **kwargs)[source]

Takes X, y, label_index, affinity matrix

predict(u_ind, **kwargs)[source]

Takes unlabel_index