Dilanka Kasun commited on
Commit
41dd585
·
1 Parent(s): 442eec5
Files changed (2) hide show
  1. multipliers.csv +0 -0
  2. run.py +16 -14
multipliers.csv ADDED
The diff for this file is too large to render. See raw diff
 
run.py CHANGED
@@ -27,7 +27,9 @@ labels = dbscan.fit_predict(features_normalized)
27
  data['labels'] = labels
28
 
29
  # Split the data into training and testing sets for regression
30
- X_train, X_test, y_train, y_test = train_test_split(features_normalized, labels, test_size=0.2, random_state=42)
 
 
31
 
32
  model = keras.Sequential([
33
  layers.Dense(128, activation='relu', input_shape=(1,)),
@@ -43,19 +45,19 @@ model.compile(optimizer='adam', loss='mean_squared_error', metrics=['mae'])
43
  # Train the updated model
44
  model.fit(X_train, y_train, epochs=100, batch_size=32, validation_split=0.2)
45
 
46
- # Streamlit App
47
- st.title('Predict Real Values with Streamlit')
 
 
 
48
 
49
- # Input for new data
50
- st.sidebar.title('New Data')
51
- new_data_input = st.sidebar.text_area('Enter new data (comma-separated)', '2.8, 6.55, 1.1, 1.06, 1.88, 1.89, 2.36, 8.23, 1.76, 1.68, 1.44, 1.35, 2.56, 1.49, 3.03, 1.82, 1.69, 7.81, 3.8')
52
 
53
- # Convert input to numpy array
54
- new_data = np.array([float(x.strip()) for x in new_data_input.split(',')])
 
55
 
56
- # Predict real values for new_data
57
- new_data_normalized = scaler.transform(new_data.reshape(-1, 1))
58
- real_value_predictions = model.predict(new_data_normalized)
59
-
60
- # Display predictions
61
- st.write("Predicted Real Values for New Data:", real_value_predictions.flatten())
 
27
  data['labels'] = labels
28
 
29
  # Split the data into training and testing sets for regression
30
+ X_train, X_test, y_train, y_test = train_test_split(
31
+ features_normalized, labels, test_size=0.2, random_state=42
32
+ )
33
 
34
  model = keras.Sequential([
35
  layers.Dense(128, activation='relu', input_shape=(1,)),
 
45
  # Train the updated model
46
  model.fit(X_train, y_train, epochs=100, batch_size=32, validation_split=0.2)
47
 
48
+ # Function to predict and display results
49
+ def predict_values(input_data):
50
+ new_data_normalized = scaler.transform(np.array(input_data).reshape(-1, 1))
51
+ real_value_predictions = model.predict(new_data_normalized)
52
+ return real_value_predictions.flatten()
53
 
54
+ # Streamlit UI
55
+ st.title('Prediction App')
 
56
 
57
+ st.write("Enter new data:")
58
+ input_data = st.text_input("Enter comma-separated values:", value="2.8, 6.55, 1.1, 1.06, 1.88, 1.89, 2.36, 8.23, 1.76, 1.68, 1.44, 1.35, 2.56, 1.49, 3.03, 1.82, 1.69, 7.81, 3.8")
59
+ input_data = [float(x.strip()) for x in input_data.split(',')]
60
 
61
+ if st.button('Predict'):
62
+ predictions = predict_values(input_data)
63
+ st.write("Predicted Real Values for New Data:", predictions)