├── .gitignore ├── .idea ├── .gitignore ├── XBNet.iml ├── inspectionProfiles │ ├── Project_Default.xml │ └── profiles_settings.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── CODE-OF-CONDUCT.md ├── CONTRIBUTING.md ├── License.txt ├── Modelly ├── app.py ├── results_graph.png ├── static │ ├── images │ │ └── Training_graphs.png │ └── index.css ├── templates │ ├── base.html │ ├── index.html │ ├── layers.html │ ├── partials │ │ └── _sawo.html │ ├── results.html │ ├── treesinp.html │ └── upload.html └── xbnet_testAccuracy_66.7_trainAccuracy_63.4.pt ├── READ.md ├── README.md ├── Research_Paper └── XBNET_paper.pdf ├── Untitled.png ├── XBNet ├── Seq.py ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-37.pyc │ └── run.cpython-37.pyc ├── main.py ├── models.py ├── run.py └── training_utils.py ├── index.rst ├── screenshots ├── Results_metrics.png └── results_graph.png ├── setup.py └── test ├── Iris (1).csv ├── data (2).csv ├── diabetes.csv ├── digit_recognizer.py ├── digits.py ├── german.data ├── gui_test.py ├── test.py ├── titanic.csv ├── titanic_test.csv ├── train.csv └── wine.py /.gitignore: -------------------------------------------------------------------------------- 1 | Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 98 | __pypackages__/ 99 | 100 | # Celery stuff 101 | celerybeat-schedule 102 | celerybeat.pid 103 | 104 | # SageMath parsed files 105 | *.sage.py 106 | 107 | # Environments 108 | .env 109 | .venv 110 | env/ 111 | venv/ 112 | ENV/ 113 | env.bak/ 114 | venv.bak/ 115 | 116 | # Spyder project settings 117 | .spyderproject 118 | .spyproject 119 | 120 | # Rope project settings 121 | .ropeproject 122 | 123 | # mkdocs documentation 124 | /site 125 | 126 | # mypy 127 | .mypy_cache/ 128 | .dmypy.json 129 | dmypy.json 130 | 131 | # Pyre type checker 132 | .pyre/ 133 | 134 | # pytype static type analyzer 135 | .pytype/ 136 | 137 | # Cython debug symbols 138 | cython_debug/ 139 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/XBNet.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 15 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CODE-OF-CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | Our ethics and morals guide us in our day-to-day interactions and decision-making. Our open source projects are no exception. Trust, respect, collaboration and transparency are core values we believe should live and breathe within our projects. Our community welcomes participants from around the world with different experiences, unique perspectives, and great ideas to share. 4 | 5 | ## Our Pledge 6 | 7 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. 8 | 9 | ## Our Standards 10 | 11 | Examples of behavior that contributes to creating a positive environment include: 12 | 13 | - Using welcoming and inclusive language 14 | - Being respectful of differing viewpoints and experiences 15 | - Gracefully accepting constructive criticism 16 | - Attempting collaboration before conflict 17 | - Focusing on what is best for the community 18 | - Showing empathy towards other community members 19 | 20 | Examples of unacceptable behavior by participants include: 21 | 22 | - Violence, threats of violence, or inciting others to commit self-harm 23 | - The use of sexualized language or imagery and unwelcome sexual attention or advances 24 | - Trolling, intentionally spreading misinformation, insulting/derogatory comments, and personal or political attacks 25 | - Public or private harassment 26 | - Publishing others' private information, such as a physical or electronic address, without explicit permission 27 | - Abuse of the reporting process to intentionally harass or exclude others 28 | - Advocating for, or encouraging, any of the above behavior 29 | - Other conduct which could reasonably be considered inappropriate in a professional setting 30 | 31 | ## Our Responsibilities 32 | 33 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 34 | 35 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 36 | 37 | ## Scope 38 | 39 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 40 | 41 | ## Enforcement 42 | 43 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting us anonymously through [this form](https://forms.gle/tPsrKs6Q3TEVRDG19). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. 44 | 45 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 46 | 47 | If you are unsure whether an incident is a violation, or whether the space where the incident took place is covered by our Code of Conduct, **we encourage you to still report it**. We would prefer to have a few extra reports where we decide to take no action, than to leave an incident go unnoticed and unresolved that may result in an individual or group to feel like they can no longer participate in the community. Reports deemed as not a violation will also allow us to improve our Code of Conduct and processes surrounding it. If you witness a dangerous situation or someone in distress, we encourage you to report even if you are only an observer. 48 | 49 | ## Attribution 50 | 51 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 52 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to XBNet 2 | 3 | A big welcome and thank you for considering contributing to XBNet! It’s people like you that make it a reality for users in our community. 4 | 5 | Reading and following these guidelines will help us make the contribution process easy and effective for everyone involved. It also communicates that you agree to respect the time of the developers managing and developing these open source projects. In return, we will reciprocate that respect by addressing your issue, assessing changes, and helping you finalize your pull requests. 6 | 7 | ## Quicklinks 8 | 9 | * [Code of Conduct](#code-of-conduct) 10 | * [Getting Started](#getting-started) 11 | * [Issues](#issues) 12 | * [Pull Requests](#pull-requests) 13 | * [Getting Help](#getting-help) 14 | 15 | ## Code of Conduct 16 | 17 | We take our open source community seriously and hold ourselves and other contributors to high standards of communication. By participating and contributing to this project, you agree to uphold our [Code of Conduct](https://github.com/tusharsarkar3/XBNet/blob/master/CODE-OF-CONDUCT.md). 18 | 19 | ## Getting Started 20 | 21 | Contributions are made to this repo via Issues and Pull Requests (PRs). A few general guidelines that cover both: 22 | 23 | - Search for existing Issues and PRs before creating your own. 24 | - We work hard to makes sure issues are handled in a timely manner but, depending on the impact, it could take a while to investigate the root cause. A friendly ping in the comment thread to the submitter or a contributor can help draw attention if your issue is blocking. 25 | - If you've never contributed before, see [the first timer's guide on our blog](https://auth0.com/blog/a-first-timers-guide-to-an-open-source-project/) for resources and tips on how to get started. 26 | 27 | ### Issues 28 | 29 | Issues should be used to report problems with the library, request a new feature, or to discuss potential changes before a PR is created. When you create a new Issue, a template will be loaded that will guide you through collecting and providing the information we need to investigate. 30 | 31 | If you find an Issue that addresses the problem you're having, please add your own reproduction information to the existing issue rather than creating a new one. Adding a [reaction](https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) can also help be indicating to our maintainers that a particular problem is affecting more than just the reporter. 32 | 33 | ### Pull Requests 34 | 35 | PRs to our libraries are always welcome and can be a quick way to get your fix or improvement slated for the next release. In general, PRs should: 36 | 37 | - Only fix/add the functionality in question **OR** address wide-spread whitespace/style issues, not both. 38 | - Add unit or integration tests for fixed or changed functionality (if a test suite already exists). 39 | - Address a single concern in the least number of changed lines as possible. 40 | - Include documentation in the repo or on our [docs site](https://xbnet.readthedocs.io/en/latest/). 41 | - Be accompanied by a complete Pull Request template (loaded automatically when a PR is created). 42 | 43 | For changes that address core functionality or would require breaking changes (e.g. a major release), it's best to open an Issue to discuss your proposal first. This is not required but can save time creating and reviewing changes. 44 | 45 | In general, we follow the ["fork-and-pull" Git workflow](https://github.com/susam/gitpr) 46 | 47 | 1. Fork the repository to your own Github account 48 | 2. Clone the project to your machine 49 | 3. Create a branch locally with a succinct but descriptive name 50 | 4. Commit changes to the branch 51 | 5. Following any formatting and testing guidelines specific to this repo 52 | 6. Push changes to your fork 53 | 7. Open a PR in our repository and follow the PR template so that we can efficiently review the changes. 54 | 55 | ## Getting Help 56 | 57 | Join us in the [Analytica Community](https://t.me/analyticadata) and post your question there in the correct category with a descriptive tag. 58 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 The Python Packaging Authority 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /Modelly/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request, send_file 2 | import csv 3 | import pandas as pd 4 | from xgboost import XGBClassifier 5 | from sklearn.ensemble import RandomForestClassifier 6 | from sklearn.tree import DecisionTreeClassifier 7 | from lightgbm import LGBMClassifier 8 | import torch 9 | import numpy as np 10 | from sklearn.preprocessing import LabelEncoder 11 | from sklearn.model_selection import train_test_split 12 | from XBNet.training_utils import training, predict 13 | from XBNet.models import XBNETClassifier 14 | from XBNet.run import run_XBNET 15 | import matplotlib.pyplot as plt 16 | import os 17 | import shutil 18 | import pickle 19 | 20 | app = Flask(__name__) 21 | 22 | 23 | @app.route('/') 24 | def uploady_file(): 25 | return render_template('index.html') 26 | 27 | 28 | @app.route('/uploader', methods=['GET', 'POST']) 29 | def upload_file(): 30 | global df 31 | global model_name 32 | global layers 33 | global target, n_layers_boosted 34 | if request.method == 'POST': 35 | df = pd.read_csv(request.files['csvfile']) 36 | model_name = request.form['model'] 37 | layers = request.form['num_layers'] 38 | target = request.form['target'] 39 | 40 | model_name = model_name.lower() 41 | if len(layers) > 0: 42 | layers = int(layers) 43 | target = target 44 | if model_name.lower() == "xbnet": 45 | n_layers_boosted = 1 46 | layers = [i + 1 for i in range(int(layers))] 47 | process_input() 48 | return render_template('layers.html', layers=layers) 49 | # self.net_model() 50 | elif (model_name == "xgboost" or model_name == "randomforest" 51 | or model_name == "decision tree" or model_name == "lightgbm" or "Logistic Regression"): 52 | process_input() 53 | return render_template('treesinp.html', layers=layers) 54 | # self.tree_model() 55 | elif model_name.lower() == "neural network": 56 | n_layers_boosted = 0 57 | layers = [i + 1 for i in range(int(layers))] 58 | process_input() 59 | return render_template('layers.html', layers=layers) 60 | # self.net_model() 61 | 62 | # get number of layers, preferably produce a list 63 | 64 | # return 'file uploaded successfully' 65 | 66 | 67 | @app.route('/layers', methods=['GET', 'POST']) 68 | def getlayers(): 69 | global layers_dims 70 | fileExt = r".pt" 71 | file = [_ for _ in os.listdir(os.getcwd()) if _.endswith(fileExt)] 72 | if len(file) > 0: 73 | os.remove(file[0]) 74 | fileExt = r".pkl" 75 | file = [_ for _ in os.listdir(os.getcwd()) if _.endswith(fileExt)] 76 | if len(file) > 0: 77 | os.remove(file[0]) 78 | layers_dims = [] 79 | if request.method == 'POST': 80 | if model_name.lower() == "xbnet" or model_name.lower() == "neural network": 81 | for i in layers: 82 | layers_dims.append(int(request.form["i" + str(i)])) 83 | layers_dims.append(int(request.form["o" + str(i)])) 84 | print(layers_dims) 85 | train() 86 | path = os.path.join("static/", "images") 87 | print(path) 88 | if os.path.isdir(path) == False: 89 | os.mkdir(path) 90 | if os.path.isfile("static\images\Training_graphs.png") == True: 91 | os.remove("static\images\Training_graphs.png") 92 | shutil.move("Training_graphs.png", path) 93 | return render_template("results.html", info={"training_acc": acc[-1], "testing_acc": val_ac[-1], 94 | "img": True}) 95 | 96 | elif (model_name == "xgboost" or model_name == "randomforest" 97 | or model_name == "decision tree" or model_name == "lightgbm"): 98 | for i in request.form.keys(): 99 | try: 100 | layers_dims.append(int(request.form[i])) 101 | except: 102 | layers_dims.append(float(request.form[i])) 103 | print(layers_dims) 104 | train() 105 | 106 | return render_template("results.html", info={"training_acc": training_acc*100, 107 | "testing_acc": testing_acc*100, "img": False}) 108 | 109 | 110 | @app.route('/default', methods=['GET', 'POST']) 111 | def default(): 112 | global layers_dims 113 | global layers_dims 114 | fileExt = r".pt" 115 | file = [_ for _ in os.listdir(os.getcwd()) if _.endswith(fileExt)] 116 | if len(file) > 0: 117 | os.remove(file[0]) 118 | fileExt = r".pkl" 119 | file = [_ for _ in os.listdir(os.getcwd()) if _.endswith(fileExt)] 120 | if len(file) > 0: 121 | os.remove(file[0]) 122 | layers_dims = [100, 6, 0.3, 1, 1] 123 | train() 124 | return render_template("results.html", info={"training_acc": training_acc*100, "testing_acc": testing_acc*100, 125 | "img": False}) 126 | 127 | 128 | @app.route('/download', methods=['GET', 'POST']) 129 | def download(): 130 | if model_name.lower() == "xbnet" or model_name.lower() == "neural network": 131 | fileExt = r".pt" 132 | file = [_ for _ in os.listdir(os.getcwd()) if _.endswith(fileExt)][0] 133 | return send_file(file) 134 | else: 135 | fileExt = r".pkl" 136 | file = [_ for _ in os.listdir(os.getcwd()) if _.endswith(fileExt)][0] 137 | return send_file(file) 138 | 139 | 140 | def process_input(): 141 | global x_data, y_data, label_encoded, imputations, label_y, columns_finally_used, y_label_encoder 142 | column_to_predict = target 143 | data = df 144 | n_df = len(data) 145 | label_encoded = {} 146 | imputations = {} 147 | for i in data.columns: 148 | imputations[i] = data[i].mode() 149 | if data[i].isnull().sum() / n_df >= 0.15: 150 | data.drop(i, axis=1, inplace=True) 151 | elif data[i].isnull().sum() / n_df < 0.15 and data[i].isnull().sum() / n_df > 0: 152 | data[i].fillna(data[i].mode(), inplace=True) 153 | imputations[i] = data[i].mode() 154 | columns_object = list(data.dtypes[data.dtypes == object].index) 155 | for i in columns_object: 156 | if i != column_to_predict: 157 | if data[i].nunique() / n_df < 0.4: 158 | le = LabelEncoder() 159 | data[i] = le.fit_transform(data[i]) 160 | label_encoded[i] = le 161 | else: 162 | data.drop(i, axis=1, inplace=True) 163 | 164 | x_data = data.drop(column_to_predict, axis=1).to_numpy() 165 | columns_finally_used = data.drop(column_to_predict, axis=1).columns 166 | 167 | y_data = data[column_to_predict].to_numpy() 168 | label_y = False 169 | if y_data.dtype == object: 170 | label_y = True 171 | y_label_encoder = LabelEncoder() 172 | y_data = y_label_encoder.fit_transform(y_data) 173 | print("Number of features are: " + str(x_data.shape[1]) + 174 | " classes are: " + str(len(np.unique(y_data)))) 175 | 176 | 177 | def train(): 178 | global model_tree, model_trained, acc, val_ac, training_acc, testing_acc 179 | X_train, X_test, y_train, y_test = train_test_split(x_data, y_data, 180 | test_size=0.3, random_state=0) 181 | if model_name == "xbnet" or model_name == "neural network": 182 | m = model_name 183 | print(layers) 184 | print(layers_dims, n_layers_boosted) 185 | model = XBNETClassifier(X_train, y_train, num_layers=int(len(layers) / 2), num_layers_boosted=n_layers_boosted, 186 | input_through_cmd=True, inputs_for_gui=layers_dims, 187 | ) 188 | criterion = torch.nn.CrossEntropyLoss() 189 | optimizer = torch.optim.Adam(model.parameters(), lr=0.01) 190 | 191 | model_trained, acc, lo, val_ac, val_lo = run_XBNET(X_train, X_test, y_train, y_test, model, 192 | criterion, optimizer, 32, 300, save=True) 193 | model_trained.save(m + "_testAccuracy_" + str(max(val_ac))[:4] + "_trainAccuracy_" + 194 | str(max(acc))[:4] + ".pt", ) 195 | # toast("Test Accuracy is: " +str(max(val_ac))[:4] +" and Training Accuracy is: " + 196 | # str(max(acc))[:4] + " and model is saved.",duration= 10) 197 | return render_template("results.html", info={"training_acc": acc, "testing_acc": val_ac}) 198 | 199 | elif (model_name == "xgboost" or model_name == "randomforest" 200 | or model_name == "decision tree" or model_name == "lightgbm"): 201 | if model_name == "xgboost": 202 | model_tree = XGBClassifier(n_estimators=layers_dims[0], 203 | max_depth=layers_dims[1], 204 | learning_rate=layers_dims[2], 205 | subsample=layers_dims[3], 206 | colsample_bylevel=layers_dims[4], 207 | random_state=0, n_jobs=-1, 208 | ) 209 | model_tree.fit(X_train, y_train, eval_metric="mlogloss") 210 | training_acc = model_tree.score(X_train, y_train) 211 | testing_acc = model_tree.score(X_test, y_test) 212 | elif model_name == "randomforest": 213 | model_tree = RandomForestClassifier(n_estimators=layers_dims[0], 214 | max_depth=layers_dims[1], 215 | random_state=0, n_jobs=-1) 216 | model_tree.fit(X_train, y_train) 217 | training_acc = model_tree.score(X_train, y_train) 218 | testing_acc = model_tree.score(X_test, y_test) 219 | elif model_name == "decision tree": 220 | model_tree = DecisionTreeClassifier(max_depth=layers_dims[1], random_state=0) 221 | model_tree.fit(X_train, y_train) 222 | training_acc = model_tree.score(X_train, y_train) 223 | testing_acc = model_tree.score(X_test, y_test) 224 | elif model_name == "lightgbm": 225 | model_tree = LGBMClassifier(n_estimators=layers_dims[0], 226 | max_depth=layers_dims[1], 227 | learning_rate=layers_dims[2], 228 | subsample=layers_dims[3], 229 | colsample_bylevel=layers_dims[4], 230 | random_state=0, n_jobs=-1, ) 231 | model_tree.fit(X_train, y_train, eval_metric="mlogloss") 232 | training_acc = model_tree.score(X_train, y_train) 233 | testing_acc = model_tree.score(X_test, y_test) 234 | print("Training and Testing accuracies are " + str(training_acc * 100) 235 | + " " + str(testing_acc * 100) + " respectively and model is stored") 236 | with open(model_name + "_testAccuracy_" + str(testing_acc)[:4] + "_trainAccuracy_" + 237 | str(training_acc)[:4] + ".pkl", 'wb') as outfile: 238 | pickle.dump(model_tree, outfile) 239 | 240 | 241 | @app.route('/predict', methods=['GET', 'POST']) 242 | def predict_results(): 243 | df_predict = pd.read_csv(request.files["csvpredictfile"]) 244 | print(list(columns_finally_used)) 245 | data = df_predict[list(columns_finally_used)] 246 | for i in data.columns: 247 | if data[i].isnull().sum() > 0: 248 | data[i].fillna(imputations[i], inplace=True) 249 | if i in label_encoded.keys(): 250 | data[i] = label_encoded[i].transform(data[i]) 251 | if (model_name == "xgboost" or model_name == "randomforest" 252 | or model_name == "decision tree" or model_name == "lightgbm"): 253 | predictions = model_tree.predict(data.to_numpy()) 254 | else: 255 | predictions = predict(model_trained, data.to_numpy()) 256 | if label_y == True: 257 | df_predict[target] = y_label_encoder.inverse_transform(predictions) 258 | else: 259 | df_predict[target] = predictions 260 | df_predict.to_csv("Predicted_Results.csv", index=False) 261 | return send_file("Predicted_Results.csv") 262 | # toast(text="Predicted_Results.csv in this directory has the results", 263 | # duration = 10) 264 | 265 | 266 | if __name__ == '__main__': 267 | app.run(debug=True) -------------------------------------------------------------------------------- /Modelly/results_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tusharsarkar3/XBNet/2b771d6beb9f15ae48e2a365f46d6f996811086f/Modelly/results_graph.png -------------------------------------------------------------------------------- /Modelly/static/images/Training_graphs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tusharsarkar3/XBNet/2b771d6beb9f15ae48e2a365f46d6f996811086f/Modelly/static/images/Training_graphs.png -------------------------------------------------------------------------------- /Modelly/static/index.css: -------------------------------------------------------------------------------- 1 | *{ 2 | font-family:sans-serif; 3 | } 4 | 5 | 6 | .intro{ 7 | background-color:rgba(13, 13, 77, 0.644); 8 | height:100%; 9 | color: white; 10 | vertical-align:middle; 11 | margin-top: 0; 12 | 13 | } 14 | .desc{ 15 | font-weight:10; 16 | 17 | } 18 | .xbnet{ 19 | color:#ec660c; 20 | } 21 | 22 | 23 | body{ 24 | background-image: url(https://freedesignfile.com/upload/2017/06/Origami-black-background-vectors.jpg); 25 | background-position: 100%; 26 | background-size: cover; 27 | 28 | } 29 | 30 | main { 31 | height:100%; 32 | } 33 | 34 | .mybts{ 35 | background-color: #ec660c; 36 | color: white; 37 | } 38 | 39 | .mybts:hover{ 40 | background-color: #ec660c8a; 41 | } 42 | 43 | .landingMain { 44 | width: 100%; 45 | height: 100%; 46 | overflow-x: hidden; 47 | } 48 | 49 | .heading { 50 | 51 | display: flex; 52 | flex-direction: row; 53 | } 54 | 55 | .form-card { 56 | 57 | margin-left: 5%; 58 | height: 300px; 59 | align-items: center; 60 | justify-content: right; 61 | 62 | } 63 | .card { 64 | align-content: center; 65 | color: #ffffff; 66 | font-weight: bolder; 67 | background-color: rgba(255, 255, 255, 0.192); 68 | } 69 | .card-title{ 70 | text-align: center; 71 | } 72 | 73 | html,body,.container { 74 | height:100%; 75 | } 76 | .container { 77 | justify-content: center; 78 | display:table; 79 | width: 100%; 80 | padding: 3% 0 5% 0; 81 | box-sizing: border-box; 82 | } 83 | 84 | .row { 85 | height: 100%; 86 | display: table-row; 87 | } 88 | 89 | .row .no-float { 90 | display: table-cell; 91 | float: none; 92 | } -------------------------------------------------------------------------------- /Modelly/templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Model Maker 9 | 15 | 16 | 21 | 22 | 23 |
24 | 25 |
26 |
27 |
28 |
29 |

Modelly

30 |

31 |

Make Your Models

32 |

33 |

Your one stop destination for the state of the art machine and deep learning models.

34 | 35 |
36 | {% block content %} {% endblock %} 37 |
38 |
39 |
40 |
41 | 42 | 43 | -------------------------------------------------------------------------------- /Modelly/templates/index.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block content %} 3 | 4 |
5 |
6 |
7 | 8 |
9 |
10 |

Welcome!


11 | 12 |
14 |

15 | 16 | 18 |

19 | 20 |
21 | 29 |
30 |
31 |
32 | 33 |
34 | 35 |
36 |
37 |
38 | 39 |
40 | 41 |
42 |
43 |

44 | 45 | 46 | 47 | 48 |
49 |
50 |
51 |
52 |
53 |
54 |