The paper presents theoretical development and a system implementation of NetBeam, a framework for fully programmable, reconfigurable and distributed beamforming. NetBeam allows for joint mechanical antenna steering, grouping of a network of individual transmitter radios for specific target receivers, as well as digital beamforming that satisfies higher layer application demands. We make the following theoretical contributions: (i) We utilize, for the first time, a machine learning approach that uses Kriging for predicting antenna gains for arbitrary 3-D placements of transmitter - receiver pairs. NetBeam efficiently exploits fine-grained and accurate antenna gain predictions of the model, while estimating the uncertainty at unexplored locations through a Gaussian distribution. (ii) We allocate antennas to receivers by formulating the scenario as a bipartite graph, followed by perfect matching strategies that maximize the channel gain. (iii) We leverage the CSI computed in stage (i) to compute the optimum digital beamforming weights by trading off SINR and power consumption that meets application requirements using semidefinite optimization. Our implementation addresses many practical aspects of distributed beamforming including achieving fast frequency, time, and phase synchronization. NetBeam minimizes the gap to optimal channel gain in a 3-D space, and reduces the total transmit power up to 60%, while still managing to provide the required SINR.