-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRF.py
26 lines (21 loc) · 778 Bytes
/
RF.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 2 15:37:35 2019
@author: mmrra
"""
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
train = pd.read_csv("F:\MachineLearning\Datasets\Titanic/trainpp.csv")
test = pd.read_csv("F:\MachineLearning\Datasets\Titanic/testpp.csv")
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import KFold
from sklearn.model_selection import cross_val_score
k_fold = KFold(n_splits = 10, shuffle=True, random_state=0)
clf=RandomForestClassifier(n_estimators = 13)
scoring = 'accuracy'
score = cross_val_score(clf, train_data, target, cv=k_fold, n_jobs=1, scoring=scoring)
print(score)
print(round(np.mean(score)*100, 2))