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)`
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.
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)`
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.