Esempio n. 1
0
def export_dataset_to_csv(request, input_dict, output_dict, widget):
    """Visualization for exporting dataset to CSV file and download of the file

    :param request:
    :param input_dict:
    :param output_dict:
    :param widget:
    :return:
    """

    output_dict = {}
    dataset = input_dict['dataset']

    csv = []
    for i, sample in enumerate(dataset.data):
        csv.append(np.append(
            sample, dataset.target[i]))  #join n_sample and n_feature array

    destination = helpers.get_media_root() + '/' + str(
        request.user.id) + '/' + str(widget.id) + '.csv'
    np.savetxt(destination, csv, delimiter=",")

    filename = str(request.user.id) + '/' + str(widget.id) + '.csv'
    output_dict['filename'] = filename
    return render(request, 'visualizations/string_to_file.html', {
        'widget': widget,
        'input_dict': input_dict,
        'output_dict': output_dict
    })
def export_dataset_to_csv(request,input_dict,output_dict,widget):
    """Visualization for exporting dataset to CSV file and download of the file

    :param request:
    :param input_dict:
    :param output_dict:
    :param widget:
    :return:
    """

    output_dict={}
    dataset= input_dict['dataset']

    csv=[]
    for i,sample in enumerate(dataset.data):
        csv.append(np.append(sample,dataset.target[i])) #join n_sample and n_feature array

    destination = helpers.get_media_root()+'/'+str(request.user.id)+'/'+str(widget.id)+'.csv'
    np.savetxt(destination, csv, delimiter=",")

    filename = str(request.user.id)+'/'+str(widget.id)+'.csv'
    output_dict['filename'] = filename
    return render(request, 'visualizations/string_to_file.html',{'widget':widget,'input_dict':input_dict,'output_dict':output_dict})
Esempio n. 3
0
def wekaLocalExportDatasetToARFF(request,input_dict,output_dict,widget):
    import utilities as ut
    from cf_core import helpers

    if not jp.isThreadAttachedToJVM():
        jp.attachThreadToJVM()

    bunch = input_dict['instances']
    output_dict = {}

    instances = ut.convert_bunch_to_weka_instances(bunch)

    destination = helpers.get_media_root()+'/'+str(request.user.id)+'/'+str(widget.id)+'.arff'

    f = open(destination, 'w')
    s = instances.toString()
    f.write(s)
    f.close()

    filename = str(request.user.id)+'/'+str(widget.id)+'.arff'
    output_dict['filename'] = filename

    return render(request, 'visualizations/string_to_file.html',{'widget':widget,'input_dict':input_dict,'output_dict':output_dict})