mlblocks.datasets

Datasets module.

This module contains functions that allow loading datasets for easy testing of pipelines and primitives over multiple data modalities and task types.

The available datasets by data modality and task type are:

Dataset

Data Modality

Task Type

Amazon

Graph

Community Detection

DIC28

Graph

Graph Matching

UMLs

Graph

Link Prediction

Nomination

Graph

Vertex Nomination

USPS

Image

Classification

Hand Geometry

Image

Regression

Iris

Single Table

Classification

Jester

Single Table

Collaborative Filtering

Boston

Single Table

Regression

Wiki QA

Multi Table

Classification

Personae

Text

Classification

News Groups

Text

Classification

Classes:

Dataset(description, data, target, score[, …])

Dataset class.

KFold([n_splits, shuffle, random_state])

K-Folds cross-validator

StratifiedKFold([n_splits, shuffle, …])

Stratified K-Folds cross-validator

Functions:

accuracy_score(y_true, y_pred[, normalize, …])

Accuracy classification score.

img_to_array(img[, data_format, dtype])

Converts a PIL Image instance to a Numpy array.

load_amazon()

Amazon product co-purchasing network and ground-truth communities.

load_boston()

Boston House Prices Dataset.

load_dic28()

DIC28 Dataset from Pajek.

load_handgeometry()

Hand Geometry Dataset.

load_img(path[, grayscale, color_mode, …])

Loads an image into PIL format.

load_iris()

Iris Dataset.

load_jester()

Ratings from the Jester Online Joke Recommender System.

load_newsgroups()

20 News Groups Dataset.

load_nomination()

Sample 1 of graph vertex nomination data from MII Lincoln Lab.

load_personae()

Personae Dataset.

load_umls()

UMLs Dataset.

load_usps()

USPs Digits Dataset.

load_wikiqa()

Challenge Dataset for Open-Domain Question Answering.

normalized_mutual_info_score(labels_true, …)

Normalized Mutual Information between two clusterings.

r2_score(y_true, y_pred[, sample_weight, …])

R^2 (coefficient of determination) regression score function.

train_test_split(*arrays, **options)

Split arrays or matrices into random train and test subsets

class mlblocks.datasets.Dataset(description, data, target, score, shuffle=True, stratify=False, **kwargs)[source]

Dataset class.

This class represents the abstraction of a dataset and works as a container of all the things needed in order to use a dataset for testing.

Among other things, it includes the actual dataset data, information about its origin, a score function that works for this dataset, and a method to split the data in multiple ways for goodnes-of-fit evaluation.

name

Name of this dataset.

Type

str

description

Short description about the data that composes this dataset.

Type

str

data

Numpy array or pandas DataFrame containing all the data of this dataset, excluding the labels or target values.

Type

array-like

target

Numpy array or pandas Series containing the expected labels or values

Type

array-like

**kwargs

Any additional keyword argument passed on initailization is also available as instance attributes.

Parameters
  • description (str) – Short description about the data that composes this dataset. The first line of the description is expected to be a human friendly name for the dataset, and will be set as the name attribute.

  • data (array-like) – Numpy array or pandas DataFrame containing all the data of this dataset, excluding the labels or target values.

  • target (array-like) – Numpy array or pandas Series containing the expected labels or values

  • score (callable) – Function that will be used to compute the score of this dataset.

  • shuffle (bool) – Whether or not to shuffle the data before splitting.

  • stratify (bool) – Whther to use a stratified or regular KFold for splitting.

  • **kwargs – Any additional keyword argument passed on initialization will be made available as instance attributes.

Methods:

describe()

Print the description of this Dataset on stdout.

get_splits([n_splits, random_state])

Return splits of this dataset ready for Cross Validation.

score(*args, **kwargs)

Scoring function for this dataset.

describe()[source]

Print the description of this Dataset on stdout.

get_splits(n_splits=1, random_state=0)[source]

Return splits of this dataset ready for Cross Validation.

