def __init__(self, json_result): from trustedanalytics import get_frame self.num_features = json_result['num_features'] self.num_classes = json_result['num_classes'] self.covariance_matrix = None if pandas_available: self.summary_table = pd.DataFrame(data=json_result['coefficients'].values(), columns=['coefficients'], index=json_result['coefficients'].keys()) self.summary_table['degrees_freedom'] = pd.Series(data=json_result['degrees_freedom'].values(), index=json_result['degrees_freedom'].keys()) if json_result.get('covariance_matrix', None) is not None: self.summary_table['standard_errors'] = pd.Series(data=json_result['standard_errors'].values(), index=json_result['standard_errors'].keys()) self.summary_table['wald_statistic'] = pd.Series(data=json_result['wald_statistic'].values(), index=json_result['wald_statistic'].keys()) self.summary_table['p_value'] = pd.Series(data=json_result['p_value'].values(), index=json_result['p_value'].keys()) self.covariance_matrix = get_frame(json_result['covariance_matrix']['uri']) else: self.summary_table = { 'coefficients': json_result['coefficients'], 'degrees_freedom': json_result['degrees_freedom'] } if json_result.get('covariance_matrix', None) is not None: self.summary_table['standard_errors'] = json_result['standard_errors'] self.summary_table['wald_statistic'] = json_result['wald_statistic'] self.summary_table['p_value'] = json_result['p_value'] self.summary_table['covariance_matrix'] = get_frame(json_result['covariance_matrix']['uri'])
def return_page_rank(json_result): from trustedanalytics import get_frame vertex_json = json_result["vertex_dictionary_output"] edge_json = json_result["edge_dictionary_output"] vertex_dictionary = dict([(k,get_frame(v["uri"])) for k,v in vertex_json.items()]) edge_dictionary = dict([(k,get_frame(v["uri"])) for k,v in edge_json.items()]) return {'vertex_dictionary': vertex_dictionary, 'edge_dictionary': edge_dictionary}
def return_collaborative_filtering(json_result): from trustedanalytics import get_frame user_frame = get_frame(json_result['user_frame']['uri']) item_frame = get_frame(json_result['item_frame']['uri']) return { 'user_frame': user_frame, 'item_frame': item_frame, 'report': json_result['report'] }
def return_lda_train(selfish, json_result): from trustedanalytics import get_frame doc_frame = get_frame(json_result['doc_results']['id']) word_frame = get_frame(json_result['word_results']['id']) return { 'doc_results': doc_frame, 'word_results': word_frame, 'report': json_result['report'] }
def return_lda_train(json_result): from trustedanalytics import get_frame doc_frame = get_frame(json_result['topics_given_doc']['uri']) word_frame = get_frame(json_result['word_given_topics']['uri']) topic_frame = get_frame(json_result['topics_given_word']['uri']) return { 'topics_given_doc': doc_frame, 'word_given_topics': word_frame, 'topics_given_word': topic_frame, 'report': json_result['report'] }
def return_clustering_coefficient(json_result): from trustedanalytics import get_frame from trustedanalytics.core.clusteringcoefficient import ClusteringCoefficient if json_result.has_key('frame'): frame = get_frame(json_result['frame']['uri']) else: frame = None return ClusteringCoefficient(json_result['global_clustering_coefficient'], frame)
def return_principal_components_predict(selfish, json_result): from trustedanalytics import get_frame train_output = { 'output_frame': get_frame(json_result['output_frame']['id']) } if json_result.get('t_squared_index', None) is not None: train_output['t_squared_index'] = json_result['t_squared_index'] return train_output
def return_loopy_belief_propagation(json_result): from trustedanalytics import get_frame vertex_json = json_result['frame_dictionary_output'] vertex_dictionary = dict([(k, get_frame(v["uri"])) for k, v in vertex_json.items()]) return { 'vertex_dictionary': vertex_dictionary, 'time': json_result['time'] }
def return_power_iteration_clustering_predict(json_result): from trustedanalytics import get_frame predicted_frame = get_frame(json_result['frame']['uri']) number_of_clusters = json_result['k'] cluster_size = json_result['cluster_size'] return { 'predicted_frame': predicted_frame, 'number_of_clusters': number_of_clusters, 'cluster_size': cluster_size }
def get_frame(name): global frame if mode is None or mode == 'local': print('Warning: Not connected to ATK') return if not frame is None: return frame frames = tap.get_frame_names() if name in frames: return tap.get_frame(name) frame = tap.Frame(tap.UploadRows([], schema)) frame.name = name return frame
def return_loopy_belief_propagation(json_result): from trustedanalytics import get_frame vertex_json = json_result['frame_dictionary_output'] vertex_dictionary = dict([(k,get_frame(v["uri"])) for k,v in vertex_json.items()]) return {'vertex_dictionary': vertex_dictionary, 'time': json_result['time']}
def return_connected_components(json_result): from trustedanalytics import get_frame dictionary = json_result["frame_dictionary_output"] return dict([(k,get_frame(v["uri"])) for k,v in dictionary.items()])
def return_collaborative_filtering(json_result): from trustedanalytics import get_frame user_frame = get_frame(json_result['user_frame']['uri']) item_frame= get_frame(json_result['item_frame']['uri']) return { 'user_frame': user_frame, 'item_frame': item_frame, 'report': json_result['report'] }
def return_label_propagation(json_result): from trustedanalytics import get_frame frame = get_frame(json_result['output_frame']['uri']) return { 'frame': frame, 'report': json_result['report'] }
def return_power_iteration_clustering_predict(json_result): from trustedanalytics import get_frame predicted_frame = get_frame(json_result['frame']['uri']) number_of_clusters = json_result['k'] cluster_size = json_result['cluster_size'] return {'predicted_frame': predicted_frame , 'number_of_clusters': number_of_clusters, 'cluster_size': cluster_size}
def return_loopy_belief_propagation(json_result): from trustedanalytics import get_frame frame = get_frame(json_result['output_frame']['uri']) return { 'frame': frame, 'report': json_result['report'] }
def return_label_propagation(selfish, json_result): from trustedanalytics import get_frame frame = get_frame(json_result['output_frame']['id']) return {'frame': frame, 'report': json_result['report']}
def _get_frame(uri_dict): from trustedanalytics import get_frame return get_frame(uri_dict['uri'])
def return_giraph_lda_train(json_result): from trustedanalytics import get_frame doc_frame = get_frame(json_result['topics_given_doc']['uri']) word_frame= get_frame(json_result['word_given_topics']['uri']) topic_frame= get_frame(json_result['topics_given_word']['uri']) return { 'topics_given_doc': doc_frame, 'word_given_topics': word_frame, 'topics_given_word': topic_frame, 'report': json_result['report'] }
def return_principal_components_predict(json_result): from trustedanalytics import get_frame train_output = {'output_frame': get_frame(json_result['output_frame']['uri']) } if json_result.get('t_squared_index', None) is not None: train_output['t_squared_index'] = json_result['t_squared_index'] return train_output