Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an option for target normalization in SVR #1853

Open
wants to merge 17 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
adding target normalization for ROM that require normalization
  • Loading branch information
Jimmy-INL committed Apr 23, 2022
commit 33a4e530d77e730cb99603a5fb7f49dc045c213e
2 changes: 1 addition & 1 deletion framework/SupervisedLearning/ScikitLearn/SVM/LinearSVR.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Created on Jan 21, 2020

@author: alfoa, wangc
Linear Support Vector Classifier
Linear Support Vector Regressor

"""
#Internal Modules (Lazy Importer)--------------------------------------------------------------------
Expand Down
11 changes: 9 additions & 2 deletions framework/SupervisedLearning/SupervisedLearning.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,13 @@ def train(self, tdict, indexMap=None):
# valueToUse can be either a matrix (for who can handle time-dep data) or a vector (for who can not)
if self.dynamicFeatures:
featureValues[:, :, cnt] = (valueToUse[:, :]- self.muAndSigmaFeatures[feat][0])/self.muAndSigmaFeatures[feat][1]
# targetValues[:,cnt] = (targetValues[:]- self.muAndSigmaFeatures[self.target[0]][0])/self.muAndSigmaFeatures[self.target[0]][1]
else:
featureValues[:,cnt] = ( (valueToUse[:,0] if len(valueToUse.shape) > 1 else valueToUse[:]) - self.muAndSigmaFeatures[feat][0])/self.muAndSigmaFeatures[feat][1]

# targetValues[cnt] = ( (targetValues[0] if len(valueToUse.shape) > 1 else targetValues[:]) - self.muAndSigmaFeatures[self.target[0]][0])/self.muAndSigmaFeatures[self.target[0]][1]
# self.targetMean = np.mean(targetValues)
# self.targetStd = np.std(targetValues)
targetValues = (targetValues - self.muAndSigmaFeatures[self.target[0]][0])/self.muAndSigmaFeatures[self.target[0]][1]
self.__trainLocal__(featureValues,targetValues)
self.amITrained = True

Expand All @@ -280,6 +284,7 @@ def _localNormalizeData(self,values,names,feat):
@ Out, None
"""
self.muAndSigmaFeatures[feat] = mathUtils.normalizationFactors(values[names.index(feat)])
self.muAndSigmaFeatures[self.target[0]] = mathUtils.normalizationFactors(values[names.index(self.target[0])])

def confidence(self, edict):
"""
Expand Down Expand Up @@ -356,7 +361,9 @@ def evaluate(self,edict):
featureValues[:, :, cnt] = ((values[names.index(feat)] - self.muAndSigmaFeatures[feat][0]))/self.muAndSigmaFeatures[feat][1]
else:
featureValues[:,cnt] = ((values[names.index(feat)] - self.muAndSigmaFeatures[feat][0]))/self.muAndSigmaFeatures[feat][1]
return self.__evaluateLocal__(featureValues)
target = self.__evaluateLocal__(featureValues)
target.update((x, y * self.muAndSigmaFeatures[self.target[0]][1] + self.muAndSigmaFeatures[self.target[0]][0]) for x, y in target.items())
return target

def reset(self):
"""
Expand Down