First ever!

This commit is contained in:
atla8167 2024-05-27 19:16:14 +03:00
commit e8d34b7795
69 changed files with 25038 additions and 0 deletions

12
Pipfile Normal file

@ -0,0 +1,12 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
django = "*"
[dev-packages]
[requires]
python_version = "3.10"

54
Pipfile.lock generated Normal file

@ -0,0 +1,54 @@
{
"_meta": {
"hash": {
"sha256": "7e6dca07b964c2888324e576ba6c1bc240d74a27b75619fc88bca2ee3979baf8"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.10"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"asgiref": {
"hashes": [
"sha256:3e1e3ecc849832fe52ccf2cb6686b7a55f82bb1d6aee72a58826471390335e47",
"sha256:c343bd80a0bec947a9860adb4c432ffa7db769836c64238fc34bdc3fec84d590"
],
"markers": "python_version >= '3.8'",
"version": "==3.8.1"
},
"django": {
"hashes": [
"sha256:8363ac062bb4ef7c3f12d078f6fa5d154031d129a15170a1066412af49d30905",
"sha256:ff1b61005004e476e0aeea47c7f79b85864c70124030e95146315396f1e7951f"
],
"index": "pypi",
"markers": "python_version >= '3.10'",
"version": "==5.0.6"
},
"sqlparse": {
"hashes": [
"sha256:714d0a4932c059d16189f58ef5411ec2287a4360f17cdd0edd2d09d4c5087c93",
"sha256:c204494cd97479d0e39f28c93d46c0b2d5959c7b9ab904762ea6c7af211c8663"
],
"markers": "python_version >= '3.8'",
"version": "==0.5.0"
},
"typing-extensions": {
"hashes": [
"sha256:83f085bd5ca59c80295fc2a82ab5dac679cbe02b9f33f7d83af68e241bea51b0",
"sha256:c1f94d72897edaf4ce775bb7558d5b79d8126906a14ea5ed1635921406c0387a"
],
"markers": "python_version < '3.11'",
"version": "==4.11.0"
}
},
"develop": {}
}

1199
X_test.csv Normal file

File diff suppressed because it is too large Load Diff

4789
X_train.csv Normal file

File diff suppressed because it is too large Load Diff

0
backup/base/__init__.py Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
backup/base/admin.py Normal file

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
backup/base/apps.py Normal file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class BaseConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'base'

4
backup/base/forms.py Normal file

@ -0,0 +1,4 @@
from django import forms
class DocumentForm(forms.Form):
docfile = forms.FileField(label='Select a file')

@ -0,0 +1,22 @@
# Generated by Django 5.0.6 on 2024-05-20 15:19
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Upload',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('uploadFile', models.FileField(upload_to='')),
('uploadDate', models.DateTimeField(auto_now_add=True)),
],
),
]

@ -0,0 +1,23 @@
# Generated by Django 5.0.6 on 2024-05-20 15:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('base', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Document',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('docfile', models.FileField(upload_to='documents/%Y/%m/%d')),
],
),
migrations.DeleteModel(
name='Upload',
),
]

Binary file not shown.

1
backup/base/models.py Normal file

@ -0,0 +1 @@
from django.db import models

@ -0,0 +1,7 @@
$(document).ready( function()
{
$('#spinner').on('click', function()
{
$('body').addClass('busy');
});
});

@ -0,0 +1,128 @@
{% extends 'main.html' %}
{% block content %}
{% load static %}
<div class="container-fluid">
<div class="mx-auto p-4 text-center bg-white shadow-sm">
<a href="/" >
<h1>
EXTREMUM
</h1>
</a>
</div>
<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 = "mx-auto p-4 text-center">
<form action="{% url 'home' %}" id="csv" method="post" enctype="multipart/form-data">
{% csrf_token %}
<input type="file"
title="Upload excel file"
name="excel_file"
style="border: 1px solid black; padding: 5px;"
required="required">
<input action="uploadCsv" type="submit" method="POST"
value="Upload"
name="csv"
style="border: 1px solid green; padding:5px; border-radius: 2px; cursor: pointer;">
</form>
</div>
</div>
<br>
<div class="row">
<div class="col">
<div class="scrollit">
{{ data_to_display|safe }}
</div>
</div>
</div>
<br>
<div class="row">
<div class="col d-flex justify-content-center">
<h3 >
<i class="fa-solid fa-chart-simple"></i> Stats
</h3>
</div>
</div>
<div class="row">
<div class="col d-flex justify-content-center">
<form action="{% url 'stats' %}" method="POST" id="stats">
{% csrf_token %}
<select id="feature1" name="feature1">
<option disabled selected> Feature 1 </option>
{% for label in labels %}
<option value={{label}}>{{label}}</option>
{% endfor %}
</select>
<select id="feature2" name="feature2">
<option disabled selected> Feature 2 </option>
{% for label in labels %}
<option value={{label}}>{{label}}</option>
{% endfor %}
</select>
<input type="submit" value="Plot">
</form>
</div>
</div>
{% if fig %}
<div class="row">
<div class="col d-flex justify-content-center">
{{ fig|safe }}
</div>
</div>
{% endif %}
<div class="row">
<div class="col d-flex justify-content-center">
<h3 >
<i class="fas fa-cog"></i> Preprocessing
</h3>
</div>
</div>
<div class="row">
<div class="col d-flex justify-content-center multi-button">
<form action="/preprocess" method="POST">
{% csrf_token %}
<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>
<br>
<br>
<div class="row">
<div class="col d-flex justify-content-center">
<form action="/train" method="POST">
{% csrf_token %}
<button type="submit" name = "svm" style="margin:0;margin-left:16px;" class="button-6" role="button" >Support Vector Machine</button>
<button type="submit" name = "logit" style="margin:0;margin-left:16px;" class="button-6" role="button" >Logistic Regression</button>
<button type="submit" name="xgb" style="margin:0;margin-left:16px;" class="button-6" role="button" >XGBoost</button>
<button type="submit" name="dt" style="margin:0;margin-left:16px;" class="button-6" role="button" >Decision Tree</button>
<button type="submit" name="rt" style="margin:0;margin-left:16px;" class="button-6" role="button" >Random Forest</button>
</form>
</div>
</div>
<br>
<br>
</div>
{% endblock content%}

3
backup/base/tests.py Normal file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

10
backup/base/urls.py Normal file

@ -0,0 +1,10 @@
from django.urls import path
from . import views
from . import models
urlpatterns = [
path('', views.home, name="home"),
path('preprocess', views.preprocess, name="preprocess"),
path('stats', views.stats, name="stats"),
path('train',views.training, name = 'training'),
]

5
backup/base/utils.py Normal file

@ -0,0 +1,5 @@
def stats(feature1, feature2, df):
import plotly.express as px
fig = px.scatter(df, x=feature1, y=feature2, color='Churn')
fig = fig.to_html(full_html=False)
return fig

131
backup/base/views.py Normal file

