Skip to main content

SemiSupervised

Describe

This is a Semi-supervised learning framework of Python. You can use it for classification task in machine learning.

Install

pip install semisupervised

API

We have implemented following semi-supervised learning algorithm.

  • LabelPropagation

reference code

  • S3VM

reference code

Statement

Some of the code comes from the Internet.

Examples

from __future__ import absolute_import
import numpy as np
from sklearn import datasets
from sklearn import metrics
from sklearn.model_selection import train_test_split

# normalization
def normalize(x):
    return (x - np.min(x))/(np.max(x) - np.min(x))

def get_data():
    X, y = datasets.load_breast_cancer(return_X_y=True)
    X = normalize(X)
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.6, random_state = 0)
    rng = np.random.RandomState(42)
    random_unlabeled_points = rng.rand(len(X_train)) < 0.1
    y_train[random_unlabeled_points] = -1
    #
    index, = np.where(y_train != -1)
    label_X_train = X_train[index,:]
    label_y_train = y_train[index]
    index, = np.where(y_train == -1)
    unlabel_X_train = X_train[index,:]
    unlabel_y = -1*np.ones(unlabel_X_train.shape[0]).astype(int)
    return label_X_train, label_y_train, unlabel_X_train, unlabel_y, X_test, y_test

label_X_train, label_y_train, unlabel_X_train, unlabel_y, X_test, y_test = get_data()

# import
from semisupervised import SKTSVM

model = SKTSVM()
model.fit(np.vstack((label_X_train, unlabel_X_train)), np.append(label_y_train, unlabel_y))
# predict
predict = model.predict(X_test)
acc = metrics.accuracy_score(y_test, predict)
# metric
print("accuracy", acc)

Metadata

Release files for semisupervised 0.0.28

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for semisupervised 0.0.28
File Size Uploaded
semisupervised-0.0.28.tar.gz 20.9 kB Details

Release files / semisupervised-0.0.28.tar.gz

Download URL semisupervised-0.0.28.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9cf912ba2ed6ee990b44046eb55c69bbe79ce1dd479ebcb159cb65fa13bec3ca
BLAKE2b-256 checksum
How to use checksums
f8a171e1fbc1987e9b7f51160405c9e9148247658033d8692ae0db8b1913de47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.6

Release history Release notifications | RSS feed

This release

0.0.28 This release

1 release file

0.0.27

1 release file

0.0.26

1 release file

0.0.25

1 release file

0.0.24

1 release file

0.0.23

1 release file

0.0.22

1 release file

0.0.21

1 release file

0.0.20

1 release file

0.0.19

1 release file

0.0.18

1 release file

0.0.17

1 release file

0.0.16

1 release file

0.0.15

1 release file

0.0.14

1 release file

0.0.13

1 release file

0.0.12

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page