<jupyter_start><jupyter_text>Some moments and overview of data<jupyter_code>data.info()
data.describe()
data.skew()
data.kurt()
data.shape
data.var()<jupyter_output><empty_output><jupyter_text>Correlation<jupyter_code>data.corr()<jupyter_output><empty_output><jupyter_text>**No variable is strongly correlated with sales  PPS Score<jupyter_code>import ppscore as pps
pps.matrix(data)<jupyter_output><empty_output><jupyter_text>Pair-plot<jupyter_code>import seaborn as sns
sns.set_style(style='darkgrid')
sns.pairplot(data)<jupyter_output><empty_output><jupyter_text>Basic EDA Process<jupyter_code>data.head()
data.value_counts('ShelveLoc')
data.value_counts('Urban')
data.value_counts('US')
Data = pd.get_dummies(data=data,columns=['ShelveLoc','Urban','US'])
Data.head()
Data.shape<jupyter_output><empty_output><jupyter_text>Isolation forest for detecting outliers<jupyter_code>from sklearn.ensemble import IsolationForest
clf = IsolationForest(random_state=10,contamination=.01)
clf.fit(Data)
y_pred_outliers = clf.predict(Data)
y_pred_outliers
Data['scores']=clf.decision_function(Data)
Data['anomaly']=clf.predict(Data.iloc[:,0:15])
Data.head()
Data[Data['anomaly']==-1]
x = Data.iloc[:,2:]
y = Data['Sales']
x
y<jupyter_output><empty_output><jupyter_text>Model building Decision tree regressor<jupyter_code>from sklearn.tree import DecisionTreeRegressor
Data.head()
array = Data.values
X = array[:,1:]
y = array[:,0]

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1)
model = DecisionTreeRegressor()
model.fit(X_train, y_train)
tree.plot_tree(model);

pred_y = model.predict(X_test)
pred_y
pred_y1 = model.predict(X_train)
pred_y1
errors= pred_y-y_test
errors
model.score(X_test,y_test)
model.score(X_train,y_train)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1399548532731377, 'fraction_numerical': 0.008465011286681716, 'mean_word_length': 10.741721854304636, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '455619', 'license': 'MIT', 'n_tokens_mistral': 729, 'n_tokens_neox': 701, 'n_words': 97, 'path': 'Decision trees   ass-1 .ipynb', 'repo_name': 'Bommureddy789/vinta-awesome-python-algorithm', 'size': '1772'}