@ -0,0 +1,131 @@
from django.shortcuts import render, redirect
import pandas as pd
from django.core.files.storage import FileSystemStorage
import pickle, os
from sklearn.preprocessing import OneHotEncoder
from sklearn.impute import SimpleImputer
import numpy as np
from . import utils
fig = None
excel_file_name_preprocessed = "dataset_preprocessed.csv"
excel_file_name = "dataset.csv"
def home(request):
global fig
global excel_file_name
global excel_file_name_preprocessed
if request.method == 'POST':
excel_file = request.FILES["excel_file"]
excel_file_name = request.FILES["excel_file"].name
df = pd.read_csv(excel_file)
fs = FileSystemStorage() #defaults to MEDIA_ROOT
request.session['excel_file_name'] = excel_file_name
fs.save(excel_file_name, excel_file)
idx = excel_file_name.index('.')
excel_file_name_preprocessed = excel_file_name[:idx] + "_preprocessed" + excel_file_name[idx:]
fs = FileSystemStorage() #defaults to MEDIA_ROOT
request.session['excel_file_name_preprocess'] = excel_file_name_preprocessed
fs.save(excel_file_name_preprocessed, excel_file)
# 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)
# collect the data to render
df = pd.read_csv(excel_file_name)
data_to_display = df[:5].to_html()
request.session['data_to_display'] = data_to_display
request.session['excel_file_name'] = excel_file_name
request.session['excel_file_name_preprocessed'] = excel_file_name_preprocessed
labels = df.columns
context = {'data_to_display': data_to_display, 'excel_file': excel_file_name, 'labels': labels, 'fig': fig}
return render(request,'base/home.html', context)
def stats(request):
global fig
excel_file = request.session.get('excel_file_name')
df = pd.read_csv(excel_file)
import plotly.express as px
if request.method == 'POST':
feature1 = request.POST.get('feature1')
feature2 = request.POST.get('feature2')
else:
feature1 = "MonthlyCharges"
feature2 = "tenure"
fig = px.scatter(df, x=feature1, y=feature2, color='Churn')
fig = fig.to_html(full_html=False)
request.session['fig'] = fig
return redirect('home')
def preprocess(request):
from sklearn.preprocessing import StandardScaler
excel_file_name_preprocessed = request.session.get('excel_file_name_preprocessed')
print(excel_file_name_preprocessed)
data = pd.read_csv(excel_file_name_preprocessed)
if set(['No','customerID','Churn']).issubset(data.columns):
data.drop(['No','customerID','Churn'],axis=1,inplace=True)
if request.method == 'POST':
if 'std' in request.POST:
# define standard scaler
scaler = StandardScaler()
# transform data
num_d = data.select_dtypes(exclude=['object'])
data[num_d.columns] = scaler.fit_transform(num_d)
if 'onehot' in request.POST:
data = pd.get_dummies(data,columns=['gender', 'Partner', 'Dependents', 'PhoneService', 'MultipleLines',
'InternetService', 'OnlineSecurity', 'OnlineBackup', 'DeviceProtection',
'TechSupport', 'StreamingTV', 'StreamingMovies', 'Contract',
'PaperlessBilling', 'PaymentMethod'],drop_first = True)
if 'imp' in request.POST:
data_numeric = data.select_dtypes(exclude=['object'])
data_categorical = data.select_dtypes(exclude=['number'])
imp = SimpleImputer(missing_values=np.nan, strategy='mean')
data_numeric = pd.DataFrame(imp.fit_transform(data_numeric), columns = data_numeric.columns, index=data_numeric.index) #only apply imputer to numeric columns
data = pd.concat([data_numeric, data_categorical], axis = 1)
os.remove(excel_file_name_preprocessed)
data.to_csv(excel_file_name_preprocessed)
return redirect('home')
def training(request):
global fig
excel_file = request.session.get('excel_file_name')
data = pd.read_csv(excel_file)
y=data['Churn']
y=y.replace({"Yes":1,"No":0})
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(data, y, test_size=0.2, random_state=0)
X_train.to_csv("X_train.csv")
X_test.to_csv("X_test.csv")
y_train.to_csv("y_train.csv")
y_test.to_csv("y_test.csv")
if 'logit' in request.POST:
from sklearn.linear_model import LogisticRegression
clf = LogisticRegression(random_state=0).fit(X_train, y_train)
filename = 'lg.sav'
pickle.dump(clf, open(filename, 'wb'))
return redirect('home')
if 'xgb' in request.POST:
from xgboost import XGBClassifier
xgb = XGBClassifier(learning_rate = 0.01,n_estimators=1000).fit(X_train, y_train)
file_name = 'xgb.sav'
pickle.dump(xgb,open(file_name,'wb'))
return render(request,'base/home.html', {})

0
base/__init__.py Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
base/admin.py Normal file

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
base/apps.py Normal file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class BaseConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'base'

4
base/forms.py Normal file

@ -0,0 +1,4 @@
from django import forms
class DocumentForm(forms.Form):
docfile = forms.FileField(label='Select a file')

@ -0,0 +1,22 @@
# Generated by Django 5.0.6 on 2024-05-20 15:19
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Upload',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('uploadFile', models.FileField(upload_to='')),
('uploadDate', models.DateTimeField(auto_now_add=True)),
],
),
]

@ -0,0 +1,23 @@
# Generated by Django 5.0.6 on 2024-05-20 15:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('base', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Document',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('docfile', models.FileField(upload_to='documents/%Y/%m/%d')),
],
),
migrations.DeleteModel(
name='Upload',
),
]

Binary file not shown.

Binary file not shown.

1
base/models.py Normal file

@ -0,0 +1 @@
from django.db import models

@ -0,0 +1,7 @@
$(document).ready( function()
{
$('#spinner').on('click', function()
{
$('body').addClass('busy');
});
});

@ -0,0 +1,130 @@
{% extends 'main.html' %}
{% block content %}
{% load static %}
<div class="container-fluid">
<div class="mx-auto p-4 text-center bg-white shadow-sm">
<a href="/" >
<h1>
EXTREMUM
</h1>
</a>
</div>
<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 = "mx-auto p-4 text-center">
<form action="{% url 'home' %}" id="csv" method="post" enctype="multipart/form-data">
{% csrf_token %}
<input type="file"
title="Upload excel file"
name="excel_file"
style="border: 1px solid black; padding: 5px;"
required="required">
<input type="submit" method="POST"
value="Upload"
name="csv"
style="border: 1px solid green; padding:5px; border-radius: 2px; cursor: pointer;">
</form>
</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">
<form action="{% url 'home' %}" name="plot" method="POST" id="stats">
<label style="display:flex;
flex-direction:column;
align-items: center;">
<h3>
<i class="fa-solid fa-chart-simple"></i> Stats
</h3>
</label>
{% csrf_token %}
<select id="feature1" name="feature1">
<option value={{feature1}} selected>{{feature1}}</option>
{% for label in labels %}
{% if label != feature1 %}
<option value={{label}}>{{label}}</option>
{% endif %}
{% endfor %}
</select>
<select id="feature2" name="feature2">
<option value={{feature2}} selected>{{feature2}}</option>
{% for label in labels %}
{% if label != feature2 %}
<option value={{label}}>{{label}}</option>
{% endif %}
{% endfor %}
</select>
<input type="submit" value="Plot" name="plot">
</form>
</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>
<br>
<div class="row justify-content-center">
<div class="col d-flex justify-content-center">
{{ fig|safe }}
</div>
<div class="col d-flex justify-content-center">
<form action="{% url 'home' %}" method="POST">
<label style="display:flex;
flex-direction:column;
align-items: center;">
<h3>
<i class="fa-solid fa-wand-magic-sparkles"></i> Training
</h3>
</label>
{% csrf_token %}
<div class="btn-toolbar" role="toolbar">
<button type="submit" name="svm" style="margin:0;margin-left:16px;" class="button-6" role="button" >Support Vector Machine</button>
<button type="submit" name="logit" style="margin:0;margin-left:16px;" class="button-6" role="button" >Logistic Regression</button>
<button type="submit" name="xgb" style="margin:0;margin-left:16px;" class="button-6" role="button" >XGBoost</button>
</div>
<br>
<div class="justify-content-center btn-toolbar" role="toolbar">
<button type="submit" name="dt" style="margin:0;margin-left:16px;" class="button-6" role="button" >Decision Tree</button>
<button type="submit" name="rt" style="margin:0;margin-left:16px;" class="button-6" role="button" >Random Forest</button>
</div>
</form>
</div>
</div>
</div>
{% endblock content%}

3
base/tests.py Normal file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

10
base/urls.py Normal file

@ -0,0 +1,10 @@
from django.urls import path
from . import views
from . import models
urlpatterns = [
path('', views.home, name="home"),
path('preprocess', views.preprocess, name="preprocess"),
path('stats', views.stats, name="stats"),
path('train',views.training, name = 'training'),
]

5
base/utils.py Normal file

@ -0,0 +1,5 @@
def stats(feature1, feature2, df):
import plotly.express as px
fig = px.scatter(df, x=feature1, y=feature2, color='Churn')
fig = fig.to_html(full_html=False)
return fig

142
base/views.py Normal file

