Re: Untitled

From dol4iha, 4 Months ago, written in Plain Text, viewed 62 times. This paste is a reply to Untitled from dol4iha - view diff
URL http://codebin.org/view/4765c17c Embed
Download Paste or View Raw
  1. import pandas as pd
  2. from sklearn.tree import DecisionTreeClassifier
  3.  
  4. df = pd.read_csv('/datasets/train_data.csv')
  5.  
  6. df.loc[df['last_price'] > 5650000, 'price_class'] = 1
  7. df.loc[df['last_price'] <= 5650000, 'price_class'] = 0
  8.  
  9. features = df.drop(['last_price', 'price_class'], axis=1)
  10. target = df['price_class']
  11.  
  12. model = DecisionTreeClassifier(random_state=12345)
  13.  
  14. model.fit(features, target)
  15.  
  16. test_df = pd.read_csv('/datasets/test_data.csv')
  17.  
  18. test_df.loc[test_df['last_price'] > 5650000, 'price_class'] = 1
  19. test_df.loc[test_df['last_price'] <= 5650000, 'price_class'] = 0
  20.  
  21. test_features = test_df.drop(['last_price', 'price_class'], axis=1)
  22. test_target = test_df['price_class']
  23. test_predictions = model.predict(test_features)
  24.  
  25. ans_pred_count = []
  26.  
  27. def error_count(answers, predictions):
  28.     # < напишите код функции здесь >
  29.     mist_count = 0
  30.     for i in range(len(answers.values)):
  31.         if i != predictions[0]:
  32.             mist_count += 1
  33.     return mist_count
  34.  
  35. print("Ошибок:", error_count(test_target, test_predictions))
  36.  
  37.  
  38.  
  39. ________________
  40.  
  41.  
  42. Ошибок: 647

Reply to "Re: Untitled"

Here you can reply to the paste above