Best Python code snippet using slash
variation_factory.py
Source:variation_factory.py
...82 if not needed_ids:83 yield Variation(self._store, {}, {})84 return85 for value_indices in itertools.product(*(range(len(p.values)) for p in parametrizations)):86 yield self._build_variation(parametrizations, value_indices)87 def _build_variation(self, parametrizations, value_indices):88 value_index_by_id = {}89 for param, param_index in zip(parametrizations, value_indices):90 value_index_by_id[param.info.id] = param_index...
FeatureImportance.py
Source:FeatureImportance.py
...35 else:36 minimum, maximum = column_data.min(), column_data.max()37 column_variants = numpy.arange(minimum, maximum, (maximum - minimum) / 100)38 return column_variants39 def _build_variation(self, column_name, variants, median_values):40 variations = []41 for variant in variants:42 variation_dict = {**median_values}43 variation_dict[column_name] = variant44 variations.append(variation_dict)45 return variations46 def _build_tensor(self, inputs):47 tensor = {48 key: convert_to_tensor([input[key] for input in inputs])49 for key in inputs[0]50 }51 return tensor52 def _continous_target_impact(self, model_output):53 return float(max(model_output) - min(model_output))54 def _discrete_target_impact(self, model_output):55 df = DataFrame(model_output)56 impact = (df.max() - df.min()).sum()57 return float(impact)58 def _get_field_importance(self, res):59 impact = (60 self._discrete_target_impact(res)61 if self.problem_type == Coltype.DISCRETE62 else self._continous_target_impact(res)63 )64 return impact65 def extract(self, df: DataFrame):66 median_values = self._get_median(df)67 impacts = {}68 dataset_input_features = list(69 filter(70 lambda x: x.columnName != self.target_col, self.dataset.datasetFields71 )72 )73 input_counts = []74 agg_inputs = []75 for field in dataset_input_features:76 field: DatasetFeature = field77 column_variants = self._generate_variants(df[field.columnName], field)78 inputs = self._build_variation(79 field.columnName, column_variants, median_values80 )81 input_counts.append(len(inputs))82 agg_inputs.extend(inputs)83 tensor = self._build_tensor(agg_inputs)84 res = self.model.predict(tensor)85 start = 086 for idx, field in enumerate(dataset_input_features):87 field_res = res[start : start + input_counts[idx]]88 start = start + input_counts[idx]89 impacts[field.columnName] = float(self._get_field_importance(field_res))...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!