sciml 0.0.4__tar.gz → 0.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sciml
3
- Version: 0.0.4
3
+ Version: 0.0.6
4
4
  Summary: draw and basic calculations/conversions
5
5
  Home-page: https://github.com/soonyenju/sciml
6
6
  Author: Songyan Zhu
@@ -11,4 +11,3 @@ Platform: any
11
11
  License-File: LICENSE
12
12
 
13
13
  coming soon
14
-
@@ -1,8 +1,12 @@
1
1
  import numpy as np
2
+ import pandas as pd
2
3
  from scipy import stats
3
4
  from sklearn.metrics import mean_squared_error
4
5
 
5
6
  def get_metrics(df, truth = 'truth', pred = 'pred', return_dict = False):
7
+ '''
8
+ Calculate statistical measures between validation and prediction sequences
9
+ '''
6
10
  df = df[[truth, pred]].copy().dropna()
7
11
  slope, intercept, r_value, p_value, std_err = stats.linregress(df.dropna()[truth], df.dropna()[pred])
8
12
  r2 = r_value**2
@@ -11,7 +15,7 @@ def get_metrics(df, truth = 'truth', pred = 'pred', return_dict = False):
11
15
  mbe = np.mean(df.dropna()[pred] - df.dropna()[truth])
12
16
  mae = (df.dropna()[pred] - df.dropna()[truth]).abs().mean()
13
17
  if return_dict:
14
- return {
18
+ return pd.DataFrame.from_dict([{
15
19
  'R2': r2,
16
20
  'Slope': slope,
17
21
  'RMSE': rmse,
@@ -20,7 +24,7 @@ def get_metrics(df, truth = 'truth', pred = 'pred', return_dict = False):
20
24
  'Intercept': intercept,
21
25
  'p-value': p_value,
22
26
  'std_err': std_err
23
- }
27
+ }])
24
28
  else:
25
29
  return r2, slope, rmse, mbe, mae, intercept, p_value, std_err
26
30
 
@@ -108,19 +112,22 @@ def train_ml(
108
112
 
109
113
  def test_ml(X_test, y_test, regr):
110
114
  res = y_test.copy() # y_test is 2D pandas dataframe.
111
- res.columns = ['true']
115
+ res.columns = ['truth']
112
116
  res['pred'] = regr.predict(X_test)
113
117
  return res
114
118
 
115
119
  # ===============================================================================================================================
116
120
  # Deep learning neural networks
117
121
 
118
- from tensorflow import keras
119
- from tensorflow.keras import layers
120
- from tensorflow.keras import models
121
- # from keras.layers import Dropout
122
- from keras.callbacks import EarlyStopping
123
- from scitbx.stutils import *
122
+ try:
123
+ from tensorflow import keras
124
+ from tensorflow.keras import layers
125
+ from tensorflow.keras import models
126
+ # from keras.layers import Dropout
127
+ from keras.callbacks import EarlyStopping
128
+ from scitbx.stutils import *
129
+ except Exception as e:
130
+ print(e)
124
131
 
125
132
  def train_lstm(X_train, y_train, nfeature, ntime, verbose = 2, epochs = 200, batch_size = 64):
126
133
  # create and fit the LSTM network
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sciml
3
- Version: 0.0.4
3
+ Version: 0.0.6
4
4
  Summary: draw and basic calculations/conversions
5
5
  Home-page: https://github.com/soonyenju/sciml
6
6
  Author: Songyan Zhu
@@ -11,4 +11,3 @@ Platform: any
11
11
  License-File: LICENSE
12
12
 
13
13
  coming soon
14
-
@@ -13,7 +13,7 @@ from setuptools import setup, find_packages
13
13
 
14
14
  setup(
15
15
  name = "sciml",
16
- version = "0.0.4",
16
+ version = "0.0.6",
17
17
  keywords = ("Scientific machine learning wrappers"),
18
18
  description = "draw and basic calculations/conversions",
19
19
  long_description = "coming soon",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes