Spaces:
Sleeping
Sleeping
File size: 2,589 Bytes
ceb185b f2f18d0 ceb185b 141a52c ceb185b f2f18d0 ceb185b f2f18d0 ceb185b 1f1a711 e1eaac2 f2f18d0 ceb185b f2f18d0 85e6cc3 831127d 85e6cc3 831127d ceb185b f2f18d0 ceb185b 831127d ceb185b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 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 55 56 57 58 59 60 61 62 63 64 65 66 67 |
import numpy as np
import pandas as pd
import xgboost as xgb
import pandas as pd
import random
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split,cross_val_score
from sklearn.ensemble import RandomForestClassifier,RandomForestRegressor
from sklearn.metrics import classification_report,confusion_matrix,accuracy_score
from sklearn.neighbors import KNeighborsClassifier,KNeighborsRegressor
from sklearn.svm import SVC,SVR
from sklearn import datasets
from ngboost import NGBRegressor
from sklearn.tree import DecisionTreeRegressor
df_strength=pd.read_csv("OPS_LWAC.csv")
x_strength=df_strength.iloc[:,:-1]
y_strength=df_strength.iloc[:,-1]
x_strength=df_strength.iloc[:,:-1]
y_strength=df_strength.iloc[:,-1]
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test=train_test_split(x_strength,y_strength, test_size=0.25, random_state=20)
learner = DecisionTreeRegressor(criterion='friedman_mse', max_depth=3)
clf = NGBRegressor (learning_rate= 0.0708, minibatch_frac= 0.647, n_estimators= 548, Base=learner)
clf.fit(x_train, y_train)
import gradio as gr
def OPS_LWAC(OPC, SCM_FA, SCM_SF, w_b, FA, CA, OPS, SP, T):
# Turning the arguments into a numpy array
x = np.array([OPC, SCM_FA, SCM_SF, w_b, FA, CA, OPS, SP, T])
prediction = clf.pred_dist(x.reshape(1, -1))
aa=prediction.params["loc"].item()
#value1 = aa[0]
bb=prediction.params["scale"].item()
#value2 = bb[0]
#prediction = clf.predict(x.reshape(1, -1))
#-3*y_dists.params["scale"]+y_dists.params["loc"]
result_string = "[CS: {:.3f}; σ: {:.3f}]".format(aa, bb)
return result_string
#return [aa, bb]
inputs = [
gr.inputs.Number(label="cement content (OPC, unit: kg/m3)"),
gr.inputs.Number(label="fly ash content (SCM_FA, unit: kg/m3)"),
gr.inputs.Number(label="silica fume content (SCM_SF, unit: kg/m3)"),
gr.inputs.Number(label="water to cementitious material ratio (w_b, unit: -)"),
gr.inputs.Number(label="fine aggregate content (FA, unit: kg/m3)"),
gr.inputs.Number(label="coarse aggregate content (CA, unit: kg/m3)"),
gr.inputs.Number(label="oil palm shell content (OPS, unit: kg/m3)"),
gr.inputs.Number(label="superplasticizer content (SP, unit: kg/m3)"),
gr.inputs.Number(label="curing time (T, unit: d)")
]
outputs = gr.outputs.Textbox(label="Estimated mean prediction and σ value (unit: MPa)")
app = gr.Interface(fn=OPS_LWAC, inputs=inputs, outputs=outputs, description="Estimation of compressive strength of OPS-based lightweight concrete")
app.launch() |