Category : Machine Learning

The popular initializers include RandomNormal distribution function, trancated normal distribution function, GlorotNormal function, HeNormal function and others. This example code show what are these functions and display the probability density functions of these initializers for my reference. Code: import numpy as np import matplotlib.pyplot as plt from scipy.stats import norm x = np.linspace(-10,10,500) #default RandomNormal(mean=0.0, ..

Read more

beautiful sprawling fantasy vast landscape

Sample code for reducing overfitting problems in deep learning.Answer the following questions: import numpy as np import pandas as pd from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler # create range of monthly dates download_dates = pd.date_range(start=’2019-01-01′, end=’2020-01-01′, freq=’MS’) # URL from Chrome DevTools Console base_url = (“https://climate.weather.gc.ca/climate_data/bulk_data_e.html?format=csv&” “stationID=51442&Year={}&Month={}&Day=7&timeframe=1&submit=Download+Data”) # add format option to year ..

Read more

deep ocean scape

Simple example code on hyperparameter optimization for DNN regression models. Prepare data import numpy as np import pandas as pd from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler # create range of monthly dates download_dates = pd.date_range(start=’2019-01-01′, end=’2020-01-01′, freq=’MS’) # URL from Chrome DevTools Console base_url = (“https://climate.weather.gc.ca/climate_data/bulk_data_e.html?format=csv&” “stationID=51442&Year={}&Month={}&Day=7&timeframe=1&submit=Download+Data”) # add format option to year ..

Read more

trees in spring, summer, autumn and winter

Example code for developing a regression model with keras. It can also answer following questions: Prepare data Read data import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split # create range of monthly dates download_dates = pd.date_range(start=’2019-01-01′, end=’2020-01-01′, freq=’MS’) # URL from Chrome DevTools Console base_url = (“https://climate.weather.gc.ca/climate_data/bulk_data_e.html?format=csv&” ..

Read more

Beautiful trees landscape image by AI

Example code for transforming a selected group of variables with Sklearn Transformer Wrapper. It can also answer following questions: Prepare data sample import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.impute import SimpleImputer from sklearn.preprocessing import StandardScaler from sklearn.preprocessing import OneHotEncoder from sklearn.preprocessing import PolynomialFeatures from ..

Read more

Beautiful forest, pond and sunshine

Example code for identifying and selecting the high predictive performance features from dataset for machine learning and deep learning models. It can also answer the following questions: Prepare data Code import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split # create range of monthly dates download_dates = pd.date_range(start=’2019-01-01′, ..

Read more

Example code to transform continuous numerical variables into discrete variables with different methods. It cab also answer the following questions. Prepare data and load functions Code import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from feature_engine.discretisation import EqualFrequencyDiscretiser from feature_engine.discretisation import EqualWidthDiscretiser from feature_engine.discretisation import ArbitraryDiscretiser from ..

Read more

A scenic autumn landscape

Example code for creating and adding new features to a data frame using the feature-engine. It also answer following questions: Math features Code import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from feature_engine.creation import MathFeatures from feature_engine.creation import RelativeFeatures from feature_engine.creation import CyclicalFeatures # create range of ..

Read more

Winding rivers in mountainous forest

Example code for creating features from time series data, such as lag features and window features? It can answer following questions: import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from feature_engine.timeseries.forecasting import LagFeatures # create range of monthly dates download_dates = pd.date_range(start=’2019-01-01′, end=’2020-01-01′, freq=’MS’) # URL from ..

Read more