SHARE
TWEET

Untitled

a guest Jun 19th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. df=pd.read_csv('DTMNegatif.csv', index_col=0)
  2. train, validate, test = np.split(df.sample(frac=1), [int(.6*len(df)), int(.8*len(df))])
  3. print (train)
  4. train.to_csv("trainNegatif.csv", sep=',')
  5. validate.to_csv("validateNegatif.csv",sep=',')
  6. test.to_csv("testNegatif.csv",sep=',')
  7.  
  8. #CODE TRAINING DATA FOR NAIVE BAYES
  9. df=pd.read_csv('trainNegatif.csv', index_col=0)
  10. df2=df.copy()
  11. columns_names = list(df.columns.values)
  12. total_kata=[]
  13. list_kata=[]
  14.  
  15. for col in columns_names:
  16.     df.loc['Total',col] =  df[col].sum()
  17.     #sum1 = df[col].sum()
  18.     if df[col].sum()<2:
  19.             del df2[col]
  20.     else:
  21.             df2.loc['Total',col] =  df2[col].sum()
  22.             total_kata.append(df2[col].sum())
  23.             list_kata.append(col)
  24.  
  25. num = np.zeros(shape=(len(total_kata), 2), dtype=object)            
  26. for n, (total_kata, list_kata) in enumerate(zip(total_kata, list_kata)):
  27.     num[n,0]=total_kata
  28.     num[n,1]=list_kata
  29.  
  30. df3 = pd.DataFrame({'Kata':num[:,1],'Frekuensi':num[:,0]})
  31. df2.to_csv("SeleksiFiturNegatif.csv", sep=',')
  32. df3.to_csv("tabelFrekuensiNegatif.csv", sep=',')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top