[subject] + 不愧是 + [noun]
[subject] + 不愧为 + [noun]
不愧是 says someone deserves the name or title that follows: what they just did proves it. It's praise, and it usually comes after the evidence. 不愧为 means the same and is more written.
The noun names a role or a reputation: 老师, 冠军, 专家, 北京人. 果然 in front adds "just as I expected".
不愧为 suits formal praise of a work, a place or a person.
With a noun for something bad, the praise turns into sarcasm: 不愧是你 after a friend's blunder is a joke at their expense.
不愧 needs 是 or 为 and a noun after it. To praise a quality, turn it into a noun phrase.
It is also written 愧, not 亏: 不亏 means "not lose out", a different word with a similar sound.