Skip to content

waikato-datamining/py-matrix-algorithms

Repository files navigation

py-matrix-algorithms

Python library of 2-dimensional matrix algorithms.

Algorithms

Available:

Planned:

Filters

Transformations

Installation

Install from the PyPI index:

pip install wai_ma

Examples

To use an algorithm:

# For example, the SIMPLS algorithm
from wai.ma.algorithm.pls import SIMPLS

# Create the algorithm object
simpls: SIMPLS = SIMPLS()
simpls.num_coefficients = 5  # Set any parameters to desired values

# Get some training data
from wai.ma.core.matrix import Matrix, helper
train_predictors: Matrix = helper.read("train_predictors.csv", False, ",")
train_response: Matrix = helper.read("train_response.csv", False, ",")

# Train the algorithm
simpls.initialize(train_predictors, train_response)

# Get some test data
test_predictors: Matrix = helper.read("test_predictors.csv", False, ",")

# Get the predicted response
test_predicted_response: Matrix = simpls.predict(test_predictors)

# Compare with actual response, or use in some other way...

To use a transformation:

# For example, the Savitzky-Golay transformation
from wai.ma.transformation import SavitzkyGolay

# Create the transformation object
sg: SavitzkyGolay = SavitzkyGolay()
sg.num_points_right = sg.num_points_left = 4  # Set any parameters to desired values

# Get some configuration data
from wai.ma.core.matrix import Matrix, helper
train: Matrix = helper.read("train.csv", False, ",")

# Configure the transformation (if not configured, will automatically
# do so with the first set of data given to transform). 
sg.configure(train)

# Get some test data
test: Matrix = helper.read("test.csv", False, ",")

# Transform the test data
test_transformed: Matrix = sg.transform(test)

# Further use of transformed data...

About

Python library of 2-dimensional matrix algorithms.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages