-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyzer.py
62 lines (40 loc) · 2.02 KB
/
analyzer.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
#The analyzer
import pandas as pd
import numpy
import datetime
from sklearn.feature_selection import RFECV
from sklearn.svm import SVR
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import StandardScaler
beau_df_meteo = pd.read_csv("dataset/beaufort99-01.csv", ';')
cacana_df_meteo = pd.read_csv("dataset/cacana99-01.csv",";")
cafram_df_meteo = pd.read_csv("dataset/cafram99-01.csv",";")
esiber_df_meteo = pd.read_csv("dataset/esiber99-01.csv",";")
beau_df_meteo.validdate = beau_df_meteo.validdate.str.slice(stop=10)
cacana_df_meteo.validdate = cacana_df_meteo.validdate.str.slice(stop=10)
cafram_df_meteo.validdate = cafram_df_meteo.validdate.str.slice(stop=10)
esiber_df_meteo.validdate = esiber_df_meteo.validdate.str.slice(stop=10)
df2 = pd.read_csv("dataset/ImageSummariesOriginal.csv")
beaufoDFocean = df2[df2.site == 'beaufo']
cacanaDFocean = df2[df2.site == 'cacana']
caframDFocean = df2[df2.site == 'cafram']
esiberDFocean = df2[df2.site == 'esiber']
dfBeaufortFinal = beau_df_meteo.set_index('validdate').join(beaufoDFocean.set_index('date'))
dfCacanaFinal = cacana_df_meteo.set_index('validdate').join(cacanaDFocean.set_index('date'))
dfCaframFinal = cafram_df_meteo.set_index('validdate').join(caframDFocean.set_index('date'))
dfEsiberFinal = esiber_df_meteo.set_index('validdate').join(esiberDFocean.set_index('date'))
dfUltimate = dfBeaufortFinal.append(dfCacanaFinal.append(dfCaframFinal.append(dfEsiberFinal)))
dfUltimate = dfUltimate.drop(columns=["All Water","Open Water","Ice","site","Unnamed: 0"])
dfUltimate = dfUltimate.dropna()
print(dfUltimate)
abetterdf = pd.read_csv("dataset/Matched Data.csv")
abetterdf = abetterdf.drop(columns=["Unnamed: 0", "site", "date","Ice", "Pond", "wind","temp","hum","rad","agg_thirty_hum","agg_thirty_rad","agg_thirty_wind","agg_thirty_temp"])
print(abetterdf.head(20))
values = abetterdf.values
X = values[:, [0,1,2,3,5]]
y = values[:,4]
print("Linear reg:")
reg = LinearRegression().fit(X, y)
print(reg.score(X, y))
print(reg.coef_)
print(reg.intercept_)