{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## **Quickstart Guide**\n", "\n", "This guide covers the standard usage pattern and basic functionality to help you get started with twinLab. In this jupyter notebook we will:\n", "\n", "1. Upload a dataset to twinLab.\n", "2. Use `Emulator.train` to train a surrogate model.\n", "3. Use the model to make a prediction with `Emulator.predict`.\n", "4. Visualise the results and their uncertainty.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Third-party imports\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import pandas as pd\n", "\n", "# Project imports\n", "import twinlab as tl" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **Your twinLab information**\n", "\n", "Confirm your twinLab version\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'cloud': '2.0.0',\n", " 'modal': '0.2.0',\n", " 'library': '1.2.0',\n", " 'image': 'jasper-twinlab-deployment'}" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tl.versions()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And view your user information, including how many credits you have.\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'username': 'jasper@digilab.co.uk', 'credits': 0}" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tl.user_information()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **Upload a dataset**\n", "\n", "Datasets must be data presented as a `pandas.DataFrame` object, or a filepaths which points to a csv file that can be parsed to a `pandas.DataFrame` object. **Both must be formatted with clearly labelled columns.** Here, we will label the input (predictor) variable `x` and the output variable `y`. In `twinlab`, data is expected to be in column-feature format, meaning each row represents a single data sample, and each column represents a data feature.\n", "\n", "`twinLab` contains a `Dataset` class with attirbutes and methods to process, view and summarise the dataset. Datasets must be created with a `dataset_id` which is used to access them. The dataset can be uploaded using the `upload` method.\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | x | \n", "y | \n", "
|---|---|---|
| 0 | \n", "0.696469 | \n", "-0.817374 | \n", "
| 1 | \n", "0.286139 | \n", "0.887656 | \n", "
| 2 | \n", "0.226851 | \n", "0.921553 | \n", "
| 3 | \n", "0.551315 | \n", "-0.326334 | \n", "
| 4 | \n", "0.719469 | \n", "-0.832518 | \n", "
| 5 | \n", "0.423106 | \n", "0.400669 | \n", "
| 6 | \n", "0.980764 | \n", "-0.164966 | \n", "
| 7 | \n", "0.684830 | \n", "-0.960764 | \n", "
| 8 | \n", "0.480932 | \n", "0.340115 | \n", "
| 9 | \n", "0.392118 | \n", "0.845795 | \n", "
| \n", " | x | \n", "
|---|---|
| 0 | \n", "0.000000 | \n", "
| 1 | \n", "0.007874 | \n", "
| 2 | \n", "0.015748 | \n", "
| 3 | \n", "0.023622 | \n", "
| 4 | \n", "0.031496 | \n", "
| ... | \n", "... | \n", "
| 123 | \n", "0.968504 | \n", "
| 124 | \n", "0.976378 | \n", "
| 125 | \n", "0.984252 | \n", "
| 126 | \n", "0.992126 | \n", "
| 127 | \n", "1.000000 | \n", "
128 rows × 1 columns
\n", "