Skip to main content

Convenient access to the NextBrain API from python

Project description

NextBrain AI

Convenient access to the NextBrain AI 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())

Extra notes

Everytime you train, you can select an option to create lightning models. is_lightning is an optional parameter that by default is set to False but can be overrided in train_model and upload_and_predict.

We also recommend that you investigate all the methods that the class provides you with to make the most of the functionalities we offer. For example, you can use the get_accuracy method to obtain all the information about the performance of your model.

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.4.tar.gz (4.7 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.4-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nextbrain-0.2.4.tar.gz
  • Upload date:
  • Size: 4.7 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.4.tar.gz
Algorithm Hash digest
SHA256 cf98f912ee435c0b7a13a316d53c4386bc02b179a1c4b01c2c5a7f252c6c2c96
MD5 58e3f5202979feda95c595099ad97f42
BLAKE2b-256 d4a1e94eaa2dd1ed6f5a680dd0b1de33724a208c4796954f0a7c71f81ec5ffb9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nextbrain-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 4.9 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a29ba315b0f579d08ee7ccd8e54f04ceabf2632e1d7c4b7fb99f64971d6b3a65
MD5 85bed28e94565a07cf4d1baac027ec90
BLAKE2b-256 a16b326d8714a4a3a52d4f7d2dcd49156b800d3cf65fc00d09cd9687629a5645

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