Advertisement
Tranvick

Pizza

Oct 27th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. import pandas as pd
  2. import numpy as np
  3. from sklearn.ensemble import RandomForestClassifier
  4.  
  5. train = pd.read_json('train.json')
  6. test = pd.read_json('test.json')
  7. y = train.requester_received_pizza
  8. ids = test.request_id
  9. string_columns = [column for dtype, column in zip(list(test.dtypes), list(test.dtypes.index))
  10.                   if dtype == np.dtype('O')]
  11.  
  12. test.drop(string_columns, inplace=True, axis=1)
  13. train = train[test.columns]
  14. clf = RandomForestClassifier(n_estimators=1000)
  15. clf.fit(train.values, y)
  16. predictions = clf.predict_proba(test.values)
  17. pd.Series(predictions[:, 1], index=ids, name='requester_received_pizza').to_csv('res.csv', header=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement