This idea, "As he thinks in his heart, so is he" applies both to the righteous and the evil. Here, the subject is evil. We can translate the first half of verse 7 in a more modern way as, "As he calculates in his soul." "Calculate" puts a twist on the word "thinks," making it a bit stronger and providing a sense of deceit—that the person is considering the odds of a scheme.
In all three verses, Solomon warns against exploitative people, against those who are slick controllers who manipulate others through charm or beguiling words. God is telling us that we need to have enough discernment to look on the heart, as the proverb says, "As he thinks in his heart, so is he."
There is an inseparable connection between teaching and practice: We cannot practice truth until we are taught it. We pick up some things from our culture because people do not do everything wrong; from time to time, they hit upon things that are right. Thus, in Romans 2, Paul writes about the conscience of the unconverted. There may be little or much in a given culture in harmony with God and His way.
So, as a person thinks in his heart—as he has been educated to think—is the way he really is. Doctrine - teaching - becomes important because, within the framework of His purpose, we really cannot walk in way of God until He teaches us the truth. He must feed the mind with the right knowledge if the person is going to do right as a way of life. This is what God is after, which is why doctrine is so important.
Thus, God says, "Train up a child in the way he should go, and when he is old he will not depart from it" (Proverbs 22:6). This verse does not mean that the child will do everything right but that the child's basic training will never completely leave him, and if his parents start him off in the right way, "as the twig is bent, so grows the tree." It is a generality, but a true one. What people need is truth. We need the doctrines put together in the correct way so they lead in the right direction—toward God's purpose.
What matters is the thinking material that the person works with because the knowledge that his mind, his heart, assimilates will form the basis from which he calculates. If a person lacks truth, he will not come to proper decisions and produce the right actions.