SlideShare a Scribd company logo
*USING 'https://raw.githubusercontent.com/BeeDrHU/Introduction-to-Python-CSPC-323-
/main/sales_forecast.csv'
please fix the errors for the RNN using python so the code can run without errors, Thank you*
##Defining Function to Build Multivariate Data Structure
def multivariate_data(dataset, target, start_index, end_index, history_size,
target_size, step, single_step=False):
data = []
labels = []
start_index = start_index + history_size
if end_index is None:
end_index = len(dataset) - target_size
for i in range(start_index, end_index):
indices = range(i-history_size, i, step)
data.append(dataset[indices])
if single_step:
labels.append(target[i+target_size])
else:
labels.append(target[i:i+target_size])
return np.array(data), np.array(labels)
##Define the Multi-step Plotting Structure
def multi_step_plot(history, true_future, prediction):
plt.figure(figsize=(12, 6))
num_in = create_time_steps(len(history))
num_out = len(true_future)
plt.plot(num_in, np.array(history[:, 1]), label='History')
plt.plot(np.arange(num_out)/STEP, np.array(true_future), 'bo',
label='True Future')
if prediction.any():
plt.plot(np.arange(num_out)/STEP, np.array(prediction), 'ro',
label='Predicted Future')
plt.legend(loc='upper left')
plt.show()
##Define Function to Plot training and Validation over Time
def plot_train_history(history, title):
loss = history.history['loss']
val_loss = history.history['val_loss']
epochs = range(len(loss))
plt.figure()
plt.plot(epochs, loss, 'b', label='Training loss')
plt.plot(epochs, val_loss, 'r', label='Validation loss')
plt.title(title)
plt.legend()
plt.show()
##How far into the past do you want the model to see?
past_history=
##How far into the future do you want the model to see?
future_target=
##
STEP=
df_val = len(dataset) - past_history - future_target
x_train_multi, y_train_multi = multivariate_data(dataset, dataset[:, 1], 0,
df_train, past_history,
future_target, STEP)
x_val_multi, y_val_multi = multivariate_data(dataset, dataset[:, 1],
df_train, df_val, past_history,
future_target, STEP)
##Define Constants
BATCH_SIZE =
BUFFER_SIZE =
EPOCHS =
EVALUATION_INTERVAL =
##Adding Layers Due to Complexity
train_data_multi = tf.data.Dataset.from_tensor_slices(())
train_data_multi = train_data_multi.cache().shuffle().batch().repeat()
val_data_multi = tf.data.Dataset.from_tensor_slices(())
val_data_multi = val_data_multi.batch().repeat()
multi_step_model = tf.keras.models.Sequential()
multi_step_model.add(tf.keras.layers.LSTM())
multi_step_model.add(tf.keras.layers.LSTM())
multi_step_model.add(tf.keras.layers.Dense(72))
multi_step_model.compile(optimizer=tf.keras.optimizers.RMSprop(clipvalue=1.0), loss='mae')
##Train the Model
multi_step_history = multi_step_model.fit(train_data_multi, epochs=,
steps_per_epoch=,
validation_data=,
validation_steps=50)
##Predict Future Data
for x, y in .take(3):
multi_step_plot(x[0], y[0], .predict(x)[0])
#Evaluate the model on the test data
test_data_multi = tf.data.Dataset.from_tensor_slices())
test_data_multi = test_data_multi.batch()
# Define the number of steps in the test dataset
steps = len()
mae_values = []
for x, y in :
x_val, y_val= x[:, :-1], y[:,-1]
#Make predictions using the model
= .predict(x_val, steps=steps)
#Compute MAE
mae = tf.keras.metrics.mean_absolute_error().numpy()
mae_values.append(mae)
overall_mae = np.mean(mae_values)
print('Overall MAE:', overall_mae)

More Related Content

Similar to USING httpsraw.githubusercontent.comBeeDrHUIntroduction-to-Py.pdf

Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...
Miguel González-Fierro
 
[부스트캠프 Tech Talk] 진명훈_datasets로 협업하기
[부스트캠프 Tech Talk] 진명훈_datasets로 협업하기[부스트캠프 Tech Talk] 진명훈_datasets로 협업하기
[부스트캠프 Tech Talk] 진명훈_datasets로 협업하기
CONNECT FOUNDATION
 
Stat Design3 18 09
Stat Design3 18 09Stat Design3 18 09
Stat Design3 18 09stat
 
An Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAdam Getchell
 
Working with Graphs _python.pptx
Working with Graphs _python.pptxWorking with Graphs _python.pptx
Working with Graphs _python.pptx
MrPrathapG
 
DN 2017 | Multi-Paradigm Data Science - On the many dimensions of Knowledge D...
DN 2017 | Multi-Paradigm Data Science - On the many dimensions of Knowledge D...DN 2017 | Multi-Paradigm Data Science - On the many dimensions of Knowledge D...
DN 2017 | Multi-Paradigm Data Science - On the many dimensions of Knowledge D...
Dataconomy Media
 
Tom Peters, Software Engineer, Ufora at MLconf ATL 2016
Tom Peters, Software Engineer, Ufora at MLconf ATL 2016Tom Peters, Software Engineer, Ufora at MLconf ATL 2016
Tom Peters, Software Engineer, Ufora at MLconf ATL 2016
MLconf
 
ML-Ops how to bring your data science to production
ML-Ops  how to bring your data science to productionML-Ops  how to bring your data science to production
ML-Ops how to bring your data science to production
Herman Wu
 
Benchy: Lightweight framework for Performance Benchmarks
Benchy: Lightweight framework for Performance Benchmarks Benchy: Lightweight framework for Performance Benchmarks
Benchy: Lightweight framework for Performance Benchmarks
Marcel Caraciolo
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Remy Sharp
 
Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02PL dream
 
The Function, the Context, and the Data—Enabling ML Ops at Stitch Fix
The Function, the Context, and the Data—Enabling ML Ops at Stitch FixThe Function, the Context, and the Data—Enabling ML Ops at Stitch Fix
The Function, the Context, and the Data—Enabling ML Ops at Stitch Fix
Databricks
 
Pres_python_talakhoury_26_09_2023.pdf
Pres_python_talakhoury_26_09_2023.pdfPres_python_talakhoury_26_09_2023.pdf
Pres_python_talakhoury_26_09_2023.pdf
RamziFeghali
 
Using an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfUsing an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdf
giriraj65
 
Python for R developers and data scientists
Python for R developers and data scientistsPython for R developers and data scientists
Python for R developers and data scientists
Lambda Tree
 
Feature Engineering in NLP.pdf
Feature Engineering in NLP.pdfFeature Engineering in NLP.pdf
Feature Engineering in NLP.pdf
bilaje4244prolugcom
 
Here is my current code- I need help visualizing my data using Python-.docx
Here is my current code- I need help visualizing my data using Python-.docxHere is my current code- I need help visualizing my data using Python-.docx
Here is my current code- I need help visualizing my data using Python-.docx
Juliang56Parsonso
 
CARTO en 5 Pasos: del Dato a la Toma de Decisiones [CARTO]
CARTO en 5 Pasos: del Dato a la Toma de Decisiones [CARTO]CARTO en 5 Pasos: del Dato a la Toma de Decisiones [CARTO]
CARTO en 5 Pasos: del Dato a la Toma de Decisiones [CARTO]
CARTO
 
Silicon valleycodecamp2013
Silicon valleycodecamp2013Silicon valleycodecamp2013
Silicon valleycodecamp2013
Sanjeev Mishra
 

Similar to USING httpsraw.githubusercontent.comBeeDrHUIntroduction-to-Py.pdf (20)

Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...
 
[부스트캠프 Tech Talk] 진명훈_datasets로 협업하기
[부스트캠프 Tech Talk] 진명훈_datasets로 협업하기[부스트캠프 Tech Talk] 진명훈_datasets로 협업하기
[부스트캠프 Tech Talk] 진명훈_datasets로 협업하기
 
Stat Design3 18 09
Stat Design3 18 09Stat Design3 18 09
Stat Design3 18 09
 
An Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional Programming
 
