def execute_all(request): if(request.method == 'POST'): form = ExecuteAllForm(request.POST) if(form.is_valid()): new = form.cleaned_data['newPoint'] dataset = request.session.get('dataset') knnRes = kmeans(new, dataset) pairBasedRes = PairBased(new, dataset) fadanaRes = fadana(new, dataset) preview(request.session['dataset'], new=new) # genère l'image a afficher (juste un plan du dataset) results = {'kmeans': knnRes[-1], 'fadana': fadanaRes[0], 'pair based': pairBasedRes[0], 'lazy analogical': "Not implemented yet"} return render(request, 'integration/algorithm_comparison.html', {'results': results}) else: form = ExecuteAllForm() return render(request, 'integration/algorithm_selection.html', {'form': SelectAlgorithmForm(), 'formAll': form})
def _execute(form, dataset, algo): if(algo == 'kmeans'): neighbors, nneighbors, cl = kmeans(form.cleaned_data['newPoint'], dataset, k=form.cleaned_data['k']) kmeans_draw(form.cleaned_data['newPoint'], dataset, neighbors, nneighbors, cl) elif(algo == 'pairBased'): classe, c, couples = PairBased(form.cleaned_data['newPoint'], dataset) pb_draw(form.cleaned_data['newPoint'], dataset, c, couples, classe) elif(algo == 'fadana'): classe, triplets, analogicalDiff = fadana(form.cleaned_data['newPoint'], dataset, k=form.cleaned_data['k']) f_draw(form.cleaned_data['newPoint'], dataset, triplets, analogicalDiff, classe) elif(algo == 'lazy'): classe, triplets, analogicalDiff = lazy_analogical(form.cleaned_data['newPoint'], dataset) la_draw(form.cleaned_data['newPoint'], dataset, triplets, analogicalDiff, classe)