Search code examples
pythonscikit-learnlabelsvc

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


As the title says, I am trying to run the svc algorithm on a dataset but I keep getting the error :

Unknown Label Type : unknown error

The code is as below :

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

Since python 3.6 doesn't allow to pass more than 255 arguments, hence I created an array containing all the labels and the assigned to y. I am completely new to machine learning algorithms and have no idea as to why I am getting this error or how to fix it. I tried looking up different questions already posted here but could not find any solution.

Please note that I was easily able run the algorithm by training only on 1 feature that is 'Price_classification' and was successfully able to get it to predict as well but when I run the code above, I keep getting Unknown Label Type : unknown error. There are 501 columns and 14373 rows in x and 501 rows in y.

I even tried the following :

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

but then I would get the following error

ValueError: setting an array element with a sequence

Any and all help would be greatly appreciated.

Thanks

The link to the folder containing the files is as below :

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

EDIT 1

The above data was in fact compiled by hand where as I could simply use a train_test_split to train and test on only one file. Say I have a file called completedataset.csv. I am trying to use train_test_split but now I get

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

The code is as below :

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

I have uploaded the completedataset.csv file to the folder as well. The link to the file is as below :

completedataset.csv used for train_test_split

Thanks


Solution

    • The problem is that the y variable contains strings.
    • You should use another way to denote the class that its sample belongs to.
    • For example, if you have 3 different classes you could use 0,1 and 2 in y.
    • From the data, I understand that these are tweeter data and I saw that you name the labels as: neutral, positive, negative etc. You could just use 0,1,2 to define the labels. Sklearn algorithms require scalar representation of the classes.

    After transforming your y, SVC will work fine.

    Example: See how classes are represented in y variable for the iris dataset.

    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])
    

    Then SVC works fine.


    EDIT 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))
    

    EDIT 2: here is an example using your dataset.

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