Update app.py
Browse files
app.py
CHANGED
|
@@ -75,10 +75,6 @@ X_train, X_val, y_train, y_val = train_test_split(X, y, train_size=0.8, random_s
|
|
| 75 |
# Random Forest model
|
| 76 |
random_forest_model = RandomForestClassifier(n_estimators=100, max_depth=16, min_samples_split=10, random_state=RANDOM_STATE).fit(X_train, y_train)
|
| 77 |
|
| 78 |
-
# Model performance
|
| 79 |
-
print(f"Metrics train:\n\tAccuracy score: {accuracy_score(random_forest_model.predict(X_train), y_train):.4f}")
|
| 80 |
-
print(f"Metrics test:\n\tAccuracy score: {accuracy_score(random_forest_model.predict(X_val), y_val):.4f}")
|
| 81 |
-
|
| 82 |
# Make predictions on validation data
|
| 83 |
predictions_random_forest = random_forest_model.predict(X_val)
|
| 84 |
|
|
@@ -96,10 +92,10 @@ from sklearn.ensemble import RandomForestClassifier
|
|
| 96 |
import seaborn as sns
|
| 97 |
|
| 98 |
# Load the data and model
|
| 99 |
-
x_train = pd.read_csv("
|
| 100 |
-
x_val = pd.read_csv("
|
| 101 |
-
y_train = pd.read_csv("
|
| 102 |
-
y_val = pd.read_csv("
|
| 103 |
|
| 104 |
RANDOM_STATE = 55
|
| 105 |
random_forest_model = RandomForestClassifier(
|
|
@@ -110,7 +106,12 @@ random_forest_model = RandomForestClassifier(
|
|
| 110 |
).fit(x_train, y_train)
|
| 111 |
|
| 112 |
# Make predictions
|
| 113 |
-
y_pred = random_forest_model.predict(x_val)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
# Calculate metrics
|
| 116 |
precision = precision_score(y_val, y_pred, average='weighted')
|
|
@@ -298,3 +299,4 @@ iface = gr.Interface(
|
|
| 298 |
|
| 299 |
iface.launch()
|
| 300 |
'gradio deploy'
|
|
|
|
|
|
| 75 |
# Random Forest model
|
| 76 |
random_forest_model = RandomForestClassifier(n_estimators=100, max_depth=16, min_samples_split=10, random_state=RANDOM_STATE).fit(X_train, y_train)
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
# Make predictions on validation data
|
| 79 |
predictions_random_forest = random_forest_model.predict(X_val)
|
| 80 |
|
|
|
|
| 92 |
import seaborn as sns
|
| 93 |
|
| 94 |
# Load the data and model
|
| 95 |
+
x_train = pd.read_csv("X_train.csv")
|
| 96 |
+
x_val = pd.read_csv("X_val.csv")
|
| 97 |
+
y_train = pd.read_csv("y_train.csv")
|
| 98 |
+
y_val = pd.read_csv("y_val.csv")
|
| 99 |
|
| 100 |
RANDOM_STATE = 55
|
| 101 |
random_forest_model = RandomForestClassifier(
|
|
|
|
| 106 |
).fit(x_train, y_train)
|
| 107 |
|
| 108 |
# Make predictions
|
| 109 |
+
y_pred = random_forest_model.predict(x_val.drop(columns=['ID']))
|
| 110 |
+
|
| 111 |
+
# Calculate metrics
|
| 112 |
+
precision = precision_score(y_val, y_pred, average='weighted')
|
| 113 |
+
recall = recall_score(y_val, y_pred, average='weighted')
|
| 114 |
+
accuracy = accuracy_score(y_val, y_pred)
|
| 115 |
|
| 116 |
# Calculate metrics
|
| 117 |
precision = precision_score(y_val, y_pred, average='weighted')
|
|
|
|
| 299 |
|
| 300 |
iface.launch()
|
| 301 |
'gradio deploy'
|
| 302 |
+
|