MelroyCaeiro / PD-Denoising-using-Optimized-Wavelet

Partial Discharge Denoising Using Optimized Wavelet
GNU Affero General Public License v3.0
10 stars 0 forks source link

Issues in NSGA2 python file. #1

Open Saumil27 opened 1 year ago

Saumil27 commented 1 year ago

while executing the above file observed the below error. ValueError: Found input variables with inconsistent numbers of samples: [5, 4000]

is this due to clean file.txt not available or I missed something in my code?

can you please help me with this?

full error mentioned below, ValueError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_7076\3079603772.py in 61 62 # Optimization initialization ---> 63 res = minimize(problem=problem, 64 algorithm=algorithm, 65 termination=stop_criteria,

~\anaconda3\lib\site-packages\pymoo\optimize.py in minimize(problem, algorithm, termination, copy_algorithm, copy_termination, **kwargs) 65 66 # actually execute the algorithm ---> 67 res = algorithm.run() 68 69 # store the deep copied algorithm in the result object

~\anaconda3\lib\site-packages\pymoo\core\algorithm.py in run(self) 139 def run(self): 140 while self.has_next(): --> 141 self.next() 142 return self.result() 143

~\anaconda3\lib\site-packages\pymoo\core\algorithm.py in next(self) 159 # call the advance with them after evaluation 160 if infills is not None: --> 161 self.evaluator.eval(self.problem, infills, algorithm=self) 162 self.advance(infills=infills) 163

~\anaconda3\lib\site-packages\pymoo\core\evaluator.py in eval(self, problem, pop, skip_already_evaluated, evaluate_values_of, count_evals, kwargs) 67 68 # do the actual evaluation - call the sub-function to set the corresponding values to the population ---> 69 self._eval(problem, pop[I], evaluate_values_of, kwargs) 70 71 # update the function evaluation counter

~\anaconda3\lib\site-packages\pymoo\core\evaluator.py in _eval(self, problem, pop, evaluate_values_of, kwargs) 88 89 # call the problem to evaluate the solutions ---> 90 out = problem.evaluate(X, return_values_of=evaluate_values_of, return_as_dictionary=True, kwargs) 91 92 # for each of the attributes set it to the problem

~\anaconda3\lib\site-packages\pymoo\core\problem.py in evaluate(self, X, return_values_of, return_as_dictionary, *args, *kwargs) 185 186 # this is where the actual evaluation takes place --> 187 _out = self.do(X, return_values_of, args, **kwargs) 188 189 out = {}

~\anaconda3\lib\site-packages\pymoo\core\problem.py in do(self, X, return_values_of, *args, kwargs) 225 # do the function evaluation 226 if self.elementwise: --> 227 self._evaluate_elementwise(X, out, *args, *kwargs) 228 else: 229 self._evaluate_vectorized(X, out, args, kwargs)

~\anaconda3\lib\site-packages\pymoo\core\problem.py in _evaluate_elementwise(self, X, out, *args, **kwargs) 243 244 # execute the runner --> 245 elems = self.elementwise_runner(f, X) 246 247 # for each evaluation call

~\anaconda3\lib\site-packages\pymoo\core\problem.py in call(self, f, X) 25 26 def call(self, f, X): ---> 27 return [f(x) for x in X] 28 29

~\anaconda3\lib\site-packages\pymoo\core\problem.py in (.0) 25 26 def call(self, f, X): ---> 27 return [f(x) for x in X] 28 29

~\anaconda3\lib\site-packages\pymoo\core\problem.py in call(self, x) 18 def call(self, x): 19 out = dict() ---> 20 self.problem._evaluate(x, out, *self.args, **self.kwargs) 21 return out 22

~\AppData\Local\Temp\ipykernel_7076\3079603772.py in _evaluate(self, x, out, *args, **kwargs) 32 33 f1 = SNR(clean_signal_upsampled, denoising) ---> 34 f2 = MSE(clean_signal_upsampled, denoising) 35 f3 = CC(clean_signal_upsampled, denoising) 36

~\AppData\Local\Temp\ipykernel_7076\1803469571.py in MSE(clean, noisy) 14 As such, we intend to optimize this closest to 0 [minimization] 15 """ ---> 16 return (mean_squared_error(clean, noisy)) 17 18 def SNR(clean, noisy):

~\anaconda3\lib\site-packages\sklearn\metrics_regression.py in mean_squared_error(y_true, y_pred, sample_weight, multioutput, squared) 436 0.825... 437 """ --> 438 y_type, y_true, y_pred, multioutput = _check_reg_targets( 439 y_true, y_pred, multioutput 440 )

