|
import streamlit as st |
|
import joblib |
|
import numpy as np |
|
|
|
|
|
regressor = joblib.load('slump_regressor.pkl') |
|
scaler = joblib.load('scaler.pkl') |
|
|
|
def preprocess_data(X): |
|
|
|
scaler = joblib.load('scaler.pkl') |
|
pca = joblib.load('pca.pkl') |
|
|
|
|
|
if X.shape[1] != 8: |
|
raise ValueError("Input data should have 8 features.") |
|
|
|
|
|
X_scaled = scaler.transform(X) |
|
|
|
|
|
X_pca = pca.transform(X_scaled) |
|
|
|
return X_pca |
|
|
|
def predict_slump_app(): |
|
|
|
cement = st.number_input("Cement (kg/m^3)", min_value=0.0, step=0.1) |
|
blast_furnace_slag = st.number_input("Blast Furnace Slag (kg/m^3)", min_value=0.0, step=0.1) |
|
fly_ash = st.number_input("Fly Ash (kg/m^3)", min_value=0.0, step=0.1) |
|
water = st.number_input("Water (kg/m^3)", min_value=0.0, step=0.1) |
|
superplasticizer = st.number_input("Superplasticizer (kg/m^3)", min_value=0.0, step=0.1) |
|
coarse_aggregate = st.number_input("Coarse Aggregate (kg/m^3)", min_value=0.0, step=0.1) |
|
fine_aggregate = st.number_input("Fine Aggregate (kg/m^3)", min_value=0.0, step=0.1) |
|
flow = st.number_input("FLOW (cm)", min_value=0.0, step=0.1) |
|
|
|
|
|
X = np.array([[cement, blast_furnace_slag, fly_ash, water, superplasticizer, coarse_aggregate, fine_aggregate, flow]]) |
|
|
|
|
|
X_preprocessed = preprocess_data(X) |
|
|
|
|
|
slump_prediction = regressor.predict(X_preprocessed)[0] |
|
|
|
return slump_prediction |
|
|
|
def main(): |
|
st.set_page_config(page_title="Concrete Slump Strength Prediction") |
|
st.title("Concrete Slump Strength Prediction") |
|
st.write("Enter the concrete mix parameters to predict the slump.") |
|
|
|
slump_prediction = predict_slump_app() |
|
st.subheader("Predicted Slump Strength:") |
|
st.write(f"{slump_prediction:.2f} MPA") |
|
|
|
if __name__ == '__main__': |
|
main() |