- import pandas as pd
- from sklearn.tree import DecisionTreeClassifier
- df = pd.read_csv('/datasets/train_data.csv')
- df.loc[df['last_price'] > 5650000, 'price_class'] = 1
- df.loc[df['last_price'] <= 5650000, 'price_class'] = 0
- features = df.drop(['last_price', 'price_class'], axis=1)
- target = df['price_class']
- model = DecisionTreeClassifier(random_state=12345)
- model.fit(features, target)
- test_df = pd.read_csv('/datasets/test_data.csv')
- test_df.loc[test_df['last_price'] > 5650000, 'price_class'] = 1
- test_df.loc[test_df['last_price'] <= 5650000, 'price_class'] = 0
- test_features = test_df.drop(['last_price', 'price_class'], axis=1)
- test_target = test_df['price_class']
- test_predictions = model.predict(test_features)
- ans_pred_count = []
- def error_count(answers, predictions):
- # < напишите код функции здесь >
- mist_count = 0
- for i in range(len(answers.values)):
- if i != predictions[0]:
- mist_count += 1
- return mist_count
- print("Ошибок:", error_count(test_target, test_predictions))
- ________________
- Ошибок: 647
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
— Expand Paste to full width of browser