There is no such thing as a "safe neighborhood" really. Its all about your personal Karma and your own practice of mindfulness.
Poor people are more desperate than people with money and most "danger" is just poor people at a breaking point.They need rich people to rob. Rapists are pissed off at women . Dress smart (not like a hooker) . Valencia street is safer than So. Van Ness, Folsom, Harrison or Bryant at midnight .Look out in Dolores Park (any park) at night.
The area between 16th and Mission / So Van Ness ) to 18th and Mission is the prostitution and big heroin dealing area. Be careful 16th and around CAPP st.