We present the first unbiased determination of spin-dependent, or polarized, Parton Distribution Functions (PDFs) of the proton. A statistically sound representation of the corresponding uncertainties is achieved by means of the NNPDF methodology: this was formerly developed for unpolarized distributions and is now generalized to the polarized here for the first time. The features of the procedure, based on robust statistical tools (Monte Carlo sampling for error propagation, neural networks for PDF parametrization, genetic algorithm for their minimization, and possibly reweighting for including new data samples without refitting), are illustrated in detail. Different sets of polarized PDFs are obtained at next-to-leading order accuracy in perturbative quantum chromodynamics, based on both fixed-target inclusive deeply-inelastic scattering data and the most recent polarized collider data. A quantitative appraisal on the potential role of future measurements at an Electron-Ion Collider is also presented. We study the stability of our results upon the variation of several theoretical and methodological assumptions and we present a detailed investigation of the first moments of our polarized PDFs, compared to other recent analyses. We find that the uncertainty on the gluon distribution from available data was substantially underestimated in previous determinations; in particular, we emphasize that a large contribution to the gluon may arise from the unmeasured small-x region, against the common belief that this is actually rather small. We demonstrate that an Electron-Ion Collider would provide evidence for a possible large gluon contribution to the nucleon spin, though with a sizable residual uncertainty.