  We present a bright galaxy sample with accurate and precise photometric
redshifts (photo-zs), selected using $ugriZYJHK_\mathrm{s}$ photometry from the
Kilo-Degree Survey (KiDS) Data Release 4 (DR4). The highly pure and complete
dataset is flux-limited at $r<20$ mag, covers $\sim1000$ deg$^2$, and contains
about 1 million galaxies after artifact masking. We exploit the overlap with
Galaxy And Mass Assembly (GAMA) spectroscopy as calibration to determine
photo-zs with the supervised machine learning neural network algorithm
implemented in the ANNz2 software. The photo-zs have mean error of $|\langle
\delta z \rangle| \sim 5 \times 10^{-4}$ and low scatter (scaled mean absolute
deviation of $\sim 0.018(1+z)$), both practically independent of the $r$-band
magnitude and photo-z at $0.05 < z_\mathrm{phot} < 0.5$. Combined with the
9-band photometry, these allow us to estimate robust absolute magnitudes and
stellar masses for the full sample. As a demonstration of the usefulness of
these data we split the dataset into red and blue galaxies, use them as lenses
and measure the weak gravitational lensing signal around them for five stellar
mass bins. We fit a halo model to these high-precision measurements to
constrain the stellar-mass--halo-mass relations for blue and red galaxies. We
find that for high stellar mass ($M_\star>5\times 10^{11} M_\odot$), the red
galaxies occupy dark matter halos that are much more massive than those
occupied by blue galaxies with the same stellar mass. The data presented here
will be publicly released via the KiDS webpage.
