【发布时间】:2020-07-17 03:06:39
【问题描述】:
我目前在运行我的代码时遇到此错误:TypeError: SparseDataFrame() 不接受任何参数。我该如何解决这个问题?
查看下面的代码。
churndrop = churn.drop(['Churn'],axis=1) #drops churn column
x= churndrop #creates dataframe
y= churntarget # creates dataframe
y = np.ravel(y) # unravels y
y # shows y
from sklearn.model_selection import train_test_split #imports sklearn
X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=0) # creates
#test and train data
from sklearn.preprocessing import StandardScaler #import scaller
sc = StandardScaler() # sets sc to standard scaler
X_train = sc.fit_transform(X_train) #transforms data
X_test = sc.transform(X_test) # transforms data
x_train,x_test,y_train,y_test = train_test_split(x,y,test_size=0.2) # test train
#x_train,x_test,y_train,y_test = train_test_split(x,y,test_size=0.4)# extra line
import light_famd # imports famd
from light_famd import FAMD #famd
famd= FAMD(n_components=2) # creates famd variable with two components
famd.fit_transform(x_test) # fits test
print(famd.explained_variance_) # prints variance
print(famd.explained_variance_rati`enter code here`o_) # prints explained variance
【问题讨论】: