Beispiel #1
0
    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'])
Beispiel #2
0
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}
Beispiel #3
0
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}
Beispiel #4
0
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']
    }
Beispiel #5
0
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']
    }
Beispiel #6
0
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']
    }
Beispiel #7
0
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)
Beispiel #8
0
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)
Beispiel #9
0
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
Beispiel #10
0
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']
    }
Beispiel #11
0
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
    }
Beispiel #12
0
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
Beispiel #13
0
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']}
Beispiel #14
0
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()])
Beispiel #15
0
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'] }
Beispiel #16
0
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'] }
Beispiel #17
0
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}
Beispiel #18
0
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()])
Beispiel #19
0
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'] }
Beispiel #20
0
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']}
Beispiel #21
0
def _get_frame(uri_dict):
    from trustedanalytics import get_frame
    return get_frame(uri_dict['uri'])
Beispiel #22
0
def _get_frame(uri_dict):
    from trustedanalytics import get_frame
    return get_frame(uri_dict['uri'])
Beispiel #23
0
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'] }
Beispiel #24
0
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