Skip to main content

Convenient access to the NextBrain API from python

Project description

NextBrain

Convenient access to the NextBrain API from python

Installation

pip install nextbrain

If you want to use the async version you need to install asyncio and aiohttp:

pip install asyncio aiohttp

Normal usage

All steps in one.

from nextbrain import NextBrain
from typing import Any, List

def main():
    nb = NextBrain('<YOUR-ACCESS-TOKEN-HERE>')

    # You can create your custom table and predict table by your own from any source
    table: List[List[Any]] = nb.load_csv('<PATH-TO-YOUR-TRAINING-CSV>')
    predict_table: List[List[Any]] = nb.load_csv('<PATH-TO-YOUR-PREDICTING-CSV>')

    model_id, response = nb.upload_and_predict(table, predict_table, '<YOUR-TARGET-COLUMN>')
    # model_id is also returned in order to predict multiple times against same model
    print(response)

if __name__ == '__main__':
    main()

Step by step

from nextbrain import NextBrain
from typing import Any, List

def main():
    nb = NextBrain('<YOUR-ACCESS-TOKEN-HERE>')

    # You can create your custom table and predict table by your own from any source
    table: List[List[Any]] = nb.load_csv('<PATH-TO-YOUR-TRAINING-CSV>')
    # Upload the model to NextBrain service
    model_id: str = nb.upload_model(table)
    # Train the model
    # You can re-train a previous model
    nb.train_model(model_id, '<YOUR-TARGET-COLUMN>')

    predict_table: List[List[Any]] = nb.load_csv('<PATH-TO-YOUR-PREDICTING-CSV>')
    # You can predict multiple using the same model (don't need to create a new model each time)
    response = nb.predict_model(model_id, predict_table[0], predict_table[1:])
    print(response)

if __name__ == '__main__':
    main()

Async usage

All steps in one.

from nextbrain import AsyncNextBrain
from typing import Any, List

async def main():
    nb = AsyncNextBrain('<YOUR-ACCESS-TOKEN-HERE>')

    # You can create your custom table and predict table by your own from any source
    table: List[List[Any]] = nb.load_csv('<PATH-TO-YOUR-TRAINING-CSV>')
    predict_table: List[List[Any]] = nb.load_csv('<PATH-TO-YOUR-PREDICTING-CSV>')

    model_id, response = await nb.upload_and_predict(table, predict_table, '<YOUR-TARGET-COLUMN>')
    # model_id is also returned in order to predict multiple times against same model
    print(response)

if __name__ == '__main__':
    import asyncio
    asyncio.run(main())

Step by step

from nextbrain import AsyncNextBrain
from typing import Any, List

async def main():
    nb = AsyncNextBrain('<YOUR-ACCESS-TOKEN-HERE>')

    # You can create your custom table and predict table by your own from any source
    table: List[List[Any]] = nb.load_csv('<PATH-TO-YOUR-TRAINING-CSV>')
    # Upload the model to NextBrain service
    model_id: str = await nb.upload_model(table)
    # Train the model
    # You can re-train a previous model
    await nb.train_model(model_id, '<YOUR-TARGET-COLUMN>')

    predict_table: List[List[Any]] = nb.load_csv('<PATH-TO-YOUR-PREDICTING-CSV>')
    # You can predict multiple using the same model (don't need to create a new model each time)
    response = await nb.predict_model(model_id, predict_table[0], predict_table[1:])
    print(response)

if __name__ == '__main__':
    import asyncio
    asyncio.run(main())

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

nextbrain-0.2.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nextbrain-0.2.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file nextbrain-0.2.2.tar.gz.

File metadata

  • Download URL: nextbrain-0.2.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.6 Linux/5.19.0-32-generic

File hashes

Hashes for nextbrain-0.2.2.tar.gz
Algorithm Hash digest
SHA256 d98995f783dd288a0d4f7cc6f1ee8e91c4f6880f1a8091838d10064cad1e3b74
MD5 3770846488d44446153ada89aa32348b
BLAKE2b-256 ca433745a7888c3dddc21b35e41d6de3305bd759841e71ddb1d0711c14b15115

See more details on using hashes here.

File details

Details for the file nextbrain-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: nextbrain-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.6 Linux/5.19.0-32-generic

File hashes

Hashes for nextbrain-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 489adcae4a6700f80352d9394934a677ce82e0ea261b3d695d91ee36e9d9ab10
MD5 07d5b4845ca947a520babdad3d3b49fc
BLAKE2b-256 43c894fd44b6f42dc12899a09fef13396ace0f4c326f31a29d09ffa3c23e3c34

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page