# -*- coding: utf-8 -*-
"""anrr.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1KIujWJRWQke8gPWWYvIWc4WQN14Mx7XX
"""

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

df=pd.read_csv('C02.csv')
df=df.drop(columns=['Data_source','Unit'])
df['country']=df['CountryShort']+":"+df['CountryLong']
df['Value']=round(df['ValueNumeric'])
df=df.drop(columns=['CountryShort','CountryLong','ValueNumeric'])
df=df.dropna(how='any')
df

from sklearn.preprocessing import LabelEncoder
le1=LabelEncoder()
le2=LabelEncoder()
df['country']=le1.fit_transform(df['country'])
df['Year']=le2.fit_transform(df['Year'])
df

X=df.iloc[:,:-1].values
y=df.iloc[:,-1].values

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, random_state = 0)

import tensorflow as tf

ann = tf.keras.models.Sequential()
ann.add(tf.keras.layers.Dense(units=10, activation='relu'))
ann.add(tf.keras.layers.Dense(units=10, activation='relu'))
ann.add(tf.keras.layers.Dense(units=1))

ann.compile(optimizer = 'adam', loss = 'mean_squared_error')
ann.fit(X_train, y_train, batch_size=32, epochs=1000)

y_pred = ann.predict(X_test)
y_pred=np.round(y_pred)
np.set_printoptions(precision=2)
print(np.concatenate((y_pred.reshape(len(y_pred),1), y_test.reshape(len(y_test),1)),1))
# -*- coding: utf-8 -*-
"""anrr.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1KIujWJRWQke8gPWWYvIWc4WQN14Mx7XX
"""

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

df=pd.read_csv('C02.csv')
df=df.drop(columns=['Data_source','Unit'])
df['country']=df['CountryShort']+":"+df['CountryLong']
df['Value']=round(df['ValueNumeric'])
df=df.drop(columns=['CountryShort','CountryLong','ValueNumeric'])
df=df.dropna(how='any')
df

from sklearn.preprocessing import LabelEncoder
le1=LabelEncoder()
le2=LabelEncoder()
df['country']=le1.fit_transform(df['country'])
df['Year']=le2.fit_transform(df['Year'])
df

X=df.iloc[:,:-1].values
y=df.iloc[:,-1].values

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, random_state = 0)

import tensorflow as tf

ann = tf.keras.models.Sequential()
ann.add(tf.keras.layers.Dense(units=10, activation='relu'))
ann.add(tf.keras.layers.Dense(units=10, activation='relu'))
ann.add(tf.keras.layers.Dense(units=1))

ann.compile(optimizer = 'adam', loss = 'mean_squared_error')
ann.fit(X_train, y_train, batch_size=32, epochs=1000)

y_pred = ann.predict(X_test)
y_pred=np.round(y_pred)
np.set_printoptions(precision=2)
print(np.concatenate((y_pred.reshape(len(y_pred),1), y_test.reshape(len(y_test),1)),1))
# -*- coding: utf-8 -*- anrr.ipynb  Automatically generated by Colaboratory.  Original file is located at     https://colab.research.google.com/drive/1KIujWJRWQke8gPWWYvIWc4WQN14Mx7XX