|
import streamlit as st |
|
from sklearn.neural_network import MLPClassifier |
|
import pandas as pd |
|
from types import NoneType |
|
|
|
def process(data): |
|
if type(data[0]) == NoneType or type(data[1]) == NoneType: |
|
st.info('Please Upload Data') |
|
return None |
|
if 'object' in list(data[0].dtypes) or 'object' in list(data[1].dtypes): |
|
st.info('Please Upload Numerica Data.') |
|
return None |
|
x_train = data[0].iloc[:,:-1] |
|
y_train = data[0].iloc[:,-1] |
|
|
|
x_test = data[1].iloc[:,:x_train.shape[1]] |
|
|
|
|
|
|
|
if len(x_train.columns) != len(x_test.columns): |
|
st.info('Training and testing datasets have different column number, cannot perform classification.') |
|
return None |
|
|
|
clf = MLPClassifier(random_state=1, max_iter=300).fit(x_train, y_train) |
|
pred = clf.predict(x_test) |
|
|
|
x_test[data[0].columns[-1]] = pred |
|
|
|
return x_test |