@ -0,0 +1,142 @@
from django.shortcuts import render, redirect
import pandas as pd
from django.core.files.storage import FileSystemStorage
import pickle, os
from sklearn.preprocessing import OneHotEncoder
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import StandardScaler
import numpy as np
from . import utils
fig = None
excel_file_name_preprocessed = "dataset_preprocessed.csv"
excel_file_name = "dataset.csv"
def home(request):
global fig
global excel_file_name
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':
print("HEYEYEYEYEYE")
feature1 = request.POST.get('feature1')
feature2 = request.POST.get('feature2')
if 'csv' in request.POST:
excel_file = request.FILES["excel_file"]
excel_file_name = request.FILES["excel_file"].name
df = pd.read_csv(excel_file)
fs = FileSystemStorage() #defaults to MEDIA_ROOT
request.session['excel_file_name'] = excel_file_name
fs.save(excel_file_name, excel_file)
idx = excel_file_name.index('.')
excel_file_name_preprocessed = excel_file_name[:idx] + "_preprocessed" + excel_file_name[idx:]
fs = FileSystemStorage() #defaults to MEDIA_ROOT
request.session['excel_file_name_preprocess'] = excel_file_name_preprocessed
fs.save(excel_file_name_preprocessed, excel_file)
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 'plot' in request.POST:
fig = stats(excel_file_name, feature1, feature2)
if 'logit' in request.POST:
training(excel_file_name_preprocessed, 'logit')
if 'xgb' in request.POST:
training(excel_file_name_preprocessed, 'xgb')
else:
# if not post, meaning either a lanch of the page or a refresh
feature1 = 'MonthlyCharges'
feature2 = 'tenure'
fig = stats(excel_file_name, feature1, feature2)
# collect the data to render
df = pd.read_csv(excel_file_name)
data_to_display = df[:5].to_html()
request.session['data_to_display'] = data_to_display
request.session['excel_file_name'] = excel_file_name
request.session['excel_file_name_preprocessed'] = excel_file_name_preprocessed
labels = df.columns
context = {'data_to_display': data_to_display, 'excel_file': excel_file_name, 'labels': labels, 'fig': fig, 'feature1': feature1, 'feature2': feature2}
return render(request,'base/home.html', context)
def stats(name, feature1, feature2):
global fig
df = pd.read_csv(name)
import plotly.express as px
fig = px.scatter(df, x=feature1, y=feature2, color='Churn')
fig = fig.to_html(full_html=False)
return fig
def preprocess(name, type):
from sklearn.preprocessing import StandardScaler
data = pd.read_csv(name)
if set(['No','customerID','Churn']).issubset(data.columns):
data.drop(['No','customerID','Churn'],axis=1,inplace=True)
if type == 'std':
# define standard scaler
scaler = StandardScaler()
# transform data
print("HEY")
num_d = data.select_dtypes(exclude=['object'])
data[num_d.columns] = scaler.fit_transform(num_d)
if type=='onehot':
data = pd.get_dummies(data,columns=['gender', 'Partner', 'Dependents', 'PhoneService', 'MultipleLines',
'InternetService', 'OnlineSecurity', 'OnlineBackup', 'DeviceProtection',
'TechSupport', 'StreamingTV', 'StreamingMovies', 'Contract',
'PaperlessBilling', 'PaymentMethod'],drop_first = True)
if type == 'imp':
data_numeric = data.select_dtypes(exclude=['object'])
data_categorical = data.select_dtypes(exclude=['number'])
imp = SimpleImputer(missing_values=np.nan, strategy='mean')
data_numeric = pd.DataFrame(imp.fit_transform(data_numeric), columns = data_numeric.columns, index=data_numeric.index) #only apply imputer to numeric columns
data = pd.concat([data_numeric, data_categorical], axis = 1)
os.remove(excel_file_name_preprocessed)
data.to_csv(excel_file_name_preprocessed)
return
def training(name, type):
global fig
data = pd.read_csv(name)
y=data['Churn']
y=y.replace({"Yes":1,"No":0})
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(data, y, test_size=0.2, random_state=0)
X_train.to_csv("X_train.csv")
X_test.to_csv("X_test.csv")
y_train.to_csv("y_train.csv")
y_test.to_csv("y_test.csv")
if 'logit' == type:
from sklearn.linear_model import LogisticRegression
clf = LogisticRegression(random_state=0).fit(X_train, y_train)
filename = 'lg.sav'
pickle.dump(clf, open(filename, 'wb'))
if 'xgb' == type:
from xgboost import XGBClassifier
xgb = XGBClassifier(learning_rate = 0.01,n_estimators=1000).fit(X_train, y_train)
file_name = 'xgb.sav'
pickle.dump(xgb,open(file_name,'wb'))
return

5987
dataset.csv Normal file

File diff suppressed because it is too large Load Diff

5987
dataset_preprocessed.csv Normal file

File diff suppressed because it is too large Load Diff

BIN
db.sqlite3 Normal file