If n_splits is 1, a tuple containing the X for train and test and the y for train and test is returned. Otherwise, if n_splits is bigger than 1, a list of such tuples is returned, one for each split.

Parameters

n_splits (int) – Number of times that the data needs to be splitted.

Returns

if n_splits is 1, a tuple containing the X for train and test and the y for train and test is returned. Otherwise, if n_splits is bigger than 1, a list of such tuples is returned, one for each split.

Return type

tuple or list

score(*args, **kwargs)[source]

Scoring function for this dataset.

Parameters
  • **kwargs (*args,) – Any given arguments and keyword arguments will be

  • passed to the given scoring function. (directly) –

Returns

The computed score.

Return type

float

mlblocks.datasets.load_amazon()[source]

Amazon product co-purchasing network and ground-truth communities.

Network was collected by crawling Amazon website. It is based on Customers Who Bought This Item Also Bought feature of the Amazon website. If a product i is frequently co-purchased with product j, the graph contains an undirected edge from i to j. Each product category provided by Amazon defines each ground-truth community.

mlblocks.datasets.load_boston()[source]

Boston House Prices Dataset.

mlblocks.datasets.load_dic28()[source]

DIC28 Dataset from Pajek.

This network represents connections among English words in a dictionary. It was generated from Knuth’s dictionary. Two words are connected by an edge if we can reach one from the other by - changing a single character (e. g., work - word) - adding / removing a single character (e. g., ever - fever).

There exist 52,652 words (vertices in a network) having 2 up to 8 characters in the dictionary. The obtained network has 89038 edges.

mlblocks.datasets.load_handgeometry()[source]

Hand Geometry Dataset.

The data of this dataset is a 3d numpy array vector with shape (224, 224, 3) containing 112 224x224 RGB photos of hands, and the target is a 1d numpy float array containing the width of the wrist in centimeters.

mlblocks.datasets.load_iris()[source]

Iris Dataset.

mlblocks.datasets.load_jester()[source]

Ratings from the Jester Online Joke Recommender System.

This dataset consists of over 1.7 million instances of (user_id, item_id, rating) triples, which is split 50-50 into train and test data.

source: “University of California Berkeley, CA” sourceURI: “http://eigentaste.berkeley.edu/dataset/

mlblocks.datasets.load_newsgroups()[source]

20 News Groups Dataset.

The data of this dataset is a 1d numpy array vector containing the texts from 11314 newsgroups posts, and the target is a 1d numpy integer array containing the label of one of the 20 topics that they are about.

mlblocks.datasets.load_nomination()[source]

Sample 1 of graph vertex nomination data from MII Lincoln Lab.

Data consists of one graph whose nodes contain two attributes, attr1 and attr2. Associated with each node is a label that has to be learned and predicted.

mlblocks.datasets.load_personae()[source]

Personae Dataset.

The data of this dataset is a 2d numpy array vector containing 145 entries that include texts written by Dutch users in Twitter, with some additional information about the author, and the target is a 1d numpy binary integer array indicating whether the author was extrovert or not.

mlblocks.datasets.load_umls()[source]

UMLs Dataset.

The data consists of information about a 135 Graph and the relations between their nodes given as a DataFrame with three columns, source, target and type, indicating which nodes are related and with which type of link. The target is a 1d numpy binary integer array indicating whether the indicated link exists or not.

mlblocks.datasets.load_usps()[source]

USPs Digits Dataset.

The data of this dataset is a 3d numpy array vector with shape (224, 224, 3) containing 9298 224x224 RGB photos of handwritten digits, and the target is a 1d numpy integer array containing the label of the digit represented in the image.

mlblocks.datasets.load_wikiqa()[source]

Challenge Dataset for Open-Domain Question Answering.

WikiQA dataset is a publicly available set of question and sentence (QS) pairs, collected and annotated for research on open-domain question answering.

source: “Microsoft” sourceURI: “https://www.microsoft.com/en-us/research/publication/wikiqa-a-challenge-dataset-for-open-domain-question-answering/#”