예제 #1
0
def check_kmeans_cluster_all_data(new_df):

    # print("working on: ", new_df.head().T)
    # new_df = pd.DataFrame([user_data_list], columns = col_list)

    # user_dataframe = pd.DataFrame.from_records((json_user_obj), index=[0])
    # new_df = user_dataframe[col_list].copy()

    processed_df = preprocessing_encoding.preprocess_data(new_df)
    if (str(processed_df) == '-1'):
        # print("RETURNING")
        return -1

    final_membership_values_all = get_membership(processed_df, 2)

    final_scaled_membership_values_all = get_levels.get_ind_levels(
        final_membership_values_all)

    distance_min, min_cluster_index = get_levels.apply_kmeans(
        final_scaled_membership_values_all)

    # print(get_output(json_user_obj,final_membership_values_all,final_scaled_membership_values_all,min_cluster_index))

    return get_output_all_data(new_df['Email Address'],
                               final_membership_values_all,
                               final_scaled_membership_values_all,
                               min_cluster_index)
예제 #2
0
def check_kmeans_cluster(user_data_json):

    # print("*******", user_data_json)
    user_data_json = user_data_json.replace("\"extensively\"", "extensively")
    json_user_obj = json.loads(user_data_json)

    # print(str(json_user_obj))
    #
    # json_user_obj['Have you been "extensively" involved in the following? [ML/AI Projects or Research]'] = json_user_obj.pop('Have you been extensively involved in the following? [ML/AI Projects or Research]')
    # json_user_obj['Have you been "extensively" involved in the following? [Social Activities (College Fest Organization or similar managerial or club activities)]'] = json_user_obj.pop('Have you been extensively involved in the following? [Social Activities (College Fest Organization or similar managerial or club activities)]')
    # json_user_obj['Have you been "extensively" involved in the following? [Literature/Blogging ]'] = json_user_obj.pop('Have you been extensively involved in the following? [Literature/Blogging ]')
    # json_user_obj['Have you been "extensively" involved in the following? [Competitive Coding]'] = json_user_obj.pop('Have you been extensively involved in the following? [Competitive Coding]')
    # json_user_obj['Have you been "extensively" involved in the following? [Mathematics and Logical Reasoning]'] = json_user_obj.pop('Have you been extensively involved in the following? [Mathematics and Logical Reasoning]')
    # json_user_obj['Have you been "extensively" involved in the following? [Sodtware Development]'] = json_user_obj.pop('Have you been extensively involved in the following? [Sodtware Development]')

    user_dataframe = pd.DataFrame.from_records((json_user_obj), index=[0])
    new_df = user_dataframe[col_list].copy()

    # print("******************")

    # print(new_df.head().T)
    processed_df = preprocessing_encoding.preprocess_data(new_df)

    final_membership_values_all = get_membership(processed_df, 2)

    final_scaled_membership_values_all = get_levels.get_ind_levels(
        final_membership_values_all)

    distance_min, min_cluster_index = get_levels.apply_kmeans(
        final_scaled_membership_values_all)

    # print(get_output(json_user_obj,final_membership_values_all,final_scaled_membership_values_all,min_cluster_index))

    return get_output(json_user_obj, final_membership_values_all,
                      final_scaled_membership_values_all, min_cluster_index)