Tarun Reddy's other Models Reports

Major Concepts

 

Sign-Up/Login to access Several ML Models and also Deploy & Monetize your own ML solutions for free

Models Home » Domain Usecases » Banking and Financial Services » Currency Exchange Rate Prediction

Currency Exchange Rate Prediction

Models Status

Model Overview

 

Money exchange is one of the greatest monetary business sectors. As of now, 1 United States dollar is identical to 74.26 Indian rupees. Many components influence trade rates like monetary, political and surprisingly psychological factors. The expectation of the money conversion scale is a troublesome issue, so in this usecase, I will walk you through the conversion of currency exchange rate with Machine Learning using Python.
Currency exchange rate prediction is the regression problem in machine learning. There are changes in return rates each day that influence the pay of an individual, a business and can even influence the economy of a country. Subsequently, foreseeing the exchange rates can assist a person with welling a country from various perspectives.
There are so many machine learning algorithms that we can use to predict future currency exchange rates. We can also use artificial neural networks for this task. In the usecase, I will take you through the task of currency exchange rate prediction with machine learning using Python.

To predict the cash conversion rate with machine learning, we first need to get the most appropriate data for this undertaking. To get a dataset for this assignment simply follow the means referenced beneath:
DATASET LINKhttps://in.finance.yahoo.com/quote/INR%3DX?p=INR%3DX&.tsrc=fin-srch

DATASET DESCRIPTION:
1.date:- year and date

2.open:- the opening value of the stock at that day
3.high:- the highest value of the stock at that day
4.low:- the lowest value of the stock at that day
5.close:- closing of stock value
6.volume and Adj Close

MODEL ACCURACY: 96

Let us now start the usecase by importing required libraries.

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from seaborn import regression
sns.set()
plt.style.use('seaborn-whitegrid')
import pickle

Now let us import the dataset and check the data.


data = pd.read_csv("E://medical//inr.csv")
print(data.head())




print(data.tail())


we can see there are 261 rows of data of currency exchange 
In this dataset, the values in the “Close” column are the target values that we need to predict. So let’s take a closer look at these values:


plt.figure(figsize=(10, 4))
plt.title("INR - USD Exchange Rate")
plt.xlabel("Date")
plt.ylabel("Close")
plt.plot(data["Close"])
plt.show()



Now let’s have a look at the correlation between the features before training the currency exchange rate prediction model:

print(data.corr())
sns.heatmap(data.corr())
plt.show()



Now the next step is to prepare the dataset by storing the most relevant features in the variable x and storing the target column in the variable y:

x = data[["Open", "High", "Low"]]
y = data["Close"]
x = x.to_numpy()
y = y.to_numpy()
y = y.reshape(-1, 1)

Now let’s split the dataset and train a currency exchange prediction model using the Decision Tree Regression model using Python:

from sklearn.model_selection import train_test_split
xtrain, xtest, ytrain, ytest = train_test_split(x, y, test_size=0.2, random_state=42)

from sklearn.tree import DecisionTreeRegressor
model = DecisionTreeRegressor()
model.fit(xtrain, ytrain)
ypred = model.predict(xtest)

Now let’s have a look at the predicted values of currency exchange rates of Indian Rupees for the next 5 days:

data = pd.DataFrame(data={"Predicted Rate": ypred.flatten()})
print(data.head())


Let us now evaluate the model.

r2 = r2_score(ypred,ytest)
mean = mean_absolute_error(ypred,ytest)
print(r2,mean)




0 comments