A computer-implemented method for controlling drilling of subterranean formations, comprising: (i) receiving measured values indicative of operations performed by drilling equipment while drilling the formations, wherein the measured values include hookload values; (ii) adjusting each of the hookload values to remove block weight from the hookload value, the adjusting comprising: (a) analyzing each of the hookload values to determine whether the hookload value was acquired while connecting a drill pipe to a drill string, the analyzing comprising: for each of the hookload values, assigning, to the hookload value, a probability that the hookload value was acquired while connecting a drill pipe to the drill string; and setting each hookload value corresponding to a probability value exceeding a predetermined threshold to be a block weight value; (b) subtracting the block weight value from each hookload value acquired after the block weight value and before a different block weight value is identified to produce rebased hookload values; (iii) applying the measured values and the rebased hookload values corresponding to operation of the drilling equipment during a first predetermined time interval to a rig state model comprising a plurality of randomized decision trees; (iv) producing a first value for a state of the drilling equipment during the first predetermined time interval as an output of the model based on the measured values and the rebased hookload values; (v) changing an operation performed to drill the subterranean formations in response to the first value for the state of the drilling equipment. (i) receiving measured values indicative of operations performed by drilling equipment while drilling the formations, wherein the measured values include hookload values; (ii) adjusting each of the hookload values to remove block weight from the hookload value, the adjusting comprising: (a) analyzing each of the hookload values to determine whether the hookload value was acquired while connecting a drill pipe to a drill string, the analyzing comprising: for each of the hookload values, assigning, to the hookload value, a probability that the hookload value was acquired while connecting a drill pipe to the drill string; and setting each hookload value corresponding to a probability value exceeding a predetermined threshold to be a block weight value; (b) subtracting the block weight value from each hookload value acquired after the block weight value and before a different block weight value is identified to produce rebased hookload values; (a) analyzing each of the hookload values to determine whether the hookload value was acquired while connecting a drill pipe to a drill string, the analyzing comprising: for each of the hookload values, assigning, to the hookload value, a probability that the hookload value was acquired while connecting a drill pipe to the drill string; and setting each hookload value corresponding to a probability value exceeding a predetermined threshold to be a block weight value; for each of the hookload values, assigning, to the hookload value, a probability that the hookload value was acquired while connecting a drill pipe to the drill string; and setting each hookload value corresponding to a probability value exceeding a predetermined threshold to be a block weight value; (b) subtracting the block weight value from each hookload value acquired after the block weight value and before a different block weight value is identified to produce rebased hookload values; (iii) applying the measured values and the rebased hookload values corresponding to operation of the drilling equipment during a first predetermined time interval to a rig state model comprising a plurality of randomized decision trees; (iv) producing a first value for a state of the drilling equipment during the first predetermined time interval as an output of the model based on the measured values and the rebased hookload values; (v) changing an operation performed to drill the subterranean formations in response to the first value for the state of the drilling equipment.