Python:ComplexWarning:将复杂的值转换为实数将丢弃虚部array = np.array(array,dtype = dtype,order = order,copy = copy)

时间:2019-03-08 11:55:50

标签: python

这是我的代码。第21行发出警告。我不知道它为什么会出现。我已经搜索了很长时间,但是我仍然找不到答案。

from scipy import fftpack
import csv
import numpy as np
import pandas as pd
import scipy.fftpack as sci_fft
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
dataframe = pd.read_csv('D:\\Lab\\data_aft\\xadata.csv',header=None)
trans = dataframe.values
lab_data_fft = np.array(fftpack.fft(trans[:,0:-1],n = 8),
                    dtype=complex)
target = trans[:,-1]
x_train,x_test,y_train,y_test = train_test_split(lab_data_fft,target,
                                                  test_size=0.333,
                                                 random_state=1)
clf = SVC(kernel='rbf',
      gamma=1,
      C=10,
      decision_function_shape='ovr')
clf.fit(x_train,y_train)
pred = clf.predict(x_test)
score = clf.score(x_test,y_test)

顺便说一句,我是python的新手:)。谢谢!

0 个答案:

没有答案