问一个别的关于python的问题好吗
来源:3-2 小数点功能的实现
TeacherZhe
2020-12-31 01:41:05
import numpy as np
import pandas as pd
from pandas import Series, DataFrame
df1 = DataFrame({"c1": [12, 13, 21, 37,40,50],
"c2": [0.22, 0.4, 0.52, 0.81, 0.91, 1.05],
"c3": [1, 3, 3, 7, 9, 10],
"c4": [18,22,26,38, 43, 50],
"c5": ["low", "low", "midium", "high", "high", "high"]})
print(df1)
print("--------------------------------")
array1 = df1.loc[:,["c1","c2","c3"]].values
print(array1)
print("--------------------------------")
array2 = np.array(df1["c4"])
print(array2)
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
r2 = LinearDiscriminantAnalysis(n_components=2).fit_transform(array1,array2)
print(r2)
以上是代码部分,用LDA去降维,但是一运行,就会报这种错误
ValueError: The number of samples must be more than the number of classes.
请问是为什么呢
1回答
时间,
2020-12-31
相似问题