Food order forecast by RandomForestRegressor, DecisionTreeRegressor, LinearRegression
refer to code:
.
..
You can download dataset from here:
Thank you.
www.marearts.com
🙇🏻♂️
The study blog from marearts.com
Computer Vision & Machine Learning Research Laboratory
refer to code:
.
..
You can download dataset from here:
Thank you.
www.marearts.com
🙇🏻♂️
refer to code:
.
..
Thank you.
www.marearts.com
🙇🏻♂️
The error occurs when you try to call the to_list() method on a pandas Series object, but the method is not available in the version of pandas you are using. This method was added in pandas version 0.24.0, so if you are using an earlier version of pandas, you will get this error.
To fix this error, you can either upgrade your pandas version to 0.24.0 or later, or you can use an alternative method to convert the Series object to a list. Here are some examples:
tolist() method: If you are using pandas version 0.17.0 or later, you can use the tolist() method instead of to_list(). For example:.
..
values attribute: If you are using pandas version 0.24.0 or later, you can also use the values attribute to get a numpy array, and then convert the array to a list using the tolist() method. For example:list() function: If you are using an earlier version of pandas and the above methods do not work, you can use the built-in list() function to convert the Series object to a list. For example:
refer to code.
..
..
Thank you.
www.marearts.com
refer to sample code
..
..
Thank you.
www.marearts.com
Average by 2 steps moving window
.
.
0The rate of change between the previous data and the current data
.
.
0
Here, our example data is stock csv file.
Load data and print
.
.
Date Open High Low Close Volume
0 2021-01-19 123.594643 123.891014 122.456978 123.346077 5646308
1 2021-01-20 123.996178 125.296364 122.906311 124.359467 10
2 2021-01-21 124.397705 126.424477 124.330788 125.860420 0
3 2021-01-22 115.391968 115.391968 112.198853 113.393883 39814421
4 2021-01-25 113.537285 114.282982 112.284897 113.365204 14315974
5 2021-01-26 113.938812 117.198853 113.212234 117.103249 11186656
replace zeros with previous non zero value & check
.
.
Date Open High Low Close Volume
0 2021-01-19 123.594643 123.891014 122.456978 123.346077 5646308
1 2021-01-20 123.996178 125.296364 122.906311 124.359467 10
2 2021-01-21 124.397705 126.424477 124.330788 125.860420 10
3 2021-01-22 115.391968 115.391968 112.198853 113.393883 39814421
4 2021-01-25 113.537285 114.282982 112.284897 113.365204 14315974
5 2021-01-26 113.938812 117.198853 113.212234 117.103249 11186656
Thank you.
www.marearts.com
🙇🏻♂️
import numpy as np import pandas as pd f1_numpy = "./data/test1.csv" f2_pandas = "./data/test2.csv" #numpy to csv np.savetxt(f1_numpy, np.array([10,20])) print(f1_numpy) #numpy to pandas and csv pda = pd.DataFrame(np.array([10,20]), columns=['data']) pda.to_csv(f2_pandas, index=False)
import numpy as np import pandas as pd #make list a = [[11, 12, 13, 14, 15], [15, 16, 17, 18, 19]] b = [[21, 22, 23, 24, 25], [25, 26, 27, 28, 29]] c = [] c.append(a) c.append(b) #make numpy npa = np.array(c) print('npa\n',npa) print('npa shape\n',npa.shape) #2 by 2 by 5
npa [[[11 12 13 14 15] [15 16 17 18 19]] [[21 22 23 24 25] [25 26 27 28 29]]] npa shape (2, 2, 5)
#make numpy to panda m,n,r = npa.shape #numpy ->group indexing, reshape out_arr = np.column_stack((np.repeat(np.arange(m),n),npa.reshape(m*n,-1))) out_df = pd.DataFrame(out_arr, columns=['group','a','b','c','d','e']) print('pnadas\n',out_df) #pandas
group a b c d e 0 0 11 12 13 14 15 1 0 15 16 17 18 19 2 1 21 22 23 24 25 3 1 25 26 27 28 29
#save to csv out_df.to_csv('test3Dpandas.csv', index=False) #load csv df = pd.read_csv('test3Dpandas.csv')
#pandas to numpy npb = df.values npb = npb[:,1:] npb2 = npb.reshape(m,n,r) print('numpy\n',npb2)
numpy [[[11 12 13 14 15] [15 16 17 18 19]] [[21 22 23 24 25] [25 26 27 28 29]]]