Altered layout
This commit is contained in:
parent
539aa9849c
commit
9a02a02658
0
README.md
Normal file
0
README.md
Normal file
@ -13,18 +13,17 @@
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col d-flex justify-content-center">
|
|
||||||
<h3>
|
|
||||||
<i class="fas fa-upload"></i> Import a file
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class = "mx-auto p-4 text-center">
|
<div class="col d-flex justify-content-center">
|
||||||
<form action="{% url 'home' %}" id="csv" method="post" enctype="multipart/form-data">
|
<form action="{% url 'home' %}" id="csv" method="post" enctype="multipart/form-data">
|
||||||
|
<label style="display:flex;
|
||||||
|
flex-direction:column;
|
||||||
|
align-items: center;">
|
||||||
|
<h3>
|
||||||
|
<i class="fas fa-upload"></i> Import a file
|
||||||
|
</h3>
|
||||||
|
</label>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="file"
|
<input type="file"
|
||||||
title="Upload excel file"
|
title="Upload excel file"
|
||||||
@ -37,19 +36,6 @@
|
|||||||
style="border: 1px solid green; padding:5px; border-radius: 2px; cursor: pointer;">
|
style="border: 1px solid green; padding:5px; border-radius: 2px; cursor: pointer;">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<br>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<div class="scrollit">
|
|
||||||
{{ data_to_display|safe }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col d-flex justify-content-center">
|
<div class="col d-flex justify-content-center">
|
||||||
<form action="{% url 'home' %}" name="plot" method="POST" id="stats">
|
<form action="{% url 'home' %}" name="plot" method="POST" id="stats">
|
||||||
<label style="display:flex;
|
<label style="display:flex;
|
||||||
@ -79,30 +65,22 @@
|
|||||||
<input type="submit" value="Plot" name="plot">
|
<input type="submit" value="Plot" name="plot">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col d-flex justify-content-center multi-button">
|
|
||||||
<form action="{% url 'home' %}" method="POST">
|
|
||||||
{% csrf_token %}
|
|
||||||
<label style="display:flex;
|
|
||||||
flex-direction:column;
|
|
||||||
align-items: center;">
|
|
||||||
<h3>
|
|
||||||
<i class="fas fa-cog"></i> Preprocessing
|
|
||||||
</h3>
|
|
||||||
</label>
|
|
||||||
<div class="multi-button">
|
|
||||||
<button type="submit" name="std" class="button-6" role="button" >Standardization</button>
|
|
||||||
<button type="submit" name="onehot" style="margin:0;margin-left:16px;" class="button-6" role="button" >One Hot Encoding</button>
|
|
||||||
<button type="submit" name="imp" style="margin:0;margin-left:16px;" class="button-6" role="button" >Imputations</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<div class="row justify-content-center">
|
<div class="row">
|
||||||
|
<div class="col d-flex justify-content-center">
|
||||||
|
<div class="scrollit">
|
||||||
|
{{ data_to_display|safe }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="col d-flex justify-content-center">
|
<div class="col d-flex justify-content-center">
|
||||||
{{ fig|safe }}
|
{{ fig|safe }}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<div class="row justify-content-center">
|
||||||
<div class="col d-flex justify-content-center">
|
<div class="col d-flex justify-content-center">
|
||||||
<form action="{% url 'home' %}" method="POST">
|
<form action="{% url 'home' %}" method="POST">
|
||||||
<label style="display:flex;
|
<label style="display:flex;
|
||||||
@ -125,6 +103,25 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col d-flex justify-content-center">
|
||||||
|
<div class="col d-flex justify-content-center multi-button">
|
||||||
|
<form action="{% url 'home' %}" method="POST">
|
||||||
|
{% csrf_token %}
|
||||||
|
<label style="display:flex;
|
||||||
|
flex-direction:column;
|
||||||
|
align-items: center;">
|
||||||
|
<h3>
|
||||||
|
<i class="fas fa-cog"></i> Preprocessing
|
||||||
|
</h3>
|
||||||
|
</label>
|
||||||
|
<div class="multi-button">
|
||||||
|
<button type="submit" name="std" class="button-6" role="button" >Standardization</button>
|
||||||
|
<button type="submit" name="onehot" style="margin:0;margin-left:16px;" class="button-6" role="button" >One Hot Encoding</button>
|
||||||
|
<button type="submit" name="imp" style="margin:0;margin-left:16px;" class="button-6" role="button" >Imputations</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock content%}
|
{% endblock content%}
|
||||||
|
@ -6,6 +6,8 @@ from sklearn.preprocessing import OneHotEncoder
|
|||||||
from sklearn.impute import SimpleImputer
|
from sklearn.impute import SimpleImputer
|
||||||
from sklearn.preprocessing import StandardScaler
|
from sklearn.preprocessing import StandardScaler
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from pandas.api.types import is_string_dtype
|
||||||
|
from pandas.api.types import is_numeric_dtype
|
||||||
from . import utils
|
from . import utils
|
||||||
|
|
||||||
|
|
||||||
@ -18,19 +20,15 @@ def home(request):
|
|||||||
global excel_file_name
|
global excel_file_name
|
||||||
global excel_file_name_preprocessed
|
global excel_file_name_preprocessed
|
||||||
|
|
||||||
# if file for preprocessing does not exist create it
|
|
||||||
if os.path.exists(excel_file_name_preprocessed) == False:
|
|
||||||
df = pd.read_csv(excel_file_name)
|
|
||||||
df.to_csv(excel_file_name_preprocessed)
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
print("HEYEYEYEYEYE")
|
|
||||||
feature1 = request.POST.get('feature1')
|
|
||||||
feature2 = request.POST.get('feature2')
|
|
||||||
if 'csv' in request.POST:
|
if 'csv' in request.POST:
|
||||||
excel_file = request.FILES["excel_file"]
|
excel_file = request.FILES["excel_file"]
|
||||||
excel_file_name = request.FILES["excel_file"].name
|
excel_file_name = request.FILES["excel_file"].name
|
||||||
df = pd.read_csv(excel_file)
|
|
||||||
|
# here we dont use the name of the file since the
|
||||||
|
# uploaded file is not yet saved
|
||||||
|
# In every other case we just need the name
|
||||||
|
df = pd.read_csv(excel_file)
|
||||||
|
|
||||||
fs = FileSystemStorage() #defaults to MEDIA_ROOT
|
fs = FileSystemStorage() #defaults to MEDIA_ROOT
|
||||||
request.session['excel_file_name'] = excel_file_name
|
request.session['excel_file_name'] = excel_file_name
|
||||||
@ -41,29 +39,49 @@ def home(request):
|
|||||||
fs = FileSystemStorage() #defaults to MEDIA_ROOT
|
fs = FileSystemStorage() #defaults to MEDIA_ROOT
|
||||||
request.session['excel_file_name_preprocess'] = excel_file_name_preprocessed
|
request.session['excel_file_name_preprocess'] = excel_file_name_preprocessed
|
||||||
fs.save(excel_file_name_preprocessed, excel_file)
|
fs.save(excel_file_name_preprocessed, excel_file)
|
||||||
|
# if file for preprocessing does not exist create it
|
||||||
if 'std' in request.POST:
|
if os.path.exists(excel_file_name_preprocessed) == False:
|
||||||
preprocess(excel_file_name_preprocessed, 'std')
|
df.to_csv(excel_file_name_preprocessed)
|
||||||
if 'onehot' in request.POST:
|
|
||||||
preprocess(excel_file_name_preprocessed, 'onehot')
|
feature1 = df.columns[0]
|
||||||
if 'imp' in request.POST:
|
feature2 = df.columns[1]
|
||||||
preprocess(excel_file_name_preprocessed, 'imp')
|
request.session['feature1'] = feature1
|
||||||
|
request.session['feature2'] = feature2
|
||||||
if 'plot' in request.POST:
|
|
||||||
fig = stats(excel_file_name, feature1, feature2)
|
|
||||||
|
|
||||||
if 'logit' in request.POST:
|
elif 'plot' in request.POST:
|
||||||
training(excel_file_name_preprocessed, 'logit')
|
df = pd.read_csv(excel_file_name)
|
||||||
if 'xgb' in request.POST:
|
feature1 = request.POST.get('feature1')
|
||||||
training(excel_file_name_preprocessed, 'xgb')
|
feature2 = request.POST.get('feature2')
|
||||||
|
print(feature1)
|
||||||
|
request.session['feature1'] = feature1
|
||||||
|
request.session['feature2'] = feature2
|
||||||
|
else:
|
||||||
|
df = pd.read_csv(excel_file_name)
|
||||||
|
|
||||||
|
if 'std' in request.POST:
|
||||||
|
preprocess(excel_file_name_preprocessed, 'std')
|
||||||
|
if 'onehot' in request.POST:
|
||||||
|
preprocess(excel_file_name_preprocessed, 'onehot')
|
||||||
|
if 'imp' in request.POST:
|
||||||
|
preprocess(excel_file_name_preprocessed, 'imp')
|
||||||
|
|
||||||
|
if 'logit' in request.POST:
|
||||||
|
training(excel_file_name_preprocessed, 'logit')
|
||||||
|
if 'xgb' in request.POST:
|
||||||
|
training(excel_file_name_preprocessed, 'xgb')
|
||||||
else:
|
else:
|
||||||
# if not post, meaning either a lanch of the page or a refresh
|
df = pd.read_csv(excel_file_name)
|
||||||
feature1 = 'MonthlyCharges'
|
# if file for preprocessing does not exist create it
|
||||||
feature2 = 'tenure'
|
if os.path.exists(excel_file_name_preprocessed) == False:
|
||||||
fig = stats(excel_file_name, feature1, feature2)
|
df.to_csv(excel_file_name_preprocessed)
|
||||||
|
|
||||||
# collect the data to render
|
feature1 = df.columns[0]
|
||||||
df = pd.read_csv(excel_file_name)
|
feature2 = df.columns[1]
|
||||||
|
request.session['feature1'] = feature1
|
||||||
|
request.session['feature2'] = feature2
|
||||||
|
|
||||||
|
fig = stats(excel_file_name, request.session['feature1'], request.session['feature2'])
|
||||||
|
|
||||||
data_to_display = df[:5].to_html()
|
data_to_display = df[:5].to_html()
|
||||||
|
|
||||||
request.session['data_to_display'] = data_to_display
|
request.session['data_to_display'] = data_to_display
|
||||||
@ -71,14 +89,23 @@ def home(request):
|
|||||||
request.session['excel_file_name_preprocessed'] = excel_file_name_preprocessed
|
request.session['excel_file_name_preprocessed'] = excel_file_name_preprocessed
|
||||||
labels = df.columns
|
labels = df.columns
|
||||||
|
|
||||||
context = {'data_to_display': data_to_display, 'excel_file': excel_file_name, 'labels': labels, 'fig': fig, 'feature1': feature1, 'feature2': feature2}
|
context = {'data_to_display': data_to_display, 'excel_file': excel_file_name, 'labels': labels, 'fig': fig, 'feature1': request.session['feature1'], 'feature2': request.session['feature2']}
|
||||||
return render(request,'base/home.html', context)
|
return render(request,'base/home.html', context)
|
||||||
|
|
||||||
def stats(name, feature1, feature2):
|
def stats(name, feature1, feature2):
|
||||||
global fig
|
global fig
|
||||||
df = pd.read_csv(name)
|
df = pd.read_csv(name)
|
||||||
import plotly.express as px
|
import plotly.express as px
|
||||||
fig = px.scatter(df, x=feature1, y=feature2, color='Churn')
|
if is_numeric_dtype(df[feature1]) and is_numeric_dtype(df[feature2]):
|
||||||
|
print("if")
|
||||||
|
fig = px.scatter(df, feature1, feature2, color='DEATH_EVENT')
|
||||||
|
elif is_string_dtype(df[feature1]) and is_string_dtype(df[feature2]):
|
||||||
|
print("elseif")
|
||||||
|
fig = px.histogram(df, feature1)
|
||||||
|
else:
|
||||||
|
print("else")
|
||||||
|
fig = px.strip(df, feature1, feature2)
|
||||||
|
|
||||||
fig = fig.to_html(full_html=False)
|
fig = fig.to_html(full_html=False)
|
||||||
return fig
|
return fig
|
||||||
|
|
||||||
|
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
@ -16,8 +16,10 @@
|
|||||||
|
|
||||||
.scrollit {
|
.scrollit {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
position: fixed;
|
||||||
|
float: left;
|
||||||
height: auto;
|
height: auto;
|
||||||
width: 60%;
|
width: 40%;
|
||||||
max-width: fit-content;
|
max-width: fit-content;
|
||||||
margin: 0px auto;
|
margin: 0px auto;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user