A sentence fragment typically occurs when either a phrase, or a subordinate clause is used in a text as though it were a complete sentence. Remember from our study in class that only independent clauses can stand on their own as simple sentences. When a subject phrase lacking a predicate (Tim the miller's son), or a predicate phrase lacking a subject (running for his life) are used as a sentence, a fragment is formed. When a subordinate clause (When the Prime Minister is in Ottawa) is used as if it was a complete sentence, this also creates a fragment.
Sentence fragments can be eliminated in a number of ways. If a phrase is the offender, you can add whatever missing element is required (subject or predicate) to transform it into a sentence. If a subordinate clause is responsible, you can remove the subordinate conjunction at the start ( When The Prime Minister is in Ottawa) or you can convert them into a complex sentence by adding an independent clause (When the Prime Minister is in Ottawa, he eats cake).