Welcome to Feature Vector Matrix’s documentation!¶
Contents:
Feature Vector Matrix¶


Python class to encapsulate different representations of large datasets
- Free software: BSD license
- Documentation: https://featurevectormatrix.readthedocs.org.
Features¶
- Python class to encapsulate different representations of large datasets
- Rows can be inserted as python dictionaries or arrays
- They can be pulled out as dictionaries or arrays
Installation¶
At the command line:
$ easy_install featurevectormatrix
Or, if you have virtualenvwrapper installed:
$ mkvirtualenv featurevectormatrix
$ pip install featurevectormatrix
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/talentpair/featurevectormatrix/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implement it.
Write Documentation¶
Feature Vector Matrix could always use more documentation, whether as part of the official Feature Vector Matrix docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/talentpair/featurevectormatrix/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up featurevectormatrix for local development.
Fork the featurevectormatrix repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/featurevectormatrix.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv featurevectormatrix $ cd featurevectormatrix/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 --config=flake8.cfg . $ python setup.py test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.7. Check https://travis-ci.org/talentpair/featurevectormatrix/pull_requests and make sure that the tests pass for all supported Python versions.
Credits¶
Development Lead¶
- Jeremy Robin <jeremy.robin@gmail.com>
Contributors¶
None yet. Why not be the first?
History¶
0.1.1 (2014-09-12)¶
- Improve import path
0.1.0 (2014-09-12)¶
- First release on PyPI.
featurevectormatrix¶
featurevectormatrix package¶
Module contents¶
- class featurevectormatrix.FeatureVectorMatrix(default_value=0, default_to_hashed_rows=False, rows=None)[source]¶
Bases: object
A class to abstract away the differences in internal representation between dictionaries and lists that can matter for very large datasets of vectors and allow them to work seamlessly with each other
Supports indexing and iteration (fvm[1] and for i in fvm:...) but you should set default_to_hash_rows to get the expected behavior. Also supports len
- add_row(list_or_dict, key=None)[source]¶
Adds a list or dict as a row in the FVM data structure
Parameters: - key (str) – key used when rows is a dict rather than an array
- list_or_dict – a feature list or dict
- default_to_hashed_rows(default=None)[source]¶
Gets the current setting with no parameters, sets it if a boolean is passed in
Parameters: default – the value to set Returns: the current value, or new value if default is set to True or False
- extend_rows(list_or_dict)[source]¶
Add multiple rows at once
Parameters: list_or_dict – a 2 dimensional structure for adding multiple rows at once Returns:
- get_matrix()[source]¶
Use numpy to create a real matrix object from the data
Returns: the matrix representation of the fvm
- get_row_dict(row_idx)[source]¶
Return a dictionary representation for a matrix row
Parameters: row_idx – which row Returns: a dict of feature keys/values, not including ones which are the default value
- get_row_list(row_idx)[source]¶
get a feature vector for the nth row
Parameters: row_idx – which row Returns: a list of feature values, ordered by column_names
- keys()[source]¶
Returns all row keys
Raises NotImplementedError: if all rows aren’t keyed Returns: all row keys
- set_column_names(column_names)[source]¶
Setup the feature vector with some column names :param column_names: the column names we want :return: