未知标签类型:运行 sklearn python 中的 svm 算法出现未知错误

Unkown Label Type : unknown error while running svc algorithm in sklearn python

正如标题所说,我正在尝试 运行 数据集上的 svc 算法,但我不断收到错误消息:

Unknown Label Type : unknown error

代码如下:

import numpy as np
import numpy as np
import pandas as pd

import matplotlib.pyplot as plt
from sklearn import svm


path1 = r'C:\Users\Ahmed Ismail Khalid\Desktop\Training.csv'
path2 = r'C:\Users\Ahmed Ismail Khalid\Desktop\Testing.csv'

training = pd.read_csv(path1)
testing = pd.read_csv(path1)


training = training.drop('created_at',axis=1)
training = training.fillna(0)

testing = testing.drop('created_at',axis=1)
testing = testing.fillna(0)

labels = (training['Count of aantonop_tweets.csv'],['Count of adam3us_tweets.csv'],['Count of alansilbert_tweets.csv'],['Count of alexsunnarborg_tweets.csv'],['Count of alextapscott_tweets.csv'],['Count of anondran_tweets.csv'],['Count of AnselLindner_tweets.csv'],['Count of AriannaSimpson_tweets.csv'],['Count of AriDavidPaul_tweets.csv'],['Count of arrington_tweets.csv'],['Count of barrysilbert_tweets.csv'],['Count of bendavenport_tweets.csv'],['Count of bgarlinghouse_tweets.csv'],['Count of bitcoinbyte_tweets.csv'],['Count of bobbyclee_tweets.csv'],['Count of brian_armstrong_tweets.csv'],['Count of brockpierce_tweets.csv'],['Count of CarpeNoctom_tweets.csv'],['Count of cburniske_tweets.csv'],['Count of certainassets_tweets.csv'],['Count of CharlieShrem_tweets.csv'],['Count of chrislarsensf_tweets.csv'],['Count of CremeDeLaCrypto_tweets.csv'],['Count of cryptomanran_tweets.csv'],['Count of dahongfei_tweets.csv'],['Count of dan_pantera_tweets.csv'],['Count of DerinCag_tweets.csv'],['Count of derose_tweets.csv'],['Count of desantis_tweets.csv'],['Count of dieguito_tweets.csv'],['Count of dinisguarda_tweets.csv'],['Count of dtapscott_tweets.csv'],['Count of eiaine_tweets.csv'],['Count of eric_lombrozo_tweets.csv'],['Count of ErikVoorhees_tweets.csv'],['Count of ethereumjoseph_tweets.csv'],['Count of FEhrsam_tweets.csv'],['Count of francispouliot__tweets.csv'],['Count of fredwilson_tweets.csv'],['Count of gavinandresen_tweets.csv'],['Count of gavofyork_tweets.csv'],['Count of HeyTaiZen_tweets.csv'],['Count of iamjosephyoung_tweets.csv'],['Count of iam_preethi_tweets.csv'],['Count of IOHK_charles_tweets.csv'],['Count of jgarzik_tweets.csv'],['Count of jihanwu_tweets.csv'],['Count of jimmysong_tweets.csv'],['Count of jonmatonis_tweets.csv'],['Count of joonian_tweets.csv'],['Count of josephzhou_tweets.csv'],['Count of juanbenet_tweets.csv'],['Count of Kris_HK_tweets.csv'],['Count of kyletorpey_tweets.csv'],['Count of laurashin_tweets.csv'],['Count of leashless_tweets.csv'],['Count of ljxie_tweets.csv'],['Count of lopp_tweets.csv'],['Count of mbauwens_tweets.csv'],['Count of Melt_Dem_tweets.csv'],['Count of michaelkitces_tweets.csv'],['Count of MrChrisEllis_tweets.csv'],['Count of muneeb_tweets.csv'],['Count of naval_tweets.csv'],['Count of nejc_kodric_tweets.csv'],['Count of niccary_tweets.csv'],['Count of NickSzabo4_tweets.csv'],['Count of novogratz_tweets.csv'],['Count of oleganza_tweets.csv'],['Count of OneMorePeter_tweets.csv'],['Count of oscarwgrut_tweets.csv'],['Count of peterktodd_tweets.csv'],['Count of pierre_rochard_tweets.csv'],['Count of prestonjbyrne_tweets.csv'],['Count of proffaustus_tweets.csv'],['Count of roasbeef_tweets.csv'],['Count of rogerkver_tweets.csv'],['Count of ryanxcharles_tweets.csv'],['Count of SatoshiLite_tweets.csv'],['Count of slushcz_tweets.csv'],['Count of spair_tweets.csv'],['Count of starkness_tweets.csv'],['Count of StephanTual_tweets.csv'],['Count of SunnyStartups_tweets.csv'],['Count of SusanneChishti_tweets.csv'],['Count of thomaspower_tweets.csv'],['Count of TimDraper_tweets.csv'],['Count of ToneVays_tweets.csv'],['Count of TonyGallippi_tweets.csv'],['Count of TuurDemeester_tweets.csv'],['Count of twobitidiot_tweets.csv'],['Count of tylerwinklevoss_tweets.csv'],['Count of ummjackson_tweets.csv'],['Count of VentureCoinist_tweets.csv'],['Count of VinnyLingham_tweets.csv'],['Count of VitalikButerin_tweets.csv'],['Count of VladZamfir_tweets.csv'],['Count of wmougayar_tweets.csv'],['Count of woonomic_tweets.csv'],['Count of _jonasschnelli__tweets.csv'],['Compound score of aantonop_tweets.csv'],['Compound score of adam3us_tweets.csv'],['Compound score of alansilbert_tweets.csv'],['Compound score of alexsunnarborg_tweets.csv'],['Compound score of alextapscott_tweets.csv'],['Compound score of anondran_tweets.csv'],['Compound score of AnselLindner_tweets.csv'],['Compound score of AriannaSimpson_tweets.csv'],['Compound score of AriDavidPaul_tweets.csv'],['Compound score of arrington_tweets.csv'],['Compound score of barrysilbert_tweets.csv'],['Compound score of bendavenport_tweets.csv'],['Compound score of bgarlinghouse_tweets.csv'],['Compound score of bitcoinbyte_tweets.csv'],['Compound score of bobbyclee_tweets.csv'],['Compound score of brian_armstrong_tweets.csv'],['Compound score of brockpierce_tweets.csv'],['Compound score of CarpeNoctom_tweets.csv'],['Compound score of cburniske_tweets.csv'],['Compound score of certainassets_tweets.csv'],['Compound score of CharlieShrem_tweets.csv'],['Compound score of chrislarsensf_tweets.csv'],['Compound score of CremeDeLaCrypto_tweets.csv'],['Compound score of cryptomanran_tweets.csv'],['Compound score of dahongfei_tweets.csv'],['Compound score of dan_pantera_tweets.csv'],['Compound score of DerinCag_tweets.csv'],['Compound score of derose_tweets.csv'],['Compound score of desantis_tweets.csv'],['Compound score of dieguito_tweets.csv'],['Compound score of dinisguarda_tweets.csv'],['Compound score of dtapscott_tweets.csv'],['Compound score of eiaine_tweets.csv'],['Compound score of eric_lombrozo_tweets.csv'],['Compound score of ErikVoorhees_tweets.csv'],['Compound score of ethereumjoseph_tweets.csv'],['Compound score of FEhrsam_tweets.csv'],['Compound score of francispouliot__tweets.csv'],['Compound score of fredwilson_tweets.csv'],['Compound score of gavinandresen_tweets.csv'],['Compound score of gavofyork_tweets.csv'],['Compound score of HeyTaiZen_tweets.csv'],['Compound score of iamjosephyoung_tweets.csv'],['Compound score of iam_preethi_tweets.csv'],['Compound score of IOHK_charles_tweets.csv'],['Compound score of jgarzik_tweets.csv'],['Compound score of jihanwu_tweets.csv'],['Compound score of jimmysong_tweets.csv'],['Compound score of jonmatonis_tweets.csv'],['Compound score of joonian_tweets.csv'],['Compound score of josephzhou_tweets.csv'],['Compound score of juanbenet_tweets.csv'],['Compound score of Kris_HK_tweets.csv'],['Compound score of kyletorpey_tweets.csv'],['Compound score of laurashin_tweets.csv'],['Compound score of leashless_tweets.csv'],['Compound score of ljxie_tweets.csv'],['Compound score of lopp_tweets.csv'],['Compound score of mbauwens_tweets.csv'],['Compound score of Melt_Dem_tweets.csv'],['Compound score of michaelkitces_tweets.csv'],['Compound score of MrChrisEllis_tweets.csv'],['Compound score of muneeb_tweets.csv'],['Compound score of naval_tweets.csv'],['Compound score of nejc_kodric_tweets.csv'],['Compound score of niccary_tweets.csv'],['Compound score of NickSzabo4_tweets.csv'],['Compound score of novogratz_tweets.csv'],['Compound score of oleganza_tweets.csv'],['Compound score of OneMorePeter_tweets.csv'],['Compound score of oscarwgrut_tweets.csv'],['Compound score of peterktodd_tweets.csv'],['Compound score of pierre_rochard_tweets.csv'],['Compound score of prestonjbyrne_tweets.csv'],['Compound score of proffaustus_tweets.csv'],['Compound score of roasbeef_tweets.csv'],['Compound score of rogerkver_tweets.csv'],['Compound score of ryanxcharles_tweets.csv'],['Compound score of SatoshiLite_tweets.csv'],['Compound score of slushcz_tweets.csv'],['Compound score of spair_tweets.csv'],['Compound score of starkness_tweets.csv'],['Compound score of StephanTual_tweets.csv'],['Compound score of SunnyStartups_tweets.csv'],['Compound score of SusanneChishti_tweets.csv'],['Compound score of thomaspower_tweets.csv'],['Compound score of TimDraper_tweets.csv'],['Compound score of ToneVays_tweets.csv'],['Compound score of TonyGallippi_tweets.csv'],['Compound score of TuurDemeester_tweets.csv'],['Compound score of twobitidiot_tweets.csv'],['Compound score of tylerwinklevoss_tweets.csv'],['Compound score of ummjackson_tweets.csv'],['Compound score of VentureCoinist_tweets.csv'],['Compound score of VinnyLingham_tweets.csv'],['Compound score of VitalikButerin_tweets.csv'],['Compound score of VladZamfir_tweets.csv'],['Compound score of wmougayar_tweets.csv'],['Compound score of woonomic_tweets.csv'],['Compound score of _jonasschnelli__tweets.csv'],['Negative score of aantonop_tweets.csv'],['Negative score of adam3us_tweets.csv'],['Negative score of alansilbert_tweets.csv'],['Negative score of alexsunnarborg_tweets.csv'],['Negative score of alextapscott_tweets.csv'],['Negative score of anondran_tweets.csv'],['Negative score of AnselLindner_tweets.csv'],['Negative score of AriannaSimpson_tweets.csv'],['Negative score of AriDavidPaul_tweets.csv'],['Negative score of arrington_tweets.csv'],['Negative score of barrysilbert_tweets.csv'],['Negative score of bendavenport_tweets.csv'],['Negative score of bgarlinghouse_tweets.csv'],['Negative score of bitcoinbyte_tweets.csv'],['Negative score of bobbyclee_tweets.csv'],['Negative score of brian_armstrong_tweets.csv'],['Negative score of brockpierce_tweets.csv'],['Negative score of CarpeNoctom_tweets.csv'],['Negative score of cburniske_tweets.csv'],['Negative score of certainassets_tweets.csv'],['Negative score of CharlieShrem_tweets.csv'],['Negative score of chrislarsensf_tweets.csv'],['Negative score of CremeDeLaCrypto_tweets.csv'],['Negative score of cryptomanran_tweets.csv'],['Negative score of dahongfei_tweets.csv'],['Negative score of dan_pantera_tweets.csv'],['Negative score of DerinCag_tweets.csv'],['Negative score of derose_tweets.csv'],['Negative score of desantis_tweets.csv'],['Negative score of dieguito_tweets.csv'],['Negative score of dinisguarda_tweets.csv'],['Negative score of dtapscott_tweets.csv'],['Negative score of eiaine_tweets.csv'],['Negative score of eric_lombrozo_tweets.csv'],['Negative score of ErikVoorhees_tweets.csv'],['Negative score of ethereumjoseph_tweets.csv'],['Negative score of FEhrsam_tweets.csv'],['Negative score of francispouliot__tweets.csv'],['Negative score of fredwilson_tweets.csv'],['Negative score of gavinandresen_tweets.csv'],['Negative score of gavofyork_tweets.csv'],['Negative score of HeyTaiZen_tweets.csv'],['Negative score of iamjosephyoung_tweets.csv'],['Negative score of iam_preethi_tweets.csv'],['Negative score of IOHK_charles_tweets.csv'],['Negative score of jgarzik_tweets.csv'],['Negative score of jihanwu_tweets.csv'],['Negative score of jimmysong_tweets.csv'],['Negative score of jonmatonis_tweets.csv'],['Negative score of joonian_tweets.csv'],['Negative score of josephzhou_tweets.csv'],['Negative score of juanbenet_tweets.csv'],['Negative score of Kris_HK_tweets.csv'],['Negative score of kyletorpey_tweets.csv'],['Negative score of laurashin_tweets.csv'],['Negative score of leashless_tweets.csv'],['Negative score of ljxie_tweets.csv'],['Negative score of lopp_tweets.csv'],['Negative score of mbauwens_tweets.csv'],['Negative score of Melt_Dem_tweets.csv'],['Negative score of michaelkitces_tweets.csv'],['Negative score of MrChrisEllis_tweets.csv'],['Negative score of muneeb_tweets.csv'],['Negative score of naval_tweets.csv'],['Negative score of nejc_kodric_tweets.csv'],['Negative score of niccary_tweets.csv'],['Negative score of NickSzabo4_tweets.csv'],['Negative score of novogratz_tweets.csv'],['Negative score of oleganza_tweets.csv'],['Negative score of OneMorePeter_tweets.csv'],['Negative score of oscarwgrut_tweets.csv'],['Negative score of peterktodd_tweets.csv'],['Negative score of pierre_rochard_tweets.csv'],['Negative score of prestonjbyrne_tweets.csv'],['Negative score of proffaustus_tweets.csv'],['Negative score of roasbeef_tweets.csv'],['Negative score of rogerkver_tweets.csv'],['Negative score of ryanxcharles_tweets.csv'],['Negative score of SatoshiLite_tweets.csv'],['Negative score of slushcz_tweets.csv'],['Negative score of spair_tweets.csv'],['Negative score of starkness_tweets.csv'],['Negative score of StephanTual_tweets.csv'],['Negative score of SunnyStartups_tweets.csv'],['Negative score of SusanneChishti_tweets.csv'],['Negative score of thomaspower_tweets.csv'],['Negative score of TimDraper_tweets.csv'],['Negative score of ToneVays_tweets.csv'],['Negative score of TonyGallippi_tweets.csv'],['Negative score of TuurDemeester_tweets.csv'],['Negative score of twobitidiot_tweets.csv'],['Negative score of tylerwinklevoss_tweets.csv'],['Negative score of ummjackson_tweets.csv'],['Negative score of VentureCoinist_tweets.csv'],['Negative score of VinnyLingham_tweets.csv'],['Negative score of VitalikButerin_tweets.csv'],['Negative score of VladZamfir_tweets.csv'],['Negative score of wmougayar_tweets.csv'],['Negative score of woonomic_tweets.csv'],['Negative score of _jonasschnelli__tweets.csv'],['Neutral score of aantonop_tweets.csv'],['Neutral score of adam3us_tweets.csv'],['Neutral score of alansilbert_tweets.csv'],['Neutral score of alexsunnarborg_tweets.csv'],['Neutral score of alextapscott_tweets.csv'],['Neutral score of anondran_tweets.csv'],['Neutral score of AnselLindner_tweets.csv'],['Neutral score of AriannaSimpson_tweets.csv'],['Neutral score of AriDavidPaul_tweets.csv'],['Neutral score of arrington_tweets.csv'],['Neutral score of barrysilbert_tweets.csv'],['Neutral score of bendavenport_tweets.csv'],['Neutral score of bgarlinghouse_tweets.csv'],['Neutral score of bitcoinbyte_tweets.csv'],['Neutral score of bobbyclee_tweets.csv'],['Neutral score of brian_armstrong_tweets.csv'],['Neutral score of brockpierce_tweets.csv'],['Neutral score of CarpeNoctom_tweets.csv'],['Neutral score of cburniske_tweets.csv'],['Neutral score of certainassets_tweets.csv'],['Neutral score of CharlieShrem_tweets.csv'],['Neutral score of chrislarsensf_tweets.csv'],['Neutral score of CremeDeLaCrypto_tweets.csv'],['Neutral score of cryptomanran_tweets.csv'],['Neutral score of dahongfei_tweets.csv'],['Neutral score of dan_pantera_tweets.csv'],['Neutral score of DerinCag_tweets.csv'],['Neutral score of derose_tweets.csv'],['Neutral score of desantis_tweets.csv'],['Neutral score of dieguito_tweets.csv'],['Neutral score of dinisguarda_tweets.csv'],['Neutral score of dtapscott_tweets.csv'],['Neutral score of eiaine_tweets.csv'],['Neutral score of eric_lombrozo_tweets.csv'],['Neutral score of ErikVoorhees_tweets.csv'],['Neutral score of ethereumjoseph_tweets.csv'],['Neutral score of FEhrsam_tweets.csv'],['Neutral score of francispouliot__tweets.csv'],['Neutral score of fredwilson_tweets.csv'],['Neutral score of gavinandresen_tweets.csv'],['Neutral score of gavofyork_tweets.csv'],['Neutral score of HeyTaiZen_tweets.csv'],['Neutral score of iamjosephyoung_tweets.csv'],['Neutral score of iam_preethi_tweets.csv'],['Neutral score of IOHK_charles_tweets.csv'],['Neutral score of jgarzik_tweets.csv'],['Neutral score of jihanwu_tweets.csv'],['Neutral score of jimmysong_tweets.csv'],['Neutral score of jonmatonis_tweets.csv'],['Neutral score of joonian_tweets.csv'],['Neutral score of josephzhou_tweets.csv'],['Neutral score of juanbenet_tweets.csv'],['Neutral score of Kris_HK_tweets.csv'],['Neutral score of kyletorpey_tweets.csv'],['Neutral score of laurashin_tweets.csv'],['Neutral score of leashless_tweets.csv'],['Neutral score of ljxie_tweets.csv'],['Neutral score of lopp_tweets.csv'],['Neutral score of mbauwens_tweets.csv'],['Neutral score of Melt_Dem_tweets.csv'],['Neutral score of michaelkitces_tweets.csv'],['Neutral score of MrChrisEllis_tweets.csv'],['Neutral score of muneeb_tweets.csv'],['Neutral score of naval_tweets.csv'],['Neutral score of nejc_kodric_tweets.csv'],['Neutral score of niccary_tweets.csv'],['Neutral score of NickSzabo4_tweets.csv'],['Neutral score of novogratz_tweets.csv'],['Neutral score of oleganza_tweets.csv'],['Neutral score of OneMorePeter_tweets.csv'],['Neutral score of oscarwgrut_tweets.csv'],['Neutral score of peterktodd_tweets.csv'],['Neutral score of pierre_rochard_tweets.csv'],['Neutral score of prestonjbyrne_tweets.csv'],['Neutral score of proffaustus_tweets.csv'],['Neutral score of roasbeef_tweets.csv'],['Neutral score of rogerkver_tweets.csv'],['Neutral score of ryanxcharles_tweets.csv'],['Neutral score of SatoshiLite_tweets.csv'],['Neutral score of slushcz_tweets.csv'],['Neutral score of spair_tweets.csv'],['Neutral score of starkness_tweets.csv'],['Neutral score of StephanTual_tweets.csv'],['Neutral score of SunnyStartups_tweets.csv'],['Neutral score of SusanneChishti_tweets.csv'],['Neutral score of thomaspower_tweets.csv'],['Neutral score of TimDraper_tweets.csv'],['Neutral score of ToneVays_tweets.csv'],['Neutral score of TonyGallippi_tweets.csv'],['Neutral score of TuurDemeester_tweets.csv'],['Neutral score of twobitidiot_tweets.csv'],['Neutral score of tylerwinklevoss_tweets.csv'],['Neutral score of ummjackson_tweets.csv'],['Neutral score of VentureCoinist_tweets.csv'],['Neutral score of VinnyLingham_tweets.csv'],['Neutral score of VitalikButerin_tweets.csv'],['Neutral score of VladZamfir_tweets.csv'],['Neutral score of wmougayar_tweets.csv'],['Neutral score of woonomic_tweets.csv'],['Neutral score of _jonasschnelli__tweets.csv'],['Positive score of aantonop_tweets.csv'],['Positive score of adam3us_tweets.csv'],['Positive score of alansilbert_tweets.csv'],['Positive score of alexsunnarborg_tweets.csv'],['Positive score of alextapscott_tweets.csv'],['Positive score of anondran_tweets.csv'],['Positive score of AnselLindner_tweets.csv'],['Positive score of AriannaSimpson_tweets.csv'],['Positive score of AriDavidPaul_tweets.csv'],['Positive score of arrington_tweets.csv'],['Positive score of barrysilbert_tweets.csv'],['Positive score of bendavenport_tweets.csv'],['Positive score of bgarlinghouse_tweets.csv'],['Positive score of bitcoinbyte_tweets.csv'],['Positive score of bobbyclee_tweets.csv'],['Positive score of brian_armstrong_tweets.csv'],['Positive score of brockpierce_tweets.csv'],['Positive score of CarpeNoctom_tweets.csv'],['Positive score of cburniske_tweets.csv'],['Positive score of certainassets_tweets.csv'],['Positive score of CharlieShrem_tweets.csv'],['Positive score of chrislarsensf_tweets.csv'],['Positive score of CremeDeLaCrypto_tweets.csv'],['Positive score of cryptomanran_tweets.csv'],['Positive score of dahongfei_tweets.csv'],['Positive score of dan_pantera_tweets.csv'],['Positive score of DerinCag_tweets.csv'],['Positive score of derose_tweets.csv'],['Positive score of desantis_tweets.csv'],['Positive score of dieguito_tweets.csv'],['Positive score of dinisguarda_tweets.csv'],['Positive score of dtapscott_tweets.csv'],['Positive score of eiaine_tweets.csv'],['Positive score of eric_lombrozo_tweets.csv'],['Positive score of ErikVoorhees_tweets.csv'],['Positive score of ethereumjoseph_tweets.csv'],['Positive score of FEhrsam_tweets.csv'],['Positive score of francispouliot__tweets.csv'],['Positive score of fredwilson_tweets.csv'],['Positive score of gavinandresen_tweets.csv'],['Positive score of gavofyork_tweets.csv'],['Positive score of HeyTaiZen_tweets.csv'],['Positive score of iamjosephyoung_tweets.csv'],['Positive score of iam_preethi_tweets.csv'],['Positive score of IOHK_charles_tweets.csv'],['Positive score of jgarzik_tweets.csv'],['Positive score of jihanwu_tweets.csv'],['Positive score of jimmysong_tweets.csv'],['Positive score of jonmatonis_tweets.csv'],['Positive score of joonian_tweets.csv'],['Positive score of josephzhou_tweets.csv'],['Positive score of juanbenet_tweets.csv'],['Positive score of Kris_HK_tweets.csv'],['Positive score of kyletorpey_tweets.csv'],['Positive score of laurashin_tweets.csv'],['Positive score of leashless_tweets.csv'],['Positive score of ljxie_tweets.csv'],['Positive score of lopp_tweets.csv'],['Positive score of mbauwens_tweets.csv'],['Positive score of Melt_Dem_tweets.csv'],['Positive score of michaelkitces_tweets.csv'],['Positive score of MrChrisEllis_tweets.csv'],['Positive score of muneeb_tweets.csv'],['Positive score of naval_tweets.csv'],['Positive score of nejc_kodric_tweets.csv'],['Positive score of niccary_tweets.csv'],['Positive score of NickSzabo4_tweets.csv'],['Positive score of novogratz_tweets.csv'],['Positive score of oleganza_tweets.csv'],['Positive score of OneMorePeter_tweets.csv'],['Positive score of oscarwgrut_tweets.csv'],['Positive score of peterktodd_tweets.csv'],['Positive score of pierre_rochard_tweets.csv'],['Positive score of prestonjbyrne_tweets.csv'],['Positive score of proffaustus_tweets.csv'],['Positive score of roasbeef_tweets.csv'],['Positive score of rogerkver_tweets.csv'],['Positive score of ryanxcharles_tweets.csv'],['Positive score of SatoshiLite_tweets.csv'],['Positive score of slushcz_tweets.csv'],['Positive score of spair_tweets.csv'],['Positive score of starkness_tweets.csv'],['Positive score of StephanTual_tweets.csv'],['Positive score of SunnyStartups_tweets.csv'],['Positive score of SusanneChishti_tweets.csv'],['Positive score of thomaspower_tweets.csv'],['Positive score of TimDraper_tweets.csv'],['Positive score of ToneVays_tweets.csv'],['Positive score of TonyGallippi_tweets.csv'],['Positive score of TuurDemeester_tweets.csv'],['Positive score of twobitidiot_tweets.csv'],['Positive score of tylerwinklevoss_tweets.csv'],['Positive score of ummjackson_tweets.csv'],['Positive score of VentureCoinist_tweets.csv'],['Positive score of VinnyLingham_tweets.csv'],['Positive score of VitalikButerin_tweets.csv'],['Positive score of VladZamfir_tweets.csv'],['Positive score of wmougayar_tweets.csv'],['Positive score of woonomic_tweets.csv'],['Positive score of _jonasschnelli__tweets.csv'],['Price_classification'])

x = np.asarray(training)
y = np.asarray(labels)

x = np.reshape(x,newshape=(501,14373))

clf = svm.SVC()

print(clf.fit(x, y))
print(clf.predict(testing))

由于python 3.6 不允许传递超过 255 个参数,因此我创建了一个数组,其中包含所有标签并分配给 y。我对机器学习算法完全陌生,不知道为什么会出现此错误或如何修复它。我尝试查找已在此处发布的不同问题,但找不到任何解决方案。

请注意,我很容易 运行 通过仅在 'Price_classification' 的 1 个特征上训练该算法,并且也成功地使其能够进行预测,但是当我 运行 上面的代码,我不断收到 Unknown Label Type : unknown 错误。 x 有 501 列和 14373 行,y 有 501 行。

我什至尝试了以下方法:

y = np.asarray(labels)
y = y.astype(str)

但是我会收到以下错误

ValueError: setting an array element with a sequence

我们将不胜感激任何帮助。

谢谢

包含文件的文件夹的 link 如下:

Training.csv, Testing.csv and Classification.py script

编辑 1

以上数据实际上是手工编译的,因为我可以简单地使用 train_test_split 来训练和测试一个文件。假设我有一个名为 completedataset.csv 的文件。我正在尝试使用 train_test_split 但现在我得到

ValueError: Shape of passed values is (14373, 501), indices imply (501, 14373) 

代码如下:

new_labels = []
for counter,value in enumerate(labels) :
    new_labels.append(counter)

X_train, X_test = train_test_split(file, test_size=0.25)
y_train = new_labels

X_train = np.reshape(X_train,newshape=(501,14373))

clf = svm.SVC()
print(clf.fit(X_train, y_train))

我也将 completedataset.csv 文件上传到该文件夹​​。文件的 link 如下:

completedataset.csv used for train_test_split

谢谢

  • 问题是 y 变量包含字符串。
  • 你应该用另一种方式来表示它的样本所属的class。
  • 例如,如果您有 3 个不同的 class,您可以在 y 中使用 0,1 和 2。
  • 根据数据,我了解到这些是高音扬声器数据,我看到您将标签命名为:中性、正面、负面等。您可以只使用 0、1、2 来定义标签。 Sklearn 算法需要 classes.
  • 的标量表示

转换您的 y 后,SVC 将正常工作。

示例:查看 classes 如何在 iris 数据集的 y 变量中表示。

import numpy as np
import matplotlib.pyplot as plt
from sklearn import svm, datasets

iris = datasets.load_iris()
X = iris.data
y = iris.target

np.unique(y)
#array([0, 1, 2])

