CoTraining

class s3l.classification.CoTraining.CoTraining(pos=1, neg=1, model1=SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, decision_function_shape='ovr', degree=3, gamma='auto', kernel='rbf', max_iter=-1, probability=True, random_state=None, shrinking=True, tol=0.001, verbose=False), model2=SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, decision_function_shape='ovr', degree=3, gamma='auto', kernel='rbf', max_iter=-1, probability=True, random_state=None, shrinking=True, tol=0.001, verbose=False), ind1=array([], dtype=int64), ind2=array([], dtype=int64), nepo=40, buffer_size=200)[source]

Bases: s3l.base.InductiveEstimatorWOGraph

CoTraining classifier

Parameters:
  • pos (int (default=1)) – The number of positive samples selected in each contraining iteration
  • neg (int (default=1)) – The number of negative samples selected in each contraining iteration
  • model (object) – [model1,model2] initializing model1 for view1 and model2 for view2
  • ind1 (array-like [] (default=0)) – The column index of view1 in features X
  • ind2 (array-like [] (default=0)) – The column index of view2 in features X
  • nepo (int (default=40)) – The number of iteration
  • buffer_size (int (default=200)) – The size of buffer
model

Two best model for view1 and view2.

Type:object list
fit(X, targets, labeled_idx)[source]

Fit a cotraining model

All the input data is provided matrix X (labeled and unlabeled) and corresponding label matrix y with a dedicated marker value for unlabeled samples.

Parameters:
  • feature1 (view1 array-like, shape = [n_samples, n_features]) –
  • feature2 (view2 array_like, shape = [n_samples, n_features]) –
  • targets (array_like, shape = [n_samples]) – label of n_labeled_samples in X.
  • labeled_ind (the index of labeled data in targets.) –
  • example (For) –
Returns:

self

Return type:

returns an instance of self.

predict(X, select_1=True)[source]
Parameters:
  • X (np.ndarray, shape = [n_samples, n_features]) – samples to be predicted
  • select_1 (boolean, optional) – select the prediction of model1 and model2.
Returns:

y – Predictions for input data

Return type:

np.ndarray, shape = [n_samples]

set_params(param)[source]

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