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 df_strength=pd.read_csv("data_strength11.csv") import random 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.15, random_state=2) clf = xgb.XGBRegressor(learning_rate=0.1788, max_depth=27, subsample=0.5146, n_estimators=100,seed = 40) clf.fit(x_train, y_train) import gradio as gr def CirConStr(d, s, fyv, psv, fc): # Turning the arguments into a numpy array x = np.array([d, s, fyv, psv, fc]) prediction = clf.predict(x.reshape(1, -1)) return prediction inputs = [ gr.inputs.Number(label="Diameter of spiral stirrups (d, unit: mm)"), gr.inputs.Number(label="Spacing of stirrups (s, unit: mm)"), gr.inputs.Number(label="Yield strength of spiral stirrups (fyv, unit: MPa)"), gr.inputs.Number(label="Volumetric ratio of spiral stirrups(psv, unit: %)"), gr.inputs.Number(label="Compressive strength of concrete (fc, unit: MPa)") ] outputs = gr.outputs.Textbox(label="Estimated Compressive Strength (fcc, unit: MPa)") app = gr.Interface(fn=CirConStr, inputs=inputs, outputs=outputs, description="Compressive strength estimation for circular concrete column confined by spiral stirrups") app.launch()