Skip to main content

Metrician

GitHub all releases GitHub GitHub Workflow Status PyPi Metrician is a small lightweight module that easily and automatically records performance metrics for you. Right now, Metrician is only compatible with Pytorch. There are a lot of great tools out there like Pytoch Lighting that have built in loggers. Although there is nothing wrong with these tools (in fact, I'm a big fan), I find myself writing the same few lines of code over and over and over again, just to log the same metrics. I hate redundancy, so I wrote a tool to fix that issue. You're still able to use the same libraries, but now you don't have to code as much.

Usage

import torch
from torch import nn
from metrician import MetricWriter, Defaults

# initialize data
X = torch.randn( 10, 10 ) # input size 10
Y = torch.randn( 10,4 ) # 4 classes

# initialize simple model, loss and optimizer
model = nn.Linear(10,4)
optim = torch.optim.SGD(model.parameters())
loss_fn = nn.L1Loss()

# initialize Metric Writer
mw = MetricWriter( Defaults.SimpleClf ) # initialize with basic classifier metrics

# inside your training loop
for _ in range(EPOCHS):
	y = model( X )
	# you can either pass the loss function into the metric writer to automatically
	# record the loss or do that seperately. If you pass in the loss, it will automatically
	# call your loss function for you i.e. (loss = loss_fn(yhat,y) ) and return the result
	# if you are recording every couple of steps/batches it's recommended that you do not pass
	# the loss function to the metric writer
	loss = mw(y,Y,loss_fn)
	loss.backward()
	optim.step()

Feeling Lazy?

With Metrician you can leverage existing class methods to automatically create a config, reducing the amount of code you need.

import torch
from torch import nn
from metrician import MetricWriter, Defaults

# initialize data
X = torch.randn( 10, 10 ) # input size 10
Y = torch.randn( 10,4 ) # 4 classes

# initialize simple classification model
model = nn.Linear(10,4)
# initialize Metric Writer
mw = MetricWriter.from_model( model )
# print( mw.cfg.config_type )
# >>> classification

# or

# initialize simple regression model
model = nn.Linear(10,1)
# initialize Metric Writer
mw = MetricWriter.from_model( model )
# print( mw.cfg.config_type )
# >>> regression
...

Want to integrate it into another library like Pytorch Lightening?

Metrician is an easy module to integrate into any existing Pytorch library/framework.

def __init__(self):
    ...
    self.accuracy = pl.metrics.Accuracy()
	self.mw = MetricWriter( Defaults.SimpleCLF )
def training_step(self, batch, batch_idx):
    x, y = batch
    preds = self(x)
	# instead of normally typing
	# self.log('my_loss', loss,)
	# ...
	# self.log('my_accuracy',self.accuracy(preds, y))
	# instead type
	self.mw( (preds, y) )

TODOs

  • add histograms, embeddings and graphs
  • Tensorflow Support
  • ?????
  • profit

Metadata

Release files for metrician 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metrician 0.0.3
File Size Uploaded Provenance Actions
metrician-0.0.3.tar.gz 17.1 kB Without provenance Details for metrician-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for metrician 0.0.3
File Interpreter ABI Platform Actions
metrician-0.0.3-py3-none-any.whl Python 3 none any Details for metrician-0.0.3-py3-none-any.whl

Total release size: 44.1 kB

Release files / metrician-0.0.3.tar.gz

Download URL metrician-0.0.3.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
81a91d476fd387837911ea326330fcb474ab307f4bf2ea14ecb20cdf751fbcdd
BLAKE2b-256 checksum
How to use checksums
3c9ce95dc698134eed168693000678a791e36a599f71d5aa2973603eb41a13d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.5

Release files / metrician-0.0.3-py3-none-any.whl

Download URL metrician-0.0.3-py3-none-any.whl
Size 26.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
303b04780502f88bd3de52bc44ab8e11ef45838efcd1e200272076ae70fb8f76
BLAKE2b-256 checksum
How to use checksums
b4916ec7f7a79a8011e2976929a9063ed68c13ad2060d8c61a5988084bbf0cb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.5

Security for metrician 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page