fadzwan commited on
Commit
a100343
·
verified ·
1 Parent(s): f1a0cad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -18
app.py CHANGED
@@ -4,6 +4,7 @@ import pickle
4
  from sklearn.linear_model import LinearRegression
5
  from sklearn.preprocessing import StandardScaler
6
  from sklearn.decomposition import PCA
 
7
 
8
  def load_data():
9
  # Replace this with your actual data loading logic
@@ -29,23 +30,8 @@ def save_model_artifacts(regressor, scaler, pca):
29
  pickle.dump(pca, f, protocol=pickle.HIGHEST_PROTOCOL)
30
 
31
  def predict_slump_app(regressor, scaler, pca):
32
- st.subheader("Enter Concrete Mix Parameters")
33
- cement = st.number_input("Cement (kg/m³)", min_value=0.0, step=1.0)
34
- slag = st.number_input("Slag (kg/m³)", min_value=0.0, step=1.0)
35
- flyash = st.number_input("Fly Ash (kg/m³)", min_value=0.0, step=1.0)
36
- water = st.number_input("Water (kg/m³)", min_value=0.0, step=1.0)
37
- superplasticizer = st.number_input("Superplasticizer (kg/m³)", min_value=0.0, step=0.1)
38
- coarseaggregate = st.number_input("Coarse Aggregate (kg/m³)", min_value=0.0, step=1.0)
39
- fineaggregate = st.number_input("Fine Aggregate (kg/m³)", min_value=0.0, step=1.0)
40
-
41
- if st.button("Predict Slump Strength"):
42
- X_new = np.array([cement, slag, flyash, water, superplasticizer, coarseaggregate, fineaggregate])
43
- X_new = scaler.transform([X_new])
44
- X_new = pca.transform(X_new)
45
- slump_prediction = regressor.predict(X_new)[0]
46
- return slump_prediction
47
- else:
48
- return None
49
 
50
  def main():
51
  st.set_page_config(page_title="Concrete Slump Strength Prediction")
@@ -54,7 +40,7 @@ def main():
54
 
55
  try:
56
  regressor, scaler, pca = load_model_artifacts()
57
- except (FileNotFoundError, UnpicklingError):
58
  X_train, y_train = load_data()
59
  regressor = LinearRegression()
60
  regressor.fit(X_train, y_train)
 
4
  from sklearn.linear_model import LinearRegression
5
  from sklearn.preprocessing import StandardScaler
6
  from sklearn.decomposition import PCA
7
+ import pickle
8
 
9
  def load_data():
10
  # Replace this with your actual data loading logic
 
30
  pickle.dump(pca, f, protocol=pickle.HIGHEST_PROTOCOL)
31
 
32
  def predict_slump_app(regressor, scaler, pca):
33
+ # Your existing code here
34
+ pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
  def main():
37
  st.set_page_config(page_title="Concrete Slump Strength Prediction")
 
40
 
41
  try:
42
  regressor, scaler, pca = load_model_artifacts()
43
+ except (FileNotFoundError, pickle.UnpicklingError):
44
  X_train, y_train = load_data()
45
  regressor = LinearRegression()
46
  regressor.fit(X_train, y_train)