-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0ff318
commit a20b921
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pandas as pd | ||
import numpy as np | ||
import numpy as np | ||
from sklearn.model_selection import train_test_split | ||
from sklearn.ensemble import RandomForestClassifier | ||
|
||
data = pd.read_csv("train") #train is location of training data | ||
data = data.dropna(axis='columns', thresh = int(0.5 * len(data))) | ||
data.fillna(data.mean()) | ||
col = data.columns | ||
X = data[col[1:]] | ||
y = data['LABEL'] | ||
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3) | ||
|
||
# Create the model with 100 trees | ||
model = model = RandomForestClassifier(n_estimators=100, | ||
bootstrap = True, | ||
max_features = 'sqrt') | ||
# Fit on training data | ||
model.fit(X_train, y_train) | ||
print(f'Model Accuracy: {model.score(X_test, y_test)}') |