Rating agencies cluster companies in rating categories to signal their creditworthiness. The rating is based on qualitative and quantitative factors and often is a mix of public and private information. Market prices, either asset swap spreads or credit default swap premiums, reflect the market perception on creditworthiness (default probability) and loss given default. Assuming a recovery rate, we use the (risk-neutral) default probabilities to cluster them in (rating) groups. We use the well-developed technique of regime switching to cluster issuers into categories. We test the model over the period 2004-2014 on issues such as in-sample likelihood, forecasting accuracy, and rating stability. The model allows market participants to rate a company's credit risk directly, complimentary to ratings issued by credit rating agencies.