# What's wrong with this code

**URL:** <https://forum.codewithmosh.com/t/whats-wrong-with-this-code/18091>\
**Category:** Python\
**Created:** [February 4, 2023, 2:13pm UTC](https://forum.codewithmosh.com/t/whats-wrong-with-this-code/18091 "2023-02-04T14:13:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Waqar](https://avatars.discourse-cdn.com/v4/letter/w/7993a0/32.png) [@Waqar](https://forum.codewithmosh.com/u/Waqar)\
**Post date:** [February 4, 2023, 2:13pm UTC](https://forum.codewithmosh.com/t/whats-wrong-with-this-code/18091/1 "2023-02-04T14:13:07Z")

</div>

What’s wrong with this code

import pandas as pd  
from sklearn.tree import DecisionTreeClassifier

income\_data = pd.read\_csv(‘C:\Waqar\Code with Mosh\Python Learning\Sample Income.csv’)  
X = income\_data.drop(columns = [‘Income’])  
y = income\_data[‘Income’]

model = DecisionTreeClassifier()  
model.fit(X, y)  
predictions = model.predict([2023])

hear is the data of csv file

| Year | Income | |
| --- | --- | --- |
| 2015 | 50000 | |
| 2016 | 51000 | |
| 2017 | 52020 | |
| 2018 | 53060.4 | |
| 2019 | 54121.2 | |
| 2020 | 55203.42 | |
| 2021 | 56307.06 | |
| 2022 | 57433.14 | |

---

<div class="post-metadata">

**Author:** ![AzharUddinSheikh](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/azharuddinsheikh/32/5561_2.png) [@AzharUddinSheikh](https://forum.codewithmosh.com/u/AzharUddinSheikh)\
**Post date:** [February 8, 2023, 7:15am UTC](https://forum.codewithmosh.com/t/whats-wrong-with-this-code/18091/2 "2023-02-08T07:15:41Z")

</div>

I think before predicting you need to train and test your data  
It’s seem you haven’t done that
