Я новичок в Python, и у меня возникают проблемы с использованием SciLearn Kit на фреймах данных, созданных с помощью Pandas.Ниже приведен код:
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib as plt
import json
%matplotlib inline
data = pd.read_json('C:/Users/Desktop/Machine Learning/yelp_academic_dataset_business.json', lines=True, orient='columns', encoding='utf-8')
dataframe = pd.DataFrame(data)
list(dataframe)
subset_data = dataframe.loc[(dataframe.city == 'Toronto')]
print(subset_data)
documents = subset_data.to_dict('records')
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer
no_features = 1000
# NMF is able to use tf-idf
tfidf_vectorizer = TfidfVectorizer(max_df=0.95, min_df=2, max_features=no_features, stop_words='english')
tfidf = tfidf_vectorizer.fit_transform(documents)
tfidf_feature_names = tfidf_vectorizer.get_feature_names()
# LDA can only use raw term counts for LDA because it is a probabilistic graphical model
tf_vectorizer = CountVectorizer(max_df=0.95, min_df=2, max_features=no_features, stop_words='english')
tf = tf_vectorizer.fit_transform(documents)
tf_feature_names = tf_vectorizer.get_feature_names()
Ниже приведена ошибка, которую я получаю.
AttributeError: 'dict' object has no attribute 'lower'
Набор данных доступен здесь: kaggle.com / yelp-dataset / yelp-dataset Набор данных: yelp_academic_dataset_business.json
Любая помощь будет оценена.Спасибо.