ValueError: class encoding field is specified without a type

Question:

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(scatter)`

Asked By: 7F_WZ

||

Answers:

This error will generally arise when the encoding names (here 'principal component 1' and/or 'principal component 2') do not match the names of any columns in the dataframe passed to the chart. Check the names of the columns in the dataframe, and make sure you’re reproducing them correctly.

Answered By: jakevdp
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.