Working with Graphs _python.pptx
Working with Graphs _python.pptxWorking with Graphs _python.pptx
Working with Graphs _python.pptx
 
ELAVARASAN.pdf
ELAVARASAN.pdfELAVARASAN.pdf
ELAVARASAN.pdf
 
DN 2017 | Multi-Paradigm Data Science - On the many dimensions of Knowledge D...
DN 2017 | Multi-Paradigm Data Science - On the many dimensions of Knowledge D...DN 2017 | Multi-Paradigm Data Science - On the many dimensions of Knowledge D...
DN 2017 | Multi-Paradigm Data Science - On the many dimensions of Knowledge D...
 
Tom Peters, Software Engineer, Ufora at MLconf ATL 2016
Tom Peters, Software Engineer, Ufora at MLconf ATL 2016Tom Peters, Software Engineer, Ufora at MLconf ATL 2016
Tom Peters, Software Engineer, Ufora at MLconf ATL 2016
 
ML-Ops how to bring your data science to production
ML-Ops  how to bring your data science to productionML-Ops  how to bring your data science to production
ML-Ops how to bring your data science to production
 
Benchy: Lightweight framework for Performance Benchmarks
Benchy: Lightweight framework for Performance Benchmarks Benchy: Lightweight framework for Performance Benchmarks
Benchy: Lightweight framework for Performance Benchmarks
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)
 
Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02
 
The Function, the Context, and the Data—Enabling ML Ops at Stitch Fix
The Function, the Context, and the Data—Enabling ML Ops at Stitch FixThe Function, the Context, and the Data—Enabling ML Ops at Stitch Fix
The Function, the Context, and the Data—Enabling ML Ops at Stitch Fix
 
Pres_python_talakhoury_26_09_2023.pdf
Pres_python_talakhoury_26_09_2023.pdfPres_python_talakhoury_26_09_2023.pdf
Pres_python_talakhoury_26_09_2023.pdf
 
Using an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfUsing an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdf
 
Python for R developers and data scientists
Python for R developers and data scientistsPython for R developers and data scientists
Python for R developers and data scientists
 
Feature Engineering in NLP.pdf
Feature Engineering in NLP.pdfFeature Engineering in NLP.pdf
Feature Engineering in NLP.pdf
 
Here is my current code- I need help visualizing my data using Python-.docx
Here is my current code- I need help visualizing my data using Python-.docxHere is my current code- I need help visualizing my data using Python-.docx
Here is my current code- I need help visualizing my data using Python-.docx
 
CARTO en 5 Pasos: del Dato a la Toma de Decisiones [CARTO]
CARTO en 5 Pasos: del Dato a la Toma de Decisiones [CARTO]CARTO en 5 Pasos: del Dato a la Toma de Decisiones [CARTO]
CARTO en 5 Pasos: del Dato a la Toma de Decisiones [CARTO]
 
Silicon valleycodecamp2013
Silicon valleycodecamp2013Silicon valleycodecamp2013
Silicon valleycodecamp2013
 

More from adonisjpr

Una mujer de 36 a�os que se someti� a un trasplante de ri��n hace 2 .pdf
Una mujer de 36 a�os que se someti� a un trasplante de ri��n hace 2 .pdfUna mujer de 36 a�os que se someti� a un trasplante de ri��n hace 2 .pdf
Una mujer de 36 a�os que se someti� a un trasplante de ri��n hace 2 .pdf
adonisjpr
 
Una empresa tiene un ciclo operativo de 120 d�as, un per�odo promedi.pdf
Una empresa tiene un ciclo operativo de 120 d�as, un per�odo promedi.pdfUna empresa tiene un ciclo operativo de 120 d�as, un per�odo promedi.pdf
Una empresa tiene un ciclo operativo de 120 d�as, un per�odo promedi.pdf
adonisjpr
 
Una empresa pag� por �ltima vez un dividendo de �3. Si el rendimient.pdf
Una empresa pag� por �ltima vez un dividendo de �3. Si el rendimient.pdfUna empresa pag� por �ltima vez un dividendo de �3. Si el rendimient.pdf
Una empresa pag� por �ltima vez un dividendo de �3. Si el rendimient.pdf
adonisjpr
 
