Delete silverchairpredictin_159.py
Browse files- silverchairpredictin_159.py +0 -62
silverchairpredictin_159.py
DELETED
@@ -1,62 +0,0 @@
|
|
1 |
-
# -*- coding: utf-8 -*-
|
2 |
-
"""silverChairpredictin.159
|
3 |
-
|
4 |
-
Automatically generated by Colab.
|
5 |
-
|
6 |
-
Original file is located at
|
7 |
-
https://colab.research.google.com/drive/1oUsaV8V9oOXQWEeYS_uQYUu3WuVk21rP
|
8 |
-
"""
|
9 |
-
|
10 |
-
import warnings
|
11 |
-
warnings.filterwarnings('ignore')
|
12 |
-
|
13 |
-
import numpy as np
|
14 |
-
import pandas as pd
|
15 |
-
import matplotlib.pyplot as plt
|
16 |
-
import seaborn as sns
|
17 |
-
|
18 |
-
file_path = 'customer_purchase_data.csv'
|
19 |
-
df = pd.read_csv(file_path)
|
20 |
-
|
21 |
-
df.head()
|
22 |
-
|
23 |
-
df.info()
|
24 |
-
|
25 |
-
df.describe()
|
26 |
-
|
27 |
-
plt.figure(figsize=(10,6))
|
28 |
-
sns.histplot(df['Age'], kde=True, bins=30)
|
29 |
-
plt.title('Distribution of Age')
|
30 |
-
plt.xlabel('Age')
|
31 |
-
plt.ylabel('Frequency')
|
32 |
-
plt.show()
|
33 |
-
|
34 |
-
plt.figure(figsize=(10, 6))
|
35 |
-
sns.histplot(df['AnnualIncome'], kde=True, bins=30)
|
36 |
-
plt.title('Distribution of Annual Income')
|
37 |
-
plt.xlabel('Annual Income')
|
38 |
-
plt.ylabel('Frequency')
|
39 |
-
plt.show
|
40 |
-
|
41 |
-
numeric_df = df.select_dtypes(include=[np.number])
|
42 |
-
plt.figure(figsize=(12, 8))
|
43 |
-
sns.heatmap(numeric_df.corr(), annot=True, cmap='coolwarm', fmt='.2f')
|
44 |
-
plt.title('Correlation Heatmap')
|
45 |
-
plt.show()
|
46 |
-
|
47 |
-
from sklearn.model_selection import train_test_split
|
48 |
-
from sklearn.ensemble import RandomForestClassifier
|
49 |
-
from sklearn.metrics import classification_report, confusion_matrix
|
50 |
-
|
51 |
-
X = df.drop('PurchaseStatus', axis=1)
|
52 |
-
y = df['PurchaseStatus']
|
53 |
-
|
54 |
-
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
|
55 |
-
|
56 |
-
model = RandomForestClassifier(random_state=42)
|
57 |
-
model.fit(X_train, y_train)
|
58 |
-
|
59 |
-
y_pred = model.predict(X_test)
|
60 |
-
|
61 |
-
print(confusion_matrix(y_test, y_pred))
|
62 |
-
print(classification_report(y_test, y_pred))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|