Spaces:
Sleeping
Sleeping
Commit ·
ceb185b
1
Parent(s): 54fbf17
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import xgboost as xgb
|
| 4 |
+
import pandas as pd
|
| 5 |
+
|
| 6 |
+
import random
|
| 7 |
+
import numpy as np
|
| 8 |
+
import pandas as pd
|
| 9 |
+
from sklearn.model_selection import train_test_split,cross_val_score
|
| 10 |
+
from sklearn.ensemble import RandomForestClassifier,RandomForestRegressor
|
| 11 |
+
from sklearn.metrics import classification_report,confusion_matrix,accuracy_score
|
| 12 |
+
from sklearn.neighbors import KNeighborsClassifier,KNeighborsRegressor
|
| 13 |
+
from sklearn.svm import SVC,SVR
|
| 14 |
+
from sklearn import datasets
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
df_strength=pd.read_csv("datasetnew1.csv")
|
| 20 |
+
|
| 21 |
+
import random
|
| 22 |
+
|
| 23 |
+
x_strength=df_strength.iloc[:,:-1]
|
| 24 |
+
y_strength=df_strength.iloc[:,-1]
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
x_strength=df_strength.iloc[:,:-1]
|
| 28 |
+
y_strength=df_strength.iloc[:,-1]
|
| 29 |
+
from sklearn.model_selection import train_test_split
|
| 30 |
+
x_train, x_test, y_train, y_test=train_test_split(x_strength,y_strength, test_size=0.2, random_state=20)
|
| 31 |
+
|
| 32 |
+
clf = xgb.XGBRegressor(colsample_bytree= 1.0, learning_rate= 0.06596, max_depth= 36, min_child_weight= 1.0, n_estimators= 750, subsample= 0.2)
|
| 33 |
+
clf.fit(x_train, y_train)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
import gradio as gr
|
| 39 |
+
|
| 40 |
+
def OPS_LWAC(OPC, SCM_FA, SCM_SF, w_b, FA, CA, OPS, SP, T):
|
| 41 |
+
# Turning the arguments into a numpy array
|
| 42 |
+
x = np.array([OPC, SCM_FA, SCM_SF, w_b, FA, CA, OPS, SP, T])
|
| 43 |
+
prediction = clf.predict(x.reshape(1, -1))
|
| 44 |
+
return prediction
|
| 45 |
+
|
| 46 |
+
inputs = [
|
| 47 |
+
gr.inputs.Number(label="cement content (OPC, unit: kg/m3)"),
|
| 48 |
+
gr.inputs.Number(label="fly ash content (SCM_FA, unit: kg/m3)"),
|
| 49 |
+
gr.inputs.Number(label="silica fume content (SCM_SF, unit: kg/m3)"),
|
| 50 |
+
gr.inputs.Number(label="water to binder ratio (w_b, unit: -)"),
|
| 51 |
+
gr.inputs.Number(label="fine aggregate content (FA, unit: kg/m3)"),
|
| 52 |
+
gr.inputs.Number(label="coarse aggregate content (CA, unit: kg/m3)"),
|
| 53 |
+
gr.inputs.Number(label="oil palm shell content (OPS, unit: kg/m3)"),
|
| 54 |
+
gr.inputs.Number(label="superplasticizer content (SP, unit: kg/m3)"),
|
| 55 |
+
gr.inputs.Number(label="curing time (T, unit: d)")
|
| 56 |
+
]
|
| 57 |
+
outputs = gr.outputs.Textbox(label="Estimated compressive strength of OPS-based LWAC (tu, unit: MPa)")
|
| 58 |
+
|
| 59 |
+
app = gr.Interface(fn=OPS_LWAC, inputs=inputs, outputs=outputs, description="Estimation of compressive strength of OPS-based lightweight concrete")
|
| 60 |
+
app.launch()
|