How to use the mlprimitives.datasets.Dataset function in mlprimitives

To help you get started, we’ve selected a few mlprimitives examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HDI-Project / MLPrimitives / mlprimitives / datasets.py View on Github external
def load_iris():
    """Iris dataset."""
    dataset = datasets.load_iris()
    return Dataset(load_iris.__doc__, dataset.data, dataset.target,
                   accuracy_score, 'single_table', 'classification',
                   'multiclass', stratify=True)
github HDI-Project / MLPrimitives / mlprimitives / datasets.py View on Github external
def load_personae():
    """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.
    """
    dataset_path = _load('personae')

    X = _load_csv(dataset_path, 'data')
    y = X.pop('label').values

    return Dataset(load_personae.__doc__, X, y, accuracy_score, 'text',
                   'classification', 'binary', stratify=True)
github HDI-Project / MLPrimitives / mlprimitives / datasets.py View on Github external
def load_boston_multitask():
    """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.
    """
    dataset = datasets.load_boston()
    y = dataset.target
    target = np.column_stack([y, 2 * y + 5])
    return Dataset(load_boston.__doc__, dataset.data, target, r2_score,
                   'single_table', 'regression', 'multivariate')
github HDI-Project / MLPrimitives / mlprimitives / datasets.py View on Github external
def load_usps():
    """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.
    """
    dataset_path = _load('usps')

    df = _load_csv(dataset_path, 'data')
    X = _load_images(os.path.join(dataset_path, 'images'), df.image)
    y = df.label.values

    return Dataset(load_usps.__doc__, X, y, accuracy_score, 'image',
                   'classification', 'binary', stratify=True)
github HDI-Project / MLPrimitives / mlprimitives / datasets.py View on Github external
y = X.pop('label').values

    graph1 = nx.Graph(nx.read_gml(os.path.join(dataset_path, 'graph1.gml')))
    graph2 = nx.Graph(nx.read_gml(os.path.join(dataset_path, 'graph2.gml')))

    graph = graph1.copy()
    graph.add_nodes_from(graph2.nodes(data=True))
    graph.add_edges_from(graph2.edges)
    graph.add_edges_from(X[['graph1', 'graph2']].values)

    graphs = {
        'graph1': graph1,
        'graph2': graph2,
    }

    return Dataset(load_dic28.__doc__, X, y, accuracy_score, 'graph', 'graph_matching',
                   stratify=True, graph=graph, graphs=graphs)
github HDI-Project / MLPrimitives / mlprimitives / datasets.py View on Github external
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.
    """

    dataset_path = _load('amazon')

    X = _load_csv(dataset_path, 'data')
    y = X.pop('label').values

    graph = nx.Graph(nx.read_gml(os.path.join(dataset_path, 'graph.gml')))

    return Dataset(load_amazon.__doc__, X, y, normalized_mutual_info_score, 'graph',
                   'community_detection', graph=graph)
github HDI-Project / MLPrimitives / mlprimitives / datasets.py View on Github external
def load_handgeometry():
    """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.
    """
    dataset_path = _load('handgeometry')

    df = _load_csv(dataset_path, 'data')
    X = _load_images(os.path.join(dataset_path, 'images'), df.image)
    y = df.target.values

    return Dataset(load_handgeometry.__doc__, X, y, r2_score, 'image', 'regression', 'univariate')
github HDI-Project / MLPrimitives / mlprimitives / datasets.py View on Github external
vocabulary = _load_csv(dataset_path, 'vocabulary', set_index=True)

    entities = {
        'data': (data, 'd3mIndex', None),
        'questions': (questions, 'qIndex', None),
        'sentences': (sentences, 'sIndex', None),
        'vocabulary': (vocabulary, 'index', None)
    }
    relationships = [
        ('questions', 'qIndex', 'data', 'qIndex'),
        ('sentences', 'sIndex', 'data', 'sIndex')
    ]

    target = data.pop('isAnswer').values

    return Dataset(load_wikiqa.__doc__, data, target, accuracy_score, 'multi_table',
                   'classification', 'binary', startify=True,
                   entities=entities, relationships=relationships)
github HDI-Project / MLPrimitives / mlprimitives / datasets.py View on Github external
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/"
    """

    dataset_path = _load('jester')

    X = _load_csv(dataset_path, 'data')
    y = X.pop('rating').values

    return Dataset(load_jester.__doc__, X, y, r2_score, 'single_table', 'collaborative_filtering')
github HDI-Project / MLPrimitives / mlprimitives / datasets.py View on Github external
('-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"
    """
    dataset_path = _load('reviews')

    X = _load_csv(dataset_path, 'data')
    y = X.pop('evaluation').values

    return Dataset(load_reviews.__doc__, X, y, r2_score, 'text', 'regression', 'univariate')