I want to ues python cord in rapidminer.
So, I would like to conduct a test using the dataset in sklearn.
However, I confirmed that an error occurred in the code that loaded the dataset.
Is there anything I need to configure to use python's sklearn?
I will tell you the code I wrote and the error message.
-Erroe meggage -
Execution of Python script failed
The execution of the python script failed.
Please check your Python script:KeyError: 192
(script, line11)
- Python Cord -
import matplotlib.pyplot as plt
import pandas as pd
from sklearn import datasets
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error, r2_score
def rm_main():
house = datasets.fetch_california_housing()
X = house.data
y = house.target
X_train, X_test, y_train, y_test = train_test_split(house.data, house.target, test_size = 0.2)
estimator = RandomForestRegressor(n_estimators=100)
estimator.fit(X_train, y_train)
prediction = estimator.predict(X_test)
mse = mean_squared_error(y_test, prediction)
r_squared = r2_score(y_test, prediction)
print(f"MSE: {mse}")
print(f"R-squared: {r_squared}")
if __name__ == "__main__":
main()
line11 :
house = datasets.fetch_california_housing()