-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy_of_random_forest.py
53 lines (37 loc) · 1.12 KB
/
copy_of_random_forest.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# -*- coding: utf-8 -*-
"""Copy of random forest.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1SpSQQxepaL1XciF0Q5ZfbY6jYmJYWcYC
"""
from google.colab import files
uploaded = files.upload()
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
dataset = pd.read_csv('lol.csv')
dataset
X = dataset[['c_c_s',
'b_f_s_prcnt',
'f_a_prcnt',
's_plast_prcnt',
'w_c_r',
'co_agg_prcnt',
'fi_agg_prcnt']]
y = dataset[['cmnt','wtr','fi_agg_prcnt',
'co_agg']]
list(dataset.columns.values)
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y,test_size=0.2)
import matplotlib.pyplot as plt #Data visualisation libraries
import seaborn as sns
# %matplotlib inline
sns.pairplot(dataset)
from sklearn.ensemble import RandomForestRegressor
regressor = RandomForestRegressor(n_estimators = 300, random_state = 0)
regressor.fit(X,y)
regressor.fit(X_train,y_train)
pred=regressor.predict(X_test)
print(regressor.score(X_test,y_test))
from sklearn.metrics import r2_score
print(r2_score(y_test,pred))