Una cartera eficiente es una combinaci�n de activos que 0 1 pun.pdf
Una cartera eficiente es una combinaci�n de activos que 0  1 pun.pdfUna cartera eficiente es una combinaci�n de activos que 0  1 pun.pdf
Una cartera eficiente es una combinaci�n de activos que 0 1 pun.pdf
adonisjpr
 
Un objetivo a corto plazo esOpci�n multiple A) una meta espec.pdf
Un objetivo a corto plazo esOpci�n multiple A) una meta espec.pdfUn objetivo a corto plazo esOpci�n multiple A) una meta espec.pdf
Un objetivo a corto plazo esOpci�n multiple A) una meta espec.pdf
adonisjpr
 
Tyco International, una empresa de fabricaci�n, demand� a su ex dire.pdf
Tyco International, una empresa de fabricaci�n, demand� a su ex dire.pdfTyco International, una empresa de fabricaci�n, demand� a su ex dire.pdf
Tyco International, una empresa de fabricaci�n, demand� a su ex dire.pdf
adonisjpr
 
Un informe de an�lisis de estados financieros no incluye A) una dec.pdf
Un informe de an�lisis de estados financieros no incluye A) una dec.pdfUn informe de an�lisis de estados financieros no incluye A) una dec.pdf
Un informe de an�lisis de estados financieros no incluye A) una dec.pdf
adonisjpr
 
ubat 2015te Hazine 4 78lik 2044 alt aylk bileik vadeye kadar 2,8.pdf
ubat 2015te Hazine 4 78lik 2044 alt aylk bileik vadeye kadar 2,8.pdfubat 2015te Hazine 4 78lik 2044 alt aylk bileik vadeye kadar 2,8.pdf
ubat 2015te Hazine 4 78lik 2044 alt aylk bileik vadeye kadar 2,8.pdf
adonisjpr
 
Two categories of attackers include hacktivists and state actors. .pdf
Two categories of attackers include hacktivists and state actors. .pdfTwo categories of attackers include hacktivists and state actors. .pdf
Two categories of attackers include hacktivists and state actors. .pdf
adonisjpr
 
Twitter, el popular sitio de microblogs, se ha enfrentado a graves c.pdf
Twitter, el popular sitio de microblogs, se ha enfrentado a graves c.pdfTwitter, el popular sitio de microblogs, se ha enfrentado a graves c.pdf
Twitter, el popular sitio de microblogs, se ha enfrentado a graves c.pdf
adonisjpr
 
Turner, Roth y Lowe son socios que comparten ingresos y p�rdidas en .pdf
Turner, Roth y Lowe son socios que comparten ingresos y p�rdidas en .pdfTurner, Roth y Lowe son socios que comparten ingresos y p�rdidas en .pdf
Turner, Roth y Lowe son socios que comparten ingresos y p�rdidas en .pdf
adonisjpr
 
Uber - Bir Startupn K�kenleri ve lk G�nleriDava M�terileri ele.pdf
Uber - Bir Startupn K�kenleri ve lk G�nleriDava M�terileri ele.pdfUber - Bir Startupn K�kenleri ve lk G�nleriDava M�terileri ele.pdf
Uber - Bir Startupn K�kenleri ve lk G�nleriDava M�terileri ele.pdf
adonisjpr
 
Trilogy Enterprises Inc. de Austin, Texas, es una empresa de softwar.pdf
Trilogy Enterprises Inc. de Austin, Texas, es una empresa de softwar.pdfTrilogy Enterprises Inc. de Austin, Texas, es una empresa de softwar.pdf
Trilogy Enterprises Inc. de Austin, Texas, es una empresa de softwar.pdf
adonisjpr
 
Transforming Data - Creating a Data Set Creating a JOIN between two .pdf
Transforming Data - Creating a Data Set Creating a JOIN between two .pdfTransforming Data - Creating a Data Set Creating a JOIN between two .pdf
Transforming Data - Creating a Data Set Creating a JOIN between two .pdf
adonisjpr
 
