forked from dmaciel123/Secchi_Disk_Landsat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
02_MDN OLI Complete.py
62 lines (39 loc) · 1.51 KB
/
02_MDN OLI Complete.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
# -*- coding: utf-8 -*-
"""
@author: Daniel Maciel
This script will train the MDN to Landsat data. It was aplpying for all data in the .CSV file but it will be filtered after that.
"""
from MDN.parameters import get_args
from MDN.utils import split_data
from MDN import get_sensor_bands
from MDN.product_estimation import get_estimates
import pandas as pd
import matplotlib.pyplot as plt
import MDN.plot_utils
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_absolute_error, mean_squared_error, mean_absolute_percentage_error
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error
import math
import random
import tensorflow as tf
import math
#Data for model creation
dataset = pd.read_csv(r"Data/Simulated Dataset/rrs_sim_OLI_v3.csv", sep = ',')
#Validation datase
BANDS = ('blue', 'green', 'red')
dataset.rename(columns = {'B1':'coastal', "B2":'blue', "B3":'green', "B4":'red', "B5":'nir'}, inplace = True)
X_train = dataset.loc[:,BANDS]
print(X_train, 'Train Data')
#Select only secchi for train Y
y_train = dataset[['secchi']]
print(y_train, 'Secchi Train Data')
#Generate the MDN model
args = get_args(no_load=False,sensor='OLI-NoCoastal',product='secchi-Maciel',
n_rounds = 10,
benchmark=False,
use_ratio = True)
#Saving the MDN model
tf.random.set_seed(1)
get_estimates(args, X_train, y_train)