I haven’t been to SF for a couple years but the sketchy areas then were confined to smaller sections of “the city”. For example you could stay in Union Square and see a couple people out of their minds. Walk to Hayes Valley and be in a very nice, trendy area where there was no sketch element. If you took certain routes on the way there you would walk through what looked like Mad Max.
Not sure what areas were “cleaned up” but the sketch areas I described could have been cleaned for this visit. You could go to areas in the city and not see any sketchy folks.