Using the location quotients(LQ) for year 2020 for 10 provinces anal.pdf
Using the location quotients(LQ) for year 2020 for 10 provinces anal.pdfUsing the location quotients(LQ) for year 2020 for 10 provinces anal.pdf
Using the location quotients(LQ) for year 2020 for 10 provinces anal.pdf
adonisjpr
 
Using the packet tracer simulator, create a network topology that in.pdf
Using the packet tracer simulator, create a network topology that in.pdfUsing the packet tracer simulator, create a network topology that in.pdf
Using the packet tracer simulator, create a network topology that in.pdf
adonisjpr
 
using silde 2 to answer silde 1 and 3 Step 17 of 40 - Create T Accou.pdf
using silde 2 to answer silde 1 and 3 Step 17 of 40 - Create T Accou.pdfusing silde 2 to answer silde 1 and 3 Step 17 of 40 - Create T Accou.pdf
using silde 2 to answer silde 1 and 3 Step 17 of 40 - Create T Accou.pdf
adonisjpr
 
Using financial data and information from Yahoo Finance only, calcul.pdf
Using financial data and information from Yahoo Finance only, calcul.pdfUsing financial data and information from Yahoo Finance only, calcul.pdf
Using financial data and information from Yahoo Finance only, calcul.pdf
adonisjpr
 
using IRAC method Joseph was a team manager of an excursion in the O.pdf
using IRAC method Joseph was a team manager of an excursion in the O.pdfusing IRAC method Joseph was a team manager of an excursion in the O.pdf
using IRAC method Joseph was a team manager of an excursion in the O.pdf
adonisjpr
 
Using Java programming language solve the followingSLL CLASS.pdf
Using Java programming language solve the followingSLL CLASS.pdfUsing Java programming language solve the followingSLL CLASS.pdf
Using Java programming language solve the followingSLL CLASS.pdf
adonisjpr
 

More from adonisjpr (20)

Una mujer de 36 a�os que se someti� a un trasplante de ri��n hace 2 .pdf
Una mujer de 36 a�os que se someti� a un trasplante de ri��n hace 2 .pdfUna mujer de 36 a�os que se someti� a un trasplante de ri��n hace 2 .pdf
Una mujer de 36 a�os que se someti� a un trasplante de ri��n hace 2 .pdf
 
Una empresa tiene un ciclo operativo de 120 d�as, un per�odo promedi.pdf
Una empresa tiene un ciclo operativo de 120 d�as, un per�odo promedi.pdfUna empresa tiene un ciclo operativo de 120 d�as, un per�odo promedi.pdf
Una empresa tiene un ciclo operativo de 120 d�as, un per�odo promedi.pdf
 
Una empresa pag� por �ltima vez un dividendo de �3. Si el rendimient.pdf
Una empresa pag� por �ltima vez un dividendo de �3. Si el rendimient.pdfUna empresa pag� por �ltima vez un dividendo de �3. Si el rendimient.pdf
Una empresa pag� por �ltima vez un dividendo de �3. Si el rendimient.pdf
 
Una cartera eficiente es una combinaci�n de activos que 0 1 pun.pdf
Una cartera eficiente es una combinaci�n de activos que 0  1 pun.pdfUna cartera eficiente es una combinaci�n de activos que 0  1 pun.pdf
Una cartera eficiente es una combinaci�n de activos que 0 1 pun.pdf
 
Un objetivo a corto plazo esOpci�n multiple A) una meta espec.pdf
Un objetivo a corto plazo esOpci�n multiple A) una meta espec.pdfUn objetivo a corto plazo esOpci�n multiple A) una meta espec.pdf
Un objetivo a corto plazo esOpci�n multiple A) una meta espec.pdf
 
Tyco International, una empresa de fabricaci�n, demand� a su ex dire.pdf
Tyco International, una empresa de fabricaci�n, demand� a su ex dire.pdfTyco International, una empresa de fabricaci�n, demand� a su ex dire.pdf
Tyco International, una empresa de fabricaci�n, demand� a su ex dire.pdf
 
