File size: 1,911 Bytes
93196f3
f63fff0
 
 
 
 
 
 
 
 
 
 
 
 
 
991eed9
 
 
 
 
c5595b8
 
 
 
 
 
 
 
 
dc609e2
 
 
 
c5595b8
daa5b98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from data_utils import *
import xarray as xr
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import pickle
import glob, os
import re
import tensorflow as tf
import netCDF4
import copy
import string
import h5py
from tqdm import tqdm
grid_info = xr.open_dataset('ClimSim_low-res_grid-info.nc')
input_mean = xr.open_dataset('input_mean.nc')
input_max = xr.open_dataset('input_max.nc')
input_min = xr.open_dataset('input_min.nc')
output_scale = xr.open_dataset('output_scale.nc')

data = data_utils(grid_info = grid_info,
                  input_mean = input_mean,
                  input_max = input_max,
                  input_min = input_min,
                  output_scale = output_scale)

data.set_to_v1_vars()

data.input_train = data.load_npy_file('train_input_small.npy')
data.target_train = data.load_npy_file('train_target_small.npy')
data.input_val = data.load_npy_file('val_input_small.npy')
data.target_val = data.load_npy_file('val_target_small.npy')


const_model = data.target_train.mean(axis = 0)
X = data.input_train
bias_vector = np.ones((X.shape[0], 1))
X = np.concatenate((X, bias_vector), axis=1)
mlr_weights = np.linalg.inv(X.transpose()@X)@X.transpose()@data.target_train
data.set_pressure_grid(data_split = 'val')

const_pred_val = np.repeat(const_model[np.newaxis, :], data.target_val.shape[0], axis = 0)
print(const_pred_val.shape)

# Multiple Linear Regression
X_val = data.input_val
bias_vector_val = np.ones((X_val.shape[0], 1))
X_val = np.concatenate((X_val, bias_vector_val), axis=1)
mlr_pred_val = X_val@mlr_weights
print(mlr_pred_val.shape)

# Load your prediction here

# Load predictions into data_utils object
data.model_names = ['const', 'mlr'] # add names of your models here
preds = [const_pred_val, mlr_pred_val] # add your custom predictions here
data.preds_val = dict(zip(data.model_names, preds))

st.markdown('Streamlit c')