-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_rangers_iit_dharwad_ai_cure_experiment.py
60 lines (42 loc) · 1.47 KB
/
data_rangers_iit_dharwad_ai_cure_experiment.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
53
54
55
56
57
58
59
# -*- coding: utf-8 -*-
"""Data Rangers_IIT Dharwad AI Cure_Experiment
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1AlD5Vcep054MiUWVJaZi4KH6eSpV-Qci
"""
# Import libraries
import pandas as pd
import numpy as np
# Load files
train = pd.read_csv("./train_data.csv")
test = pd.read_csv("./sample_test_data.csv")
Sample_Output = pd.read_csv("./sample_output_generated.csv")
train
test
Sample_Output
train.drop(['uuid'], axis=1, inplace=True)
test.drop(['uuid'], axis=1, inplace=True)
from sklearn.preprocessing import LabelEncoder
label_encoder = LabelEncoder()
train['condition'] = label_encoder.fit_transform(train['condition'])
test['condition'] = label_encoder.transform(test['condition'])
columns = train.columns
columns = [col for col in columns if col not in ['HR']]
features = columns
target = 'HR'
X = train[columns]
y = train[target]
from sklearn.model_selection import train_test_split
X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.1, random_state=40)
import lightgbm as lgb
import xgboost as xgb
model = lgb.LGBMRegressor()
model.fit(X, y)
y_pred_val =model.predict(test)
import sklearn.metrics
mse = sklearn.metrics.mean_squared_error(Sample_Output['HR'], y_pred_val)
import math
rmse = math.sqrt(mse)
print("The difference between actual and predicted values(MSE)", mse)
print("The difference between actual and predicted values(RMSE)", rmse)
test.to_csv("./result.csv",index=False)