~\anaconda3\lib\site-packages\sklearn\metrics_regression.py in _check_reg_targets(y_true, y_pred, multioutput, dtype) 92 the dtype argument passed to check_array. 93 """ ---> 94 check_consistent_length(y_true, y_pred) 95 y_true = check_array(y_true, ensure_2d=False, dtype=dtype) 96 y_pred = check_array(y_pred, ensure_2d=False, dtype=dtype)

~\anaconda3\lib\site-packages\sklearn\utils\validation.py in check_consistent_length(*arrays) 330 uniques = np.unique(lengths) 331 if len(uniques) > 1: --> 332 raise ValueError( 333 "Found input variables with inconsistent numbers of samples: %r" 334 % [int(l) for l in lengths]

ValueError: Found input variables with inconsistent numbers of samples: [5, 4000]

yangyuqing15715165798 commented 4 months ago

while executing the above file observed the below error. ValueError: Found input variables with inconsistent numbers of samples: [5, 4000]

is this due to clean file.txt not available or I missed something in my code?

can you please help me with this?

full error mentioned below, ValueError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_7076\3079603772.py in 61 62 # Optimization initialization ---> 63 res = minimize(problem=problem, 64 algorithm=algorithm, 65 termination=stop_criteria,

~\anaconda3\lib\site-packages\pymoo\optimize.py in minimize(problem, algorithm, termination, copy_algorithm, copy_termination, **kwargs) 65 66 # actually execute the algorithm ---> 67 res = algorithm.run() 68 69 # store the deep copied algorithm in the result object

~\anaconda3\lib\site-packages\pymoo\core\algorithm.py in run(self) 139 def run(self): 140 while self.has_next(): --> 141 self.next() 142 return self.result() 143

~\anaconda3\lib\site-packages\pymoo\core\algorithm.py in next(self) 159 # call the advance with them after evaluation 160 if infills is not None: --> 161 self.evaluator.eval(self.problem, infills, algorithm=self) 162 self.advance(infills=infills) 163

~\anaconda3\lib\site-packages\pymoo\core\evaluator.py in eval(self, problem, pop, skip_already_evaluated, evaluate_values_of, count_evals, kwargs) 67 68 # do the actual evaluation - call the sub-function to set the corresponding values to the population ---> 69 self._eval(problem, pop[I], evaluate_values_of, kwargs) 70 71 # update the function evaluation counter

~\anaconda3\lib\site-packages\pymoo\core\evaluator.py in _eval(self, problem, pop, evaluate_values_of, kwargs) 88 89 # call the problem to evaluate the solutions ---> 90 out = problem.evaluate(X, return_values_of=evaluate_values_of, return_as_dictionary=True, kwargs) 91 92 # for each of the attributes set it to the problem

~\anaconda3\lib\site-packages\pymoo\core\problem.py in evaluate(self, X, return_values_of, return_as_dictionary, *args, *kwargs) 185 186 # this is where the actual evaluation takes place --> 187 _out = self.do(X, return_values_of, args, **kwargs) 188 189 out = {}

~\anaconda3\lib\site-packages\pymoo\core\problem.py in do(self, X, return_values_of, *args, kwargs) 225 # do the function evaluation 226 if self.elementwise: --> 227 self._evaluate_elementwise(X, out, *args, *kwargs) 228 else: 229 self._evaluate_vectorized(X, out, args, kwargs)

~\anaconda3\lib\site-packages\pymoo\core\problem.py in _evaluate_elementwise(self, X, out, *args, **kwargs) 243 244 # execute the runner --> 245 elems = self.elementwise_runner(f, X) 246 247 # for each evaluation call

~\anaconda3\lib\site-packages\pymoo\core\problem.py in call(self, f, X) 25 26 def call(self, f, X): ---> 27 return [f(x) for x in X] 28 29

~\anaconda3\lib\site-packages\pymoo\core\problem.py in (.0) 25 26 def call(self, f, X): ---> 27 return [f(x) for x in X] 28 29

~\anaconda3\lib\site-packages\pymoo\core\problem.py in call(self, x) 18 def call(self, x): 19 out = dict() ---> 20 self.problem._evaluate(x, out, *self.args, **self.kwargs) 21 return out 22

~\AppData\Local\Temp\ipykernel_7076\3079603772.py in _evaluate(self, x, out, *args, **kwargs) 32 33 f1 = SNR(clean_signal_upsampled, denoising) ---> 34 f2 = MSE(clean_signal_upsampled, denoising) 35 f3 = CC(clean_signal_upsampled, denoising) 36

~\AppData\Local\Temp\ipykernel_7076\1803469571.py in MSE(clean, noisy) 14 As such, we intend to optimize this closest to 0 [minimization] 15 """ ---> 16 return (mean_squared_error(clean, noisy)) 17 18 def SNR(clean, noisy):

~\anaconda3\lib\site-packages\sklearn\metrics_regression.py in mean_squared_error(y_true, y_pred, sample_weight, multioutput, squared) 436 0.825... 437 """ --> 438 y_type, y_true, y_pred, multioutput = _check_reg_targets( 439 y_true, y_pred, multioutput 440 )

~\anaconda3\lib\site-packages\sklearn\metrics_regression.py in _check_reg_targets(y_true, y_pred, multioutput, dtype) 92 the dtype argument passed to check_array. 93 """ ---> 94 check_consistent_length(y_true, y_pred) 95 y_true = check_array(y_true, ensure_2d=False, dtype=dtype) 96 y_pred = check_array(y_pred, ensure_2d=False, dtype=dtype)

~\anaconda3\lib\site-packages\sklearn\utils\validation.py in check_consistent_length(*arrays) 330 uniques = np.unique(lengths) 331 if len(uniques) > 1: --> 332 raise ValueError( 333 "Found input variables with inconsistent numbers of samples: %r" 334 % [int(l) for l in lengths]

ValueError: Found input variables with inconsistent numbers of samples: [5, 4000]

数据集似乎不全