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 class. 

KFolds crossvalidator 

Stratified KFolds crossvalidator 
Functions:

Accuracy classification score. 

Converts a PIL Image instance to a Numpy array. 
Amazon product copurchasing network and groundtruth communities. 

Boston House Prices Dataset. 

DIC28 Dataset from Pajek. 

Hand Geometry Dataset. 


Loads an image into PIL format. 
Iris Dataset. 

Ratings from the Jester Online Joke Recommender System. 

20 News Groups Dataset. 

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

Personae Dataset. 

UMLs Dataset. 

USPs Digits Dataset. 

Challenge Dataset for OpenDomain Question Answering. 


Normalized Mutual Information between two clusterings. 

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

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 goodnesoffit 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
arraylike

target
¶ Numpy array or pandas Series containing the expected labels or values
 Type
arraylike

**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 (arraylike) – Numpy array or pandas DataFrame containing all the data of this dataset, excluding the labels or target values.
target (arraylike) – 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.

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


mlblocks.datasets.
load_amazon
()[source]¶ Amazon product copurchasing network and groundtruth 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 copurchased with product j, the graph contains an undirected edge from i to j. Each product category provided by Amazon defines each groundtruth community.

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_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 5050 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 OpenDomain Question Answering.
WikiQA dataset is a publicly available set of question and sentence (QS) pairs, collected and annotated for research on opendomain question answering.
source: “Microsoft” sourceURI: “https://www.microsoft.com/enus/research/publication/wikiqaachallengedatasetforopendomainquestionanswering/#”