Binary file not shown.

0
extremum/__init__.py Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

16
extremum/asgi.py Normal file

@ -0,0 +1,16 @@
"""
ASGI config for extremum project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'extremum.settings')
application = get_asgi_application()

130
extremum/settings.py Normal file

@ -0,0 +1,130 @@
"""
Django settings for extremum project.
Generated by 'django-admin startproject' using Django 5.0.6.
For more information on this file, see
https://docs.djangoproject.com/en/5.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.0/ref/settings/
"""
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-0w^ybt_7vclag#rrutc_eo)m+l^@ml)t%jsg6n06siu)xyls+-'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'base.apps.BaseConfig',
'bootstrap5',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'extremum.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
BASE_DIR / 'templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'extremum.wsgi.application'
# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/5.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.0/howto/static-files/
STATIC_URL = '/static/'
MEDIA_URL = '/images/'
STATICFILES_DIRS = (os.path.join(BASE_DIR,'base/static'),)
# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

25
extremum/urls.py Normal file

@ -0,0 +1,25 @@
"""
URL configuration for extremum project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('base.urls'))
]

16
extremum/wsgi.py Normal file

@ -0,0 +1,16 @@
"""
WSGI config for extremum project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'extremum.settings')
application = get_wsgi_application()

BIN
lg.sav Normal file

Binary file not shown.

22
manage.py Executable file

@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'extremum.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()

109
templates/main.html Normal file

@ -0,0 +1,109 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="'IE=edge" />
<title>EXTREMUM</title>
<meta name="viewport" content="'width=device-width, initial-scale=1" />
{% load static %}
{% load bootstrap5 %}
{% bootstrap_css %}
{% bootstrap_javascript %}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
</head>
<style>
.scrollit {
overflow: auto;
height: auto;
width: 60%;
max-width: fit-content;
margin: 0px auto;
}
.dataframe {
font-size: 11pt;
font-family: Arial;
border-collapse: collapse;
margin: 25px 0;
font-size: 0.9em;
}
.dataframe thead tr {
text-align: left;
font-weight: bold;
}
.dataframe th,
.dataframe td {
padding: 12px 15px;
text-align: left;
}
.dataframe tbody tr {
border-bottom: 1px solid #dddddd;
}
.dataframe tbody tr:nth-of-type(even) {
background-color: #f3f3f3;
}
.dataframe tbody tr:last-of-type {
border-bottom: 2px solid #009879;
}
/* CSS */
.button-6 {
align-items: center;
background-color: #FFFFFF;
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: .25rem;
box-shadow: rgba(0, 0, 0, 0.02) 0 1px 3px 0;
box-sizing: border-box;
color: rgba(0, 0, 0, 0.85);
cursor: pointer;
display: inline-flex;
font-family: system-ui,-apple-system,system-ui,"Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 16px;
font-weight: 600;
justify-content: center;
line-height: 1.25;
margin: 0;
min-height: 3rem;
padding: calc(.875rem - 1px) calc(1.5rem - 1px);
position: relative;
text-decoration: none;
transition: all 250ms;
user-select: none;
-webkit-user-select: none;
touch-action: manipulation;
vertical-align: baseline;
width: auto;
}
.button-6:hover,
.button-6:focus {
border-color: rgba(0, 0, 0, 0.15);
box-shadow: rgba(0, 0, 0, 0.1) 0 4px 12px;
color: rgba(0, 0, 0, 0.65);
}
.button-6:hover {
transform: translateY(-1px);
}
.button-6:active {
background-color: #F0F0F1;
border-color: rgba(0, 0, 0, 0.15);
box-shadow: rgba(0, 0, 0, 0.06) 0 2px 4px;
color: rgba(0, 0, 0, 0.65);
transform: translateY(0);
}
</style>
<body>
{% block content %} {% endblock content %}
</body>
</html>

5
templates/navbar.html Normal file

@ -0,0 +1,5 @@
<a href="/" class="mx-auto p-4 text-center bg-white shadow-sm">
<h1>
EXTREMUM
</h1>
</a>

BIN
xgb.sav Normal file

Binary file not shown.

1199
y_test.csv Normal file

File diff suppressed because it is too large Load Diff

4789
y_train.csv Normal file

File diff suppressed because it is too large Load Diff