How to use compose_feature method in lettuce-tools

Best Python code snippet using lettuce-tools_python

mvFeatureExtractor.py

Source:mvFeatureExtractor.py Github

copy

Full Screen

...22 elif (chart['chart_type'] == 'scatter'):23 return [0,1,0,0,0]24 elif (chart['chart_type'] == 'area'):25 return [1,0,0,0,0]26def compose_feature(chart, mv_charts):27 def if_decompose(c1, c2):28 return all(i in c2 for i in c1) ## c1 in c229 mv_charts = [c for c in mv_charts if chart['indices'] != c['indices'] and chart['chart_type'] != c['chart_type']]30 return sum(1 for c in mv_charts if if_decompose(chart, c))31def complementary_feature(chart, mv_charts):32 def if_complementary(pair):33 return len(set(itertools.chain(*pair))) == sum([len(x) for x in pair])34 mv_charts = [c for c in mv_charts if chart['indices'] != c['indices'] and chart['chart_type'] != c['chart_type']]35 combinations = [(chart, c) for c in mv_charts]36 return sum(1 for x in combinations if if_complementary(x))37def chart_to_feature(chart, mv_charts, all_charts_with_normed_score):38 chart_type_n_columns_feature = chart_type_feature(chart)39 score = [x for x in all_charts_with_normed_score if x['indices'] == chart['indices'] and x['chart_type'] == chart['chart_type']][0]['final_score']40 41 # # print(len(chart['indices']), chart_type_feature(chart), compose_feature(chart,mv_charts), 42 # # complementary_feature(chart,mv_charts), score)43 # print(chart)44 return [len(chart['indices']), *chart_type_feature(chart), compose_feature(chart,mv_charts), 45 complementary_feature(chart,mv_charts), score]46def charts_to_features_dl(mv_charts, all_charts_with_normed_score, seq_length = False):47 features = []48 for c in mv_charts:49 features.append(chart_to_feature(c, mv_charts, all_charts_with_normed_score))50 if seq_length != False:51 ## padding zero to match seq_length52 padding_zero = np.zeros((seq_length - len(features), len(features[0]))).tolist()53 features.extend(padding_zero)54 return features55def get_chart_lists(raw_lists):56 def get_chart(raw_chart):57 if raw_chart['markEncoding'] == 'arc':58 chart_type = 'pie'...

Full Screen

Full Screen

resampling.py

Source:resampling.py Github

copy

Full Screen

1import numpy as np2import pandas as pd3from data_process.ProcessedData import ProcessedData4class ResamplingData(ProcessedData):5 def __init__(self, raw_data):6 super().__init__(raw_data)7 self.rest_columns = raw_data.rest_columns8 def process(self):9 equal_zero_index = (self.label_df != 1).values10 equal_one_index = ~equal_zero_index11 pass_feature = np.array(self.feature_df[equal_zero_index])12 fail_feature = np.array(self.feature_df[equal_one_index])13 diff_num = len(pass_feature) - len(fail_feature)14 if diff_num < 1 or len(fail_feature) <= 0:15 return16 temp_array = np.zeros([diff_num, len(self.feature_df.values[0])])17 for i in range(diff_num):18 temp_array[i] = fail_feature[i % len(fail_feature)]19 features_np = np.array(self.feature_df)20 compose_feature = np.vstack((features_np, temp_array))21 label_np = np.array(self.label_df)22 gen_label = np.ones(diff_num).reshape((-1, 1))23 compose_label = np.vstack((label_np, gen_label))24 self.label_df = pd.DataFrame(compose_label, columns=['error'], dtype=float)25 self.feature_df = pd.DataFrame(compose_feature, columns=self.feature_df.columns, dtype=float)...

Full Screen

Full Screen

CLIP_model.py

Source:CLIP_model.py Github

copy

Full Screen

1import torch2import clip3import torch.nn as nn4class clip_model(nn.Module):5 def __init__(self, image_dim, text_dim):6 super().__init__()7 self.clip_model, _ = clip.load("ViT-B/32")8 # self.compose_linear = nn.Linear(image_dim+text_dim, image_dim)9 def forward(self, image, text):10 image_feature = self.clip_model.encode_image(image) # batch x 51211 text_feature = self.clip_model.encode_text(clip.tokenize(text).cuda()) # batch x 51212 compose_feature = torch.cat((image_feature, text_feature), dim=-1)13 # compose_feature = self.compose_linear(compose_feature)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lettuce-tools automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful