mlprimitives.datasets module

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

Task Subtype

Amazon

Graph

Community Detection

DIC28

Graph

Graph Matching

UMLs

Graph

Link Prediction

Nomination

Graph

Vertex Nomination

USPS

Image

Classification

Binary

Hand Geometry

Image

Regression

Univariate

Iris

Single Table

Classification

Multiclass

Census

Single Table

Classification

Binary

Jester

Single Table

Collaborative Filtering

Boston

Single Table

Regression

Univariate

Boston Multitask

Single Table

Regression

Multivariate

Wiki QA

Multi Table

Classification

Binary

Personae

Text

Classification

Binary

News Groups

Text

Classification

Multiclass

Paper Reviews

Text

Regression

Univariate

class mlprimitives.datasets.Dataset(description, data, target, score, data_modality, task_type, task_subtype=None, shuffle=True, stratify=False, **kwargs)[source]

Bases: object

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.

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

mlprimitives.datasets.load_amazon()[source]

Amazon dataset.

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.

mlprimitives.datasets.load_boston()[source]

Boston House Prices dataset.

mlprimitives.datasets.load_boston_multitask()[source]

Boston House Prices dataset.

Modified version of the Boston dataset with a synthetic multitask output.

The multitask output is obtained by applying a linear transformation to the original y and adding it as a second output column.

mlprimitives.datasets.load_census()[source]

Adult Census dataset.

Predict whether income exceeds $50K/yr based on census data. Also known as “Adult” dataset.

Extraction was done by Barry Becker from the 1994 Census database. A set of reasonably clean records was extracted using the following conditions: ((AAGE>16) && (AGI>100) && (AFNLWGT>1)&& (HRSWK>0))

Prediction task is to determine whether a person makes over 50K a year.

source: “UCI sourceURI: “https://archive.ics.uci.edu/ml/datasets/census+income

mlprimitives.datasets.load_dataset(name)[source]
mlprimitives.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.

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

mlprimitives.datasets.load_iris()[source]

Iris dataset.

mlprimitives.datasets.load_jester()[source]

Jester dataset.

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/

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

mlprimitives.datasets.load_nomination()[source]

Nomination dataset.

Sample 1 of graph vertex nomination data from MIT 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.

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

mlprimitives.datasets.load_reviews()[source]

Paper Reviews Dataset.

The data set consists of paper reviews sent to an international conference mostly in Spanish (some are in English). It has a total of N = 405 instances evaluated with a 5-point scale (‘-2’: very negative, ‘-1’: negative, ‘0’: neutral, ‘1’: positive, ‘2’: very positive), expressing the reviewer’s opinion about the paper and the orientation perceived by a reader who does not know the reviewer’s evaluation (more details in the attributes’ section). The distribution of the original scores is more uniform in comparison to the revised scores. This difference is assumed to come from a discrepancy between the way the paper is evaluated and the way the review is written by the original reviewer.

source: “UCI sourceURI: “https://archive.ics.uci.edu/ml/datasets/Paper+Reviews

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

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

mlprimitives.datasets.load_wikiqa()[source]

WikiQA dataset.

A 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/#”