Un informe de an�lisis de estados financieros no incluye A) una dec.pdf
Un informe de an�lisis de estados financieros no incluye A) una dec.pdfUn informe de an�lisis de estados financieros no incluye A) una dec.pdf
Un informe de an�lisis de estados financieros no incluye A) una dec.pdf
 
ubat 2015te Hazine 4 78lik 2044 alt aylk bileik vadeye kadar 2,8.pdf
ubat 2015te Hazine 4 78lik 2044 alt aylk bileik vadeye kadar 2,8.pdfubat 2015te Hazine 4 78lik 2044 alt aylk bileik vadeye kadar 2,8.pdf
ubat 2015te Hazine 4 78lik 2044 alt aylk bileik vadeye kadar 2,8.pdf
 
Two categories of attackers include hacktivists and state actors. .pdf
Two categories of attackers include hacktivists and state actors. .pdfTwo categories of attackers include hacktivists and state actors. .pdf
Two categories of attackers include hacktivists and state actors. .pdf
 
Twitter, el popular sitio de microblogs, se ha enfrentado a graves c.pdf
Twitter, el popular sitio de microblogs, se ha enfrentado a graves c.pdfTwitter, el popular sitio de microblogs, se ha enfrentado a graves c.pdf
Twitter, el popular sitio de microblogs, se ha enfrentado a graves c.pdf
 
Turner, Roth y Lowe son socios que comparten ingresos y p�rdidas en .pdf
Turner, Roth y Lowe son socios que comparten ingresos y p�rdidas en .pdfTurner, Roth y Lowe son socios que comparten ingresos y p�rdidas en .pdf
Turner, Roth y Lowe son socios que comparten ingresos y p�rdidas en .pdf
 
Uber - Bir Startupn K�kenleri ve lk G�nleriDava M�terileri ele.pdf
Uber - Bir Startupn K�kenleri ve lk G�nleriDava M�terileri ele.pdfUber - Bir Startupn K�kenleri ve lk G�nleriDava M�terileri ele.pdf
Uber - Bir Startupn K�kenleri ve lk G�nleriDava M�terileri ele.pdf
 
Trilogy Enterprises Inc. de Austin, Texas, es una empresa de softwar.pdf
Trilogy Enterprises Inc. de Austin, Texas, es una empresa de softwar.pdfTrilogy Enterprises Inc. de Austin, Texas, es una empresa de softwar.pdf
Trilogy Enterprises Inc. de Austin, Texas, es una empresa de softwar.pdf
 
Transforming Data - Creating a Data Set Creating a JOIN between two .pdf
Transforming Data - Creating a Data Set Creating a JOIN between two .pdfTransforming Data - Creating a Data Set Creating a JOIN between two .pdf
Transforming Data - Creating a Data Set Creating a JOIN between two .pdf
 
Using the location quotients(LQ) for year 2020 for 10 provinces anal.pdf
Using the location quotients(LQ) for year 2020 for 10 provinces anal.pdfUsing the location quotients(LQ) for year 2020 for 10 provinces anal.pdf
Using the location quotients(LQ) for year 2020 for 10 provinces anal.pdf
 
Using the packet tracer simulator, create a network topology that in.pdf
Using the packet tracer simulator, create a network topology that in.pdfUsing the packet tracer simulator, create a network topology that in.pdf
Using the packet tracer simulator, create a network topology that in.pdf
 
using silde 2 to answer silde 1 and 3 Step 17 of 40 - Create T Accou.pdf
using silde 2 to answer silde 1 and 3 Step 17 of 40 - Create T Accou.pdfusing silde 2 to answer silde 1 and 3 Step 17 of 40 - Create T Accou.pdf
using silde 2 to answer silde 1 and 3 Step 17 of 40 - Create T Accou.pdf
 
Using financial data and information from Yahoo Finance only, calcul.pdf
Using financial data and information from Yahoo Finance only, calcul.pdfUsing financial data and information from Yahoo Finance only, calcul.pdf
Using financial data and information from Yahoo Finance only, calcul.pdf
 
using IRAC method Joseph was a team manager of an excursion in the O.pdf
using IRAC method Joseph was a team manager of an excursion in the O.pdfusing IRAC method Joseph was a team manager of an excursion in the O.pdf
using IRAC method Joseph was a team manager of an excursion in the O.pdf
 
