Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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()
- model.fit(features, target)
- new_features = pd.DataFrame(
- [[None, None, 2.8, 25, None, 25, 0, 0, 0, None, 0, 30706.0, 7877.0],
- [None, None, 2.75, 25, None, 25, 0, 0, 0, None, 0, 36421.0, 9176.0]],
- columns=features.columns)
- # дозаполните таблицу с новыми признаками
- #new_features.loc[0, 'total_area'] = 900.0
- # < напишите код здесь >
- #new_features.loc[0:1, 'total_area', 'rooms', 'living_area', 'kitchen_area'] = [[900.0, 12, 409.7, 112.0], [109.0, 2, 32.0, 40.5]]
- new_features.loc[0:1, 'total_area', 'rooms', 'ceiling_height', 'floors_total', 'living_area', 'floor', 'is_apartment', 'studio', 'open_plan', 'kitchen_area', 'balcony', 'airports_nearest', 'cityCenters_nearest'] = [[900.0, 12, 2.8, 25, 409.7, 25, 0, 0, 0, 112.0, 0, 30706.0, 7877.0], [109.0, 2, 2.75, 25, 32.0, 25, 0, 0, 0, 40.5, 0, 36421.0, 9176.0]]
- # предскажите ответы и напечатайте результат на экране
- # < напишите код здесь >
- answers = model.predict(new_features)
- print(answers)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement