Machine Learning Things
Machine Learning Things (ml_things) is a lightweight python library that contains functions and code snippets that I use in my everyday research with Machine Learning, Deep Learning, NLP.
I created this repo because I was tired of always looking up same code from older projects and I wanted to gain some experience in building a Python library. By making this available to everyone it gives me easy access to code I use frequently and it can help others in their machine learning work. If you find any bugs or something doesn't make sense please feel free to open an issue.
This library also contains Python code snippets that can speed up Machine Learning workflow.
Installation
This repo is tested with Python 3.6+.
It's always good practice to install ml_things in a virtual environment. If you guidance on using Python's virtual environments you can check out the user guide here.
You can install ml_things with pip from GitHub:
pip install git+https://github.com/gmihaila/ml_things
Functions
pad_array [source]
def pad_array(variable_length_array, fixed_length=None, axis=1)
| Parameters: | variable_length_array : array Single arrays [1,2,3] or nested arrays 1,2],[3. fixed_length : int Max length of rows for numpy. axis : int Directions along rows: 1 or columns: 0. |
| Returns: | numpy_array : axis=1: fixed numpy array shape [len of array, fixed_length]. axis=0: fixed numpy array shape [fixed_length, len of array]. |
Example:
>>> from ml_things import pad_array
>>> pad_array(variable_length_array=[[1,2],[3],[4,5,6]], fixed_length=5)
array([[1., 2., 0., 0., 0.],
[3., 0., 0., 0., 0.],
[4., 5., 6., 0., 0.]])