neptune-client

Neptune client library - integrate your Python scripts with Neptune

Showing:

Popularity

Downloads/wk

0

GitHub Stars

166

Maintenance

Last Commit

3d ago

Contributors

31

Package

Dependencies

0

License

Apache License 2.0

Categories

Readme



PyPI version Build Status neptune-blog twitter youtube

Lightweight experiment tracking tool for AI/ML individuals and teams. Fits any workflow.

Neptune is a lightweight experiment logging/tracking tool that helps you with your machine learning experiments. Neptune is suitable for indvidual, commercial and research projects.

Get free account



Features to help you get the job done

  • Rich experiment logging and tracking capabilities
  • Python and R clients
  • Experiments dashboards, views and comparison features
  • Team management
  • 25+ integrations with popular data science stack libraries
  • Fast, reliable UI

Documentation

Neptune in 30 seconds

Installation

pip install neptune-client

or

conda install -c conda-forge neptune-client

Start tracking

For the hands-on intro to neptune-client check this API Tour, below simple example is presented:

github-code jupyter-code Open In Colab

import neptune

neptune.init('my_workspace/my_project')
neptune.create_experiment()

for epoch in range(train_epochs):
    ...
    neptune.log_metric('loss', loss)
    neptune.log_metric('metric', accuracy)

score = ...

neptune.log_metric('val_score', score)
neptune.log_artifact('model_weights.pth')

What is Neptune good for?

Neptune can especially helpful with the following problems:

Use Neptune with your favourite AI/ML libraries

frameworks-logos

Neptune comes with 25+ integrations with Python libraries popular in machine learning, deep learning and reinforcement learning.

Integrations lets you automatically:

  • log training, validation and testing metrics, and visualize them in Neptune UI,
  • log experiment hyper-parameters,
  • monitor hardware usage,
  • log performance charts and images,
  • save model checkpoints,
  • log interactive visualizations,
  • log csv files, pandas Datraframes,
  • log much more.

All integrations

PyTorch Lightning



PyTorch Lightning is a lightweight PyTorch wrapper for high-performance AI research. You can automatically log PyTorch Lightning experiments to Neptune using NeptuneLogger (part of the pytorch-lightning library).

Example:

from pytorch_lightning.loggers.neptune import NeptuneLogger

# Create NeptuneLogger
neptune_logger = NeptuneLogger(
    api_key="ANONYMOUS",
    project_name="shared/pytorch-lightning-integration",
    params=PARAMS)

# Pass NeptuneLogger to the Trainer
trainer = pl.Trainer(max_epochs=PARAMS['max_epochs'],
                     logger=neptune_logger)

# Fit model, have everything logged automatically
model = LitModel()
trainer.fit(model, train_loader)

neptune-pl

Check full code example:

github-code jupyter-code Open In Colab

TensorFow/Keras



TensorFlow is an open source deep learning framework commonly used for building neural network models. Keras is an official higher level API on top of TensorFlow. Neptune helps with keeping track of model training metadata.

Neptune integrates with both TensorFlow / Keras directly and via TensorBoard.

Example:

import neptune
import tensorflow as tf
from neptunecontrib.monitoring.keras import NeptuneMonitor

neptune.init(api_token='ANONYMOUS', project_qualified_name='my_workspace/my_project')
neptune.create_experiment('tensorflow-keras-quickstart')

x_train, x_test = ...
model = tf.keras.models.Sequential([
  ...
])
optimizer = tf.keras.optimizers.SGD(lr=0.005, momentum=0.4,)
model.compile(optimizer=optimizer,
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])
model.fit(x_train, y_train,
          epochs=5,
          batch_size=64,
          callbacks=[NeptuneMonitor()])

neptune-pl

Check full code example:

github-code jupyter-code Open In Colab

Use with Scikit-learn



Scikit-learn is an open source machine learning framework commonly used for building predictive models. Neptune helps with keeping track of model training metadata.

Example:

import neptune
from neptunecontrib.monitoring.sklearn import log_regressor_summary

neptune.init('my_workspace/my_project')
neptune.create_experiment(params=parameters,
                          name='regression-example',
                          tags=['RandomForestRegressor', 'regression'])

rfr = RandomForestRegressor(**parameters)
X, y = load_boston(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=28743)
rfr.fit(X_train, y_train)

log_regressor_summary(rfr, X_train, X_test, y_train, y_test)

neptune-pl

Check full code example:

github-code jupyter-code Open In Colab

Use with LightGBM



LightGBM is a popular gradient boosting library.

Example:


import lightgbm as lgb
import neptune
from neptunecontrib.monitoring.lightgbm import neptune_monitor

neptune.init('my_project/my_workspace')
neptune.create_experiment()

X_train, X_test, y_train, y_test = ...
lgb_train = lgb.Dataset(X_train, y_train)
lgb_eval = lgb.Dataset(X_test, y_test, reference=lgb_train)

params = {'boosting_type': 'gbdt',
          'objective': 'multiclass',
          'num_class': 3,
          'num_leaves': 31,
          'learning_rate': 0.05,
          'feature_fraction': 0.9
          }

gbm = lgb.train(params,
    lgb_train,
    num_boost_round=500,
    valid_sets=[lgb_train, lgb_eval],
    valid_names=['train','valid'],
    callbacks=[neptune_monitor()],
    )

neptune-pl

Check full code example:

github-code jupyter-code Open In Colab

Use with Optuna



Optuna is an open source hyperparameter optimization framework to automate hyperparameter search.

Example:

import neptune
import lightgbm as lgb
import optuna
import neptunecontrib.monitoring.optuna as opt_utils

def objective(trial):
    data, target = load_breast_cancer(return_X_y=True)
    train_x, test_x, train_y, test_y = train_test_split(data, target, test_size=0.25)
    dtrain = lgb.Dataset(train_x, label=train_y)

    param = {'verbose': -1,
             'objective': 'binary',
             'metric': 'binary_logloss',
             'num_leaves': trial.suggest_int('num_leaves', 2, 256),
             'feature_fraction': trial.suggest_uniform('feature_fraction', 0.2, 1.0),
             'bagging_fraction': trial.suggest_uniform('bagging_fraction', 0.2, 1.0),
             'min_child_samples': trial.suggest_int('min_child_samples', 3, 100)}

    gbm = lgb.train(param, dtrain)
    preds = gbm.predict(test_x)
    accuracy = roc_auc_score(test_y, preds)

    return accuracy

neptune.init('my_workspace/my_project')
neptune.create_experiment('optuna-sweep')

neptune_callback = opt_utils.NeptuneCallback()

study = optuna.create_study(direction='maximize')
study.optimize(objective, n_trials=100, callbacks=[neptune_callback])

neptune-pl

Check full code example:

github-code jupyter-code Open In Colab

Getting help

If you got stuck or simply want to talk to us about something here are your options:

Neptune.ai is trusted by great companies

People behind Neptune

Created with ❤️ by the Neptune.ai team:

Piotr, Michał, Jakub, Paulina, Kamil, Małgorzata, Piotr, Aleksandra, Marcin, Hubert, Adam, Szymon, Jakub, Maciej, Piotr, Paweł, Patrycja, Grzegorz, Paweł, Natalia, Marcin and you?

neptune.ai

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100