Skip to content
Untitled Python workspace
# Start coding here... import pandas as pd
from sklearn.svm import SVR
# Load the data
df = pd.read_csv("oil_prices.csv")
# Select the features and target variable
X = df[['GDP_per_capita', 'gold_price', 'NASDAQ', 'world_trade']]
y = df['oil_price']
# Split the data into training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Build the model
model = SVR()
model.fit(X_train, y_train)
# Evaluate the model on the test set
test_predictions = model.predict(X_test)
test_mse = mean_squared_error(y_test, test_predictions)
print(f"Test MSE: {test_mse:.2f}")
# Predict the oil price for next month
gdp_per_capita = x[0] # Replace with actual value for GDP per capita
gold_price = x[1] # Replace with actual value for gold price
nasdaq = x[2] # Replace with actual value for NASDAQ index
world_trade = x[3] # Replace with actual value for total world trade value
prediction = model.predict([[gdp_per_capita, gold_price, nasdaq, world_trade]])
import pandas as pd
from sklearn.svm import SVR
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error
# Load the data
df = pd.read_csv("path/to/oil_prices.csv")
# Select the features and target variable
X = df[['GDP_per_capita', 'gold_price', 'NASDAQ', 'world_trade']]
y = df['oil_price']
# Split the data into training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Build the model
model = SVR()
model.fit(X_train, y_train)
# Evaluate the model on the test set
test_predictions = model.predict(X_test)
test_mse = mean_squared_error(y_test, test_predictions)
print(f"Test MSE: {test_mse:.2f}")
# Predict the oil price for next month
gdp_per_capita = x[0] # Replace with actual value for GDP per capita
gold_price = x[1] # Replace with actual value for gold price
nasdaq = x[2] # Replace with actual value for NASDAQ index
world_trade = x[3] # Replace with actual value for total world trade value
prediction = model.predict([[gdp_per_capita, gold_price, nasdaq, world_trade]])