Using Java programming language solve the followingSLL CLASS.pdf
Using Java programming language solve the followingSLL CLASS.pdfUsing Java programming language solve the followingSLL CLASS.pdf
Using Java programming language solve the followingSLL CLASS.pdf
 

Recently uploaded

Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 

Recently uploaded (20)

Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 

USING httpsraw.githubusercontent.comBeeDrHUIntroduction-to-Py.pdf

  • 1. *USING 'https://raw.githubusercontent.com/BeeDrHU/Introduction-to-Python-CSPC-323- /main/sales_forecast.csv' please fix the errors for the RNN using python so the code can run without errors, Thank you* ##Defining Function to Build Multivariate Data Structure def multivariate_data(dataset, target, start_index, end_index, history_size, target_size, step, single_step=False): data = [] labels = [] start_index = start_index + history_size if end_index is None: end_index = len(dataset) - target_size for i in range(start_index, end_index): indices = range(i-history_size, i, step) data.append(dataset[indices]) if single_step: labels.append(target[i+target_size]) else: labels.append(target[i:i+target_size]) return np.array(data), np.array(labels) ##Define the Multi-step Plotting Structure def multi_step_plot(history, true_future, prediction): plt.figure(figsize=(12, 6)) num_in = create_time_steps(len(history)) num_out = len(true_future) plt.plot(num_in, np.array(history[:, 1]), label='History') plt.plot(np.arange(num_out)/STEP, np.array(true_future), 'bo', label='True Future') if prediction.any():
  • 2. plt.plot(np.arange(num_out)/STEP, np.array(prediction), 'ro', label='Predicted Future') plt.legend(loc='upper left') plt.show() ##Define Function to Plot training and Validation over Time def plot_train_history(history, title): loss = history.history['loss'] val_loss = history.history['val_loss'] epochs = range(len(loss)) plt.figure() plt.plot(epochs, loss, 'b', label='Training loss') plt.plot(epochs, val_loss, 'r', label='Validation loss') plt.title(title) plt.legend() plt.show() ##How far into the past do you want the model to see? past_history= ##How far into the future do you want the model to see? future_target= ## STEP= df_val = len(dataset) - past_history - future_target x_train_multi, y_train_multi = multivariate_data(dataset, dataset[:, 1], 0, df_train, past_history, future_target, STEP) x_val_multi, y_val_multi = multivariate_data(dataset, dataset[:, 1], df_train, df_val, past_history,
  • 3. future_target, STEP) ##Define Constants BATCH_SIZE = BUFFER_SIZE = EPOCHS = EVALUATION_INTERVAL = ##Adding Layers Due to Complexity train_data_multi = tf.data.Dataset.from_tensor_slices(()) train_data_multi = train_data_multi.cache().shuffle().batch().repeat() val_data_multi = tf.data.Dataset.from_tensor_slices(()) val_data_multi = val_data_multi.batch().repeat() multi_step_model = tf.keras.models.Sequential() multi_step_model.add(tf.keras.layers.LSTM()) multi_step_model.add(tf.keras.layers.LSTM()) multi_step_model.add(tf.keras.layers.Dense(72)) multi_step_model.compile(optimizer=tf.keras.optimizers.RMSprop(clipvalue=1.0), loss='mae') ##Train the Model multi_step_history = multi_step_model.fit(train_data_multi, epochs=, steps_per_epoch=, validation_data=, validation_steps=50) ##Predict Future Data for x, y in .take(3): multi_step_plot(x[0], y[0], .predict(x)[0]) #Evaluate the model on the test data test_data_multi = tf.data.Dataset.from_tensor_slices()) test_data_multi = test_data_multi.batch() # Define the number of steps in the test dataset steps = len()
  • 4. mae_values = [] for x, y in : x_val, y_val= x[:, :-1], y[:,-1] #Make predictions using the model = .predict(x_val, steps=steps) #Compute MAE mae = tf.keras.metrics.mean_absolute_error().numpy() mae_values.append(mae) overall_mae = np.mean(mae_values) print('Overall MAE:', overall_mae)