Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

README.rst 7.3 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
  1. BOHR (Big Old Heuristic Repository)
  2. ----------------------------------
  3. |GitHub license| |Maintainability| |GitHub make-a-pull-requests|
  4. BOHR is a **repository of heuristics** for preparation (labeling, grouping, linking, filtering) of software engineering artifacts, e.g. commits, bug reports, code snippets, etc. Preparation of these artifacts is often required by researchers in the field of Software Engineering (SE) and Mining Software Repositories (MSR) to convert artifacts mined from software repositories such as GitHub, StackOverflow into datasets that can be used for empirical experiments and for training machine learning models. An example could be classifying commits mined from GitHub into bug-fixing and others in order to create a training dataset to train a machine-learning model on.
  5. Preparing each artifact manually is expensive and does not scale well. Therefore BOHR offers an approach to define heuristics (short functions) to do the job automatically. Even though using heuristics is usually less accurate than letting experts analyse each artifacts, we claim that using a large number of diverse heuristics and combining them "smartly" can significantly reduce the noise compared to for example using one heuistic. The way heuristics are combined depends on the type of the task, but one of the most common way is to use the algorithm used by the `snorkel <https://www.snorkel.org/>`_, the state-of-the-art `weak supervision <http://ai.stanford.edu/blog/weak-supervision/>`_ tool.
  6. .. contents:: **Contents**
  7. :backlinks: none
  8. Examples of tasks and heuristics
  9. =======================================
  10. Commit classification
  11. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. One example is classifying commits mined from GitHub into "bugfix" and "non-bugfix", in order to create a training dataset to train a machine-learning model on.
  13. .. code-block:: python
  14. # ... other imports
  15. from bohrapi.core import Heuristic
  16. from bohrlabels.core import OneOrManyLabels
  17. from bohrapi.artifacts import Commit
  18. from bohrlabels.labels import CommitLabel
  19. @Heuristic(Commit)
  20. def bugless_if_many_files_changes(commit: Commit) -> OneOrManyLabels:
  21. if len(commit.commit_files) > 15:
  22. return CommitLabel.NonBugFix
  23. else:
  24. return None
  25. Grouping online identities
  26. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  27. Important things to note:
  28. #. A heuristics is marked with the ``Heuristic`` decorator, and the artifact type to which it is applied is passed to it as a parameter;
  29. #. The artifact instance is exposed to the heuristic as a function parameter; the properties of the artifact object can be used to implement the logic;
  30. #. The label assigned to the artifact by the heuristic is the result of the execution on the passed artifact object; the heuristic must assign one of the labels defined in the BOHR label hierarchy or ``None`` if it abstains on the data point.
  31. TBD: Insert somewhere later?
  32. * **Simplifies** the process of **adding new heuristics** and **evaluating their effectiveness**;
  33. * **Labels the datasets** registered with BOHR and **automatically updates the labels** once heuristics are added;
  34. * Keeps track of heursitics used for each version of generated datasets and models, and, in general, makes sure they are **reproducible** and **easily accessable** by using `DVC <https://dvc.org>`_.
  35. Main Concepts (maybe this is not needed in README, rather in the docs)
  36. ====================================
  37. BOHR is a repository of *heuristics*, hence, a heuristic is a primary concept in BOHR. Sub-program (python function) that accepts an artifact or multiple artifacts of the same or different types.
  38. Artifact is BOHR's abstraction that represents a software engineering artifact - a product of SE activities, e,g. code, commit, software project, software repository, issue report. *Dataset* is a collection of artifacts of the same type.
  39. *Task* is an abstraction that describes the problem that a researcher is working on in terms of BOHR. The input and the output of the tasks are datasets. Task types are labeling, grouping, linking, filtering. The task is defined by specifying artifact type(s) heuristics are applied to, possible outputs of heuristics, strategy how heuristics aree combined, test datasets and metrics to use to evaluate the effectiveness of heuristics.
  40. *Experiment* is an attempt to solve a task using a specific set of heuristics (and training data if needed).
  41. BOHR workflow
  42. ===================================
  43. 1a. For the given task, pull existing heuristics developed by community
  44. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  45. ``bohr clone https://github.com/giganticode/bohr-workdir-bugginess``
  46. This will clone the so called BOHR working directory that corresponds to the <task> to <path>
  47. 3 Check whether the existing labeled datasets are suitable for your purposes.
  48. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  49. Every task comes with a trained classifier and a default dataset labeled by this classifier. Check whether the default datasets suits your purposes.
  50. ``cd bugginess-work-dir && bohr pull default``
  51. The path where dataset is load will be displayed.
  52. 4. Label your own dataset with the default classifier.
  53. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  54. ``$ bohr dataset add ~/new_commit_dataset.csv``
  55. ``$ bohr task add-dataset bugginess new_commit_dataset --repro``
  56. 5. Develop a new heuristic
  57. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  58. ``$ vi heuristics/commit_files.py``
  59. 6. Debug and tune the heuristic by checking its coverage and accuracy on a stand-alone test-set
  60. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  61. ``$ bohr repro``
  62. 7. Submit a pull request with the new heuristic to remote BOHR repository
  63. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  64. ``$ bohr upload``
  65. Label model is trained and metrics are calculated on stand-alone test set as a part of a CI-pipeline. If metrics has been improved, the new heuristic is added to BOHR, and is available for other researchers.
  66. 8. Add a new task
  67. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  68. ``$ bohr task add tangled-commits \``
  69. ``... -l TangledCommit.NonTangled,TangledCommit.Tangled \``
  70. ``... --repro``
  71. Installation
  72. ==============
  73. TODO: add links to other repos
  74. Pre-prints and publications
  75. =============================
  76. If you use BOHR in your research, please cite us:
  77. .. code-block::
  78. @inproceedings{babii2021mining,
  79. title={Mining Software Repositories with a Collaborative Heuristic Repository},
  80. author={Babii, Hlib and Prenner, Julian Aron and Stricker, Laurin and Karmakar, Anjan and Janes, Andrea and Robbes, Romain},
  81. booktitle={2021 IEEE/ACM 43rd International Conference on Software Engineering: New Ideas and Emerging Results (ICSE-NIER)},
  82. pages={106--110},
  83. year={2021},
  84. organization={IEEE}
  85. }
  86. .. |GitHub license| image:: https://img.shields.io/github/license/giganticode/bohr.svg
  87. :target: https://github.com/giganticode/bohr/blob/master/LICENSE
  88. .. |GitHub make-a-pull-requests| image:: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
  89. :target: http://makeapullrequest.com
  90. .. |Maintainability| image:: https://codeclimate.com/github/giganticode/bohr/badges/gpa.svg
  91. :target: https://codeclimate.com/github/giganticode/bohr
  92. :alt: Code Climate
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...