You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

t_quickstart.rst 3.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. Quick Start
  2. ===========
  3. This tutorial will help you quickly go through the concepts and usages of important classes in AutoGL. In this tutorial, you will conduct a quick auto graph learning on dataset `Cora`_.
  4. .. _Cora: https://graphsandnetworks.com/the-cora-dataset/
  5. AutoGL Learning
  6. ---------------
  7. Based on the concept of autoML, auto graph learning aims at **automatically** solve tasks with data represented by graphs. Unlike conventional learning frameworks, auto graph learning, like autoML, does not need humans inside the experiment loop. You only need to provide the datasets and tasks to the AutoGL solver. This framework will automatically find suitable methods and hyperparameters for you.
  8. The diagram below describes the workflow of AutoGL framework.
  9. To reach the aim of autoML, our proposed auto graph learning framework is organized as follows. We have ``dataset`` to maintain the graph datasets given by users. A ``solver`` object needs to be built for specifying the target tasks. Inside ``solver``, there are five submodules to help complete the auto graph tasks, namely ``auto feature engineer``, ``auto model``, ``neural architecture search``, ``hyperparameter optimization`` and ``auto ensemble``, which will automatically preprocess/enhance your data, choose and optimize deep models and ensemble them in the best way for you.
  10. Let's say you want to conduct an auto graph learning on dataset ``Cora``. First, you can easily get the ``Cora`` dataset using the ``dataset`` module:
  11. .. code-block:: python
  12. from autogl.datasets import build_dataset_from_name
  13. cora_dataset = build_dataset_from_name('cora')
  14. The dataset will be automatically downloaded for you. Please refer to :ref:`dataset` or :ref:`dataset documentation` for more details of dataset constructions, available datasets, add local datasets, etc.
  15. After deriving the dataset, you can build a ``node classification solver`` to handle auto training process:
  16. .. code-block:: python
  17. import torch
  18. device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
  19. from autogl.solver import AutoNodeClassifier
  20. solver = AutoNodeClassifier(
  21. feature_module='deepgl',
  22. graph_models=['gcn', 'gat'],
  23. hpo_module='anneal',
  24. ensemble_module='voting',
  25. device=device
  26. )
  27. In this way, we build a ``node classification solver``, which will use ``deepgl`` as its feature engineer, and use ``anneal`` hyperparameter optimizer to optimize the given three models ``['gcn','gat']``. The derived models will then be ensembled using ``voting`` ensembler. Please refer to the corresponding tutorials or documentation to see the definition and usages of available submodules.
  28. Then, you can fit the solver and then check the leaderboard:
  29. .. code-block:: python
  30. solver.fit(cora_dataset, time_limit=3600)
  31. solver.get_leaderboard().show()
  32. The ``time_limit`` is set to 3600 so that the whole auto graph process will not exceed 1 hour. ``solver.show()`` will present the models maintained by ``solver``, with their performances on the validation dataset.
  33. Then, you can make the predictions and evaluate the results using the evaluation functions provided:
  34. .. code-block:: python
  35. from autogl.module.train import Acc
  36. predicted = solver.predict_proba()
  37. print('Test accuracy: ', Acc.evaluate(predicted,
  38. cora_dataset.data.y[cora_dataset.data.test_mask].cpu().numpy()))
  39. .. note:: You don't need to pass the ``cora_dataset`` again when predicting, since the dataset is **remembered** by the ``solver`` and will be reused when no dataset is passed at predicting. However, you can also pass a new dataset when predicting, and the new dataset will be used instead of the remembered one. Please refer to :ref:`solver` or :ref:`solver documentation` for more details.