Machine learning components
Project description
Vector
from abel.linalg.vector import Vector
a, b = Vector([1, 2]), Vector([3, 4])
c, d = Vector([1, 2, 3]), Vector([4, 5, 6])
assert a.shape == b.shape == (1, 2)
assert c.shape == d.shape == (1, 3)
Addition
assert a + a == Vector([2, 4])
assert a + b == Vector([4, 6])
assert b + b == Vector([6, 8])
Subtraction
assert a - b == Vector([-2, -2])
assert b - a == Vector([2, 2])
Scaling
assert a * 5 == Vector([5, 10])
assert 5 * a == Vector([5, 10])
assert a / 2 == Vector([0.5, 1.0])
Dot (inner) product
assert a @ b == 11
assert a @ a == 5
Norm (length)
assert a.norm() - 2.236 < 0.001
assert b.norm() - 5 < 0.001
Angle
assert Vector.angle(a, a) < 0.001
assert Vector.angle(a, b) - 0.1799 < 0.001
assert Vector.angle(a, b) == Vector.angle(b, a)
Vector projection
assert Vector.proj(a, a) == a
assert Vector.proj(a, b) == Vector([1.32, 1.76])
assert Vector.proj(b, a) == Vector([2.2, 4.4])
Scalar projection
assert Vector.scalproj(a, b) - 4.919 < 0.01
assert Vector.scalproj(b, a) - 2.2 < 0.01
assert Vector.scalproj(a, a) - 2.236 < 0.01
assert Vector.scalproj(b, b) - 5 < 0.1
Cross product
assert Vector.cross(c, d) == Vector([-3, 6, -3])
Average (arithmetic mean)
assert Vector.average(Vector([2, 1]), Vector([4, 2])) == Vector([3.0, 1.5])
Collinearity
Vectors are collinear iff one is a scalar multiple of the other.
assert Vector.collinear(Vector([2, 1]), Vector([4, 2]))
assert Vector.collinear(Vector([-3, 4, 1]), Vector([-15, 20, 5]))
assert not Vector.collinear(Vector([0, 1]), Vector([1, 0]))
Linear independence
A set of vectors is linearly independent iff all vectors in it are pairwise non-collinear.
assert Vector.linindep(Vector([0, 1]), Vector([1, 0]))
assert Vector.linindep(Vector([1, 1]), Vector([2, 1]))
assert not Vector.linindep(Vector([1, 2, 3]), Vector([0, 0, 1]), Vector([0, 0, 2]))
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
abel-0.0.6.tar.gz
(3.1 kB
view details)
Built Distribution
abel-0.0.6-py3-none-any.whl
(3.8 kB
view details)
File details
Details for the file abel-0.0.6.tar.gz
.
File metadata
- Download URL: abel-0.0.6.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b1bbdd51a019a9b2f64f9cf1e57ae6929832f909154a53952635af3ca3e5e1e |
|
MD5 | 49648be711bff4af67e34182389279fd |
|
BLAKE2b-256 | 5ab38830991bf9ae36e17626f27d557d07622cdf628a1c2773186f79174567ed |
File details
Details for the file abel-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: abel-0.0.6-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc8aca51675c9d62674f1e75699f90f98bacefc1437af7371b85fb9b3d1d7676 |
|
MD5 | 8982d1abdeafe24ad3b4a8b4ea7e6216 |
|
BLAKE2b-256 | f8ec4480b1b854b239a8350e726ef6759b6521e970d5335765fe86e48dc5a92d |