Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 012df3e

Browse filesBrowse files
committed
new
1 parent 01a6ec5 commit 012df3e
Copy full SHA for 012df3e

File tree

Expand file treeCollapse file tree

6 files changed

+40
-0
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+40
-0
lines changed
Binary file not shown.
Binary file not shown.
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import pandas as pd
2+
import numpy as np
3+
from sklearn.model_selection import train_test_split
4+
from sklearn.preprocessing import LabelEncoder, StandardScaler
5+
6+
def preprocess_data(data):
7+
8+
data.fillna(method='ffill', inplace=True)
9+
10+
11+
data['Age_Tenure_Product'] = data['Age'] * data['Tenure'] * data['NumOfProducts']
12+
data['Balance'] = np.log1p(data['Balance'])
13+
14+
le = LabelEncoder()
15+
data['Geography'] = le.fit_transform(data['Geography'])
16+
data['Gender'] = le.fit_transform(data['Gender'])
17+
18+
19+
scaler = StandardScaler()
20+
data[['CreditScore', 'Age', 'Tenure', 'Balance', 'NumOfProducts', 'EstimatedSalary']] = scaler.fit_transform(data[['CreditScore', 'Age', 'Tenure', 'Balance', 'NumOfProducts', 'EstimatedSalary']])
21+
22+
23+
X = data.drop('Exited', axis=1)
24+
y = data['Exited']
25+
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
26+
27+
return X_train, X_test, y_train, y_test

‎Random_Forest_project/src/kuchbhi.py

Copy file name to clipboard
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import pandas as pd
2+
from datapreproc import preprocess_data
3+
from model_training import train_model
4+
from modelevelution import evaluate_model
5+
6+
7+
data = pd.read_csv('Churn_Modelling.csv')
8+
9+
X_train, X_test, y_train, y_test = preprocess_data(data)
10+
11+
model = train_model(X_train, y_train)
12+
13+
evaluate_model(model, X_test, y_test)

‎Random_Forest_project/src/model_training.py

Copy file name to clipboardExpand all lines: Random_Forest_project/src/model_training.py
Whitespace-only changes.

‎Random_Forest_project/src/modelevelution.py

Copy file name to clipboardExpand all lines: Random_Forest_project/src/modelevelution.py
Whitespace-only changes.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.