As the need for storing significant amounts of data has increased, an increased areal density (AD) of hard disk drives is required. Bit-patterned media recording (BPMR) with the ability to increase AD is regarded as one of the future magnetic storage systems. Reducing the distance between islands storing 1 bit can provide high AD, but it creates problems of intersymbol and intertrack interferences. In this study, we propose a bit-flipping scheme using the <inline-formula xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink"> <tex-math notation="LaTeX">$K$ </tex-math></inline-formula> -means algorithm for the BPMR system. In the proposed scheme, the <inline-formula xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink"> <tex-math notation="LaTeX">$K$ </tex-math></inline-formula> -means algorithm, which is an iterative clustering method for identifying similar samples and assigning them to clusters, is used to assign the samples that consist of the main and neighboring data to clusters. The predicted index from <inline-formula xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink"> <tex-math notation="LaTeX">$K$ </tex-math></inline-formula> -means is utilized to compare and flip the sign of the main data when the sign is different. The proposed scheme flips the sign of data that is predicted to be an error and improves the performance using the neighboring information.