# Extracting features from categorical variables #Extracting features from categorical variables 独热编码 from sklearn.feature_extraction import DictVectorizer onehot_encoder=DictVectorizer() instance=[{'city':'New York'},{'city':'San Francisco'}, {'city…