matrices Package

matrices Package

Methods for generating matrices from Paper objects and other data.

dfr Methods for generating Numpy data objects from JSTOR Data-for-Research datasets.

dfr Module

Methods for generating Numpy data objects from JSTOR Data-for-Research datasets.

array(data[, normalize, verbose]) Yields a Numpy array, along with feature-index and document-index mappings.
matrix(data[, normalize, verbose]) Yields a Numpy matrix, along with feature-index and document-index mappings.
class tethne.matrices.dfr.Map[source]

Bases: object

Maps integer indices to string values.

tethne.matrices.dfr.array(data, normalize=False, verbose=False)[source]

Yields a Numpy array, along with feature-index and document-index mappings.

Usage

>>> import tethne.readers as rd
>>> import tethne.matrices as mt
>>> data = rd.dfr.ngrams("/Path/to/DfR/data")
>>> A, doc_index, feat_index = mt.dfr.array(data, normalize=True)
Parameters :

data : dict

Keys are document identifiers (e.g. DOIs), values are lists of feature- frequency tuples.

normalize : bool

If True, matrix values are relative to the maximum value in the matrix.

Returns :

A : Numpy array

Columns are documents, rows are features.

document_index : class:.Map

Maps column indices to document identifiers (keys of provided data).

feature_index : Map

Maps row indices to features.

tethne.matrices.dfr.matrix(data, normalize=False, verbose=False)[source]

Yields a Numpy matrix, along with feature-index and document-index mappings.

Usage

>>> import tethne.readers as rd
>>> import tethne.matrices as mt
>>> data = rd.dfr.ngrams("/Path/to/DfR/data")
>>> M, doc_index, feat_index = mt.dfr.matrix(data, normalize=True)
Parameters :

data : dict

Keys are document identifiers (e.g. DOIs), values are lists of feature- frequency tuples.

normalize : bool

If True, matrix values are relative to the maximum value in the matrix.

Returns :

M : Numpy matrix

Columns are documents, rows are features.

document_index : class:.Map

Maps column indices to document identifiers (keys of provided data).

feature_index : Map

Maps row indices to features.

Table Of Contents

Previous topic

analyze Package

Next topic

networks Package

This Page