然后 SVC 工作正常。


编辑 1

from sklearn import cross_validation
from sklearn import datasets
from sklearn.svm import SVC

iris = datasets.load_iris()
X = iris.data
y = iris.target

# use train_test_split to split into training and testing data
x_train, x_test, y_train, y_test = cross_validation.train_test_split(
X, y,test_size=0.4,random_state=0)

# fit / train the model using the training data
clf = SVC(kernel="linear")
clf.fit(x_train, y_train)

# predict using the trained model using the testing data
y_predicted = clf.predict(x_test)

# get the accuracy of the classifier using .score attribute
acc = clf.score(x_test,y_test)
print('The accuracy of the SVC classifier is {}'.format(acc))

编辑 2:这是一个使用您的数据集的示例。

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn import svm
from sklearn import cross_validation
from sklearn import datasets
from sklearn.svm import SVC


df = pd.read_csv('completedataset.csv')
df = df.dropna()

X = df.iloc[:,1:500]
y = df.iloc[:, df.shape[1]-1]
X = X.values
y = y.values


# use train_test_split to split into training and testing data
x_train, x_test, y_train, y_test = cross_validation.train_test_split(
X, y,test_size=0.4,random_state=0)

# fit / train the model using the training data
clf = SVC(kernel="linear")
clf.fit(x_train, y_train)

# predict using the trained model using the testing data
y_predicted = clf.predict(x_test)

# get the accuracy of the classifier using .score attribute
acc = clf.score(x_test,y_test)
print('\n\nThe accuracy of the SVC classifier is {}'.format(acc))