online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
# Import libraries import numpy as np import matplotlib.pyplot as plt from sklearn.ensemble import RandomForestRegressor from sklearn.model_selection import train_test_split from sklearn.metrics import mean_squared_error, r2_score # Generate synthetic regression data np.random.seed(42) X = np.linspace(0, 10, 200).reshape(-1, 1) y = 3 * X.squeeze()**2 + 5 * X.squeeze() + 10 + np.random.randn(200) * 10 # Split the dataset X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=0.2, random_state=42 ) # Create Random Forest Regressor rf_model = RandomForestRegressor( n_estimators=200, max_depth=10, min_samples_split=5, random_state=42 ) # Train the model rf_model.fit(X_train, y_train) # Predict on test data y_pred = rf_model.predict(X_test) # Model evaluation print("Mean Squared Error:", mean_squared_error(y_test, y_pred)) print("R2 Score:", r2_score(y_test, y_pred)) # Sort values for smooth plotting sorted_idx = X_test.squeeze().argsort() # Plot actual vs predicted values plt.figure() plt.scatter(X_test, y_test) plt.plot(X_test[sorted_idx], y_pred[sorted_idx]) plt.xlabel("Input Feature (X)") plt.ylabel("Target Value (y)") plt.title("Random Forest Regression") plt.show()

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue