Magnetic refrigeration exploits the magnetocaloric effect, which is the entropy change upon the application and removal of magnetic fields in materials, providing an alternate path for refrigeration other than conventional gas cycles. While intensive research has uncovered a vast number of magnetic materials that exhibit a large magnetocaloric effect, these properties remain unknown for a substantial number of compounds. To explore new functional materials in this unknown space, machine learning is used as a guide for selecting materials that could exhibit a large magnetocaloric effect. By this approach, HoB2 is singled out and synthesized, and its magnetocaloric properties are evaluated, leading to the experimental discovery of a gigantic magnetic entropy change of 40.1 J kg−1 K−1 (0.35 J cm−3 K−1) for a field change of 5 T in the vicinity of a ferromagnetic second-order phase transition with a Curie temperature of 15 K. This is the highest value reported so far, to the best of our knowledge, near the hydrogen liquefaction temperature; thus, HoB2 is a highly suitable material for hydrogen liquefaction and low-temperature magnetic cooling applications.