ValueError: class encoding field is specified without a type

ValueError: class encoding field is specified without a type

dim_red = TruncatedSVD(n_components=2)
data_red = dim_red.fit_transform(tfidf)

scatter = alt.Chart(data_red,title="dimensionality reduction",height=400).mark_circle().encode(
    x='principal component 1', y='principal component 2', color=alt.Color(
        'class', scale=alt.Scale(scheme='blues')),tooltip=["class"]).interactive()

st.altair_chart(散点图)`

当编码名称(此处 'principal component 1' and/or 'principal component 2')与传递给图表的数据框中的任何列的名称不匹配时,通常会出现此错误。检查数据框中列的名称,并确保您正确地重现了它们。