-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathThunderstorm Prediction.py
147 lines (62 loc) · 1.54 KB
/
Thunderstorm Prediction.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
get_ipython().run_line_magic('matplotlib', 'inline')
# In[2]:
bankdata = pd.read_csv(r"img_pixels.csv", header= None)
# In[3]:
bankdata.head()
# In[4]:
df= pd.read_csv(r"data.csv", header= None)
col= ['Temp', 'Prec', 'Dew', 'Air', 'pres','class']
df.columns=col
df.head()
# In[5]:
df.head()
# In[6]:
new_df = pd.concat([df,bankdata], axis = 1)
# In[7]:
new_df
# In[8]:
x=new_df.drop('class',axis=1)
y= new_df['class']
# In[9]:
from sklearn.preprocessing import LabelEncoder
from sklearn import preprocessing
le=preprocessing.LabelEncoder()
le.fit(y)
LabelEncoder()
le.classes_
y=le.transform(y)
# In[10]:
from sklearn.model_selection import train_test_split
# Create training and test sets
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.30, random_state=42, stratify = y)
# In[11]:
print(y_test)
# In[13]:
from sklearn.svm import SVC
clf = SVC()
clf.fit(x_train, y_train)
# In[14]:
# In[15]:
y_pred = clf.predict(x_test)
# In[16]:
from sklearn.metrics import classification_report
from sklearn.metrics import confusion_matrix
print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
# In[17]:
clf.score(x_test, y_test)
# In[18]:
from sklearn.svm import SVC
svclassifier = SVC(kernel='linear')
svclassifier.fit(x_train, y_train)
# In[19]:
y_pred = svclassifier.predict(x_test)
# In[ ]:
# In[ ]:
# In[ ]: