Welcome to the third project of the Machine Learning Engineer Nanodegree! In this notebook, some template code has already been provided for you, and it will be your job to implement the additional functionality necessary to successfully complete this project. Sections that begin with 'Implementation' in the header indicate that the following block of code will require additional functionality which you must provide. Instructions will be provided for each section and the specifics of the implementation are marked in the code block with a 'TODO'
statement. Please be sure to read the instructions carefully!
In addition to implementing code, there will be questions that you must answer which relate to the project and your implementation. Each section where you will answer a question is preceded by a 'Question X' header. Carefully read each question and provide thorough answers in the following text boxes that begin with 'Answer:'. Your project submission will be evaluated based on your answers to each of the questions and the implementation you provide.
Note: Code and Markdown cells can be executed using the Shift + Enter keyboard shortcut. In addition, Markdown cells can be edited by typically double-clicking the cell to enter edit mode.
In this project, you will analyze a dataset containing data on various customers' annual spending amounts (reported in monetary units) of diverse product categories for internal structure. One goal of this project is to best describe the variation in the different types of customers that a wholesale distributor interacts with. Doing so would equip the distributor with insight into how to best structure their delivery service to meet the needs of each customer.
The dataset for this project can be found on the UCI Machine Learning Repository. For the purposes of this project, the features 'Channel'
and 'Region'
will be excluded in the analysis — with focus instead on the six product categories recorded for customers.
Run the code block below to load the wholesale customers dataset, along with a few of the necessary Python libraries required for this project. You will know the dataset loaded successfully if the size of the dataset is reported.
# Import libraries necessary for this project
import numpy as np
import pandas as pd
import seaborn as sns
from IPython.display import display # Allows the use of display() for DataFrames
import matplotlib.pyplot as plt
# Import supplementary visualizations code visuals.py
import visuals as vs
# Pretty display for notebooks
%matplotlib inline
# Load the wholesale customers dataset
try:
data = pd.read_csv("customers.csv")
data.drop(['Region', 'Channel'], axis = 1, inplace = True)
print "Wholesale customers dataset has {} samples with {} features each.".format(*data.shape)
except:
print "Dataset could not be loaded. Is the dataset missing?"
In this section, you will begin exploring the data through visualizations and code to understand how each feature is related to the others. You will observe a statistical description of the dataset, consider the relevance of each feature, and select a few sample data points from the dataset which you will track through the course of this project.
Run the code block below to observe a statistical description of the dataset. Note that the dataset is composed of six important product categories: 'Fresh', 'Milk', 'Grocery', 'Frozen', 'Detergents_Paper', and 'Delicatessen'. Consider what each category represents in terms of products you could purchase.
# Display a description of the dataset
display(data.describe())
To get a better understanding of the customers and how their data will transform through the analysis, it would be best to select a few sample data points and explore them in more detail. In the code block below, add three indices of your choice to the indices
list which will represent the customers to track. It is suggested to try different sets of samples until you obtain customers that vary significantly from one another.
# TODO: Select three indices of your choice you wish to sample from the dataset
indices = [20, 94, 397]
# Create a DataFrame of the chosen samples
samples = pd.DataFrame(data.loc[indices], columns = data.keys()).reset_index(drop = True)
print "Chosen samples of wholesale customers dataset:"
display(samples)
print "Compare compare each product to the mean"
display(samples - np.round(data.mean()))
print "Compare compare each product to the median"
display(samples - np.round(data.median()))
Consider the total purchase cost of each product category and the statistical description of the dataset above for your sample customers.
What kind of establishment (customer) could each of the three samples you've chosen represent?
Hint: Examples of establishments include places like markets, cafes, and retailers, among many others. Avoid using names for establishments, such as saying "McDonalds" when describing a sample customer as a restaurant.
Answer:
One interesting thought to consider is if one (or more) of the six product categories is actually relevant for understanding customer purchasing. That is to say, is it possible to determine whether customers purchasing some amount of one category of products will necessarily purchase some proportional amount of another category of products? We can make this determination quite easily by training a supervised regression learner on a subset of the data with one feature removed, and then score how well that model can predict the removed feature.
In the code block below, you will need to implement the following:
new_data
a copy of the data by removing a feature of your choice using the DataFrame.drop
function.sklearn.cross_validation.train_test_split
to split the dataset into training and testing sets.test_size
of 0.25
and set a random_state
.random_state
, and fit the learner to the training data.score
function.from sklearn.cross_validation import train_test_split
from sklearn.tree import DecisionTreeRegressor
# TODO: Make a copy of the DataFrame, using the 'drop' function to drop the given feature
new_data = data.drop(['Detergents_Paper'], axis = 1)
# TODO: Split the data into training and testing sets using the given feature as the target
y = data['Detergents_Paper']
X_train, X_test, y_train, y_test = train_test_split(new_data, y,
test_size = 0.25, random_state = 1)
# TODO: Create a decision tree regressor and fit it to the training set
regressor = DecisionTreeRegressor(random_state=0)
fit = regressor.fit(X_train, y_train)
# TODO: Report the score of the prediction using the testing set
score = fit.score(X_test, y_test)
print "The score when dropping the 'Detergents_Paper' column is {}".format(score)
#Compare each R^2 scores:
data2 = data.copy()
keys = ['Fresh', 'Milk', 'Grocery', 'Frozen', 'Detergents_Paper', 'Delicatessen']
r_scores = []
for key in keys:
label = data2[key]
features = data2.drop([key], axis =1)
X_train, X_test, y_train, y_test = train_test_split(features, label,
test_size = 0.25, random_state = 1)
regressor1 = DecisionTreeRegressor(random_state=0)
fit1 = regressor.fit(X_train, y_train)
score = regressor.score(X_test, y_test)
r_scores.append(score)
# display features and scores
result = pd.DataFrame(np.array([keys, r_scores]).T, columns=['Feature', 'Score'])
display(result)
Which feature did you attempt to predict? What was the reported prediction score? Is this feature is necessary for identifying customers' spending habits?
Hint: The coefficient of determination, R^2
, is scored between 0 and 1, with 1 being a perfect fit. A negative R^2
implies the model fails to fit the data.
Answer:
To get a better understanding of the dataset, we can construct a scatter matrix of each of the six product features present in the data. If you found that the feature you attempted to predict above is relevant for identifying a specific customer, then the scatter matrix below may not show any correlation between that feature and the others. Conversely, if you believe that feature is not relevant for identifying a specific customer, the scatter matrix might show a correlation between that feature and another feature in the data. Run the code block below to produce a scatter matrix.
# Produce a scatter matrix for each pair of features in the data
pd.scatter_matrix(data, alpha = 0.3, figsize = (14,8), diagonal = 'kde');
import seaborn as sns
sns_plot = sns.pairplot(data, diag_kind='kde', size = 1.6)
Are there any pairs of features which exhibit some degree of correlation? Does this confirm or deny your suspicions about the relevance of the feature you attempted to predict? How is the data for those features distributed?
Hint: Is the data normally distributed? Where do most of the data points lie?
Answer:
Are there any pairs of features which exhibit some degree of correlation? The Detergents_Paper and Grocery exhibit high degree of correlation in the scatter matrix above. There may be correlation between Detergents_Paper and Milk, Grocery and Milk.
Does this confirm or deny your suspicions about the relevance of the feature you attempted to predict? It confirms previous answer Q2 about the relevance of the Detergents_Paper and Grocery feature.
How is the data for those features distributed? The data distributes plot dose not look like a normally distribution, rather looks more like a lognormal.
In this section, you will preprocess the data to create a better representation of customers by performing a scaling on the data and detecting (and optionally removing) outliers. Preprocessing data is often times a critical step in assuring that results you obtain from your analysis are significant and meaningful.
If data is not normally distributed, especially if the mean and median vary significantly (indicating a large skew), it is most often appropriate to apply a non-linear scaling — particularly for financial data. One way to achieve this scaling is by using a Box-Cox test, which calculates the best power transformation of the data that reduces skewness. A simpler approach which can work in most cases would be applying the natural logarithm.
In the code block below, you will need to implement the following:
log_data
after applying logarithmic scaling. Use the np.log
function for this.log_samples
after applying logarithmic scaling. Again, use np.log
.# TODO: Scale the data using the natural logarithm
log_data = np.log(data).copy()
# TODO: Scale the sample data using the natural logarithm
log_samples = np.log(samples).copy()
# Produce a scatter matrix for each pair of newly-transformed features
pd.scatter_matrix(log_data, alpha = 0.3, figsize = (14,8), diagonal = 'kde');
import seaborn as sns
sns_plot = sns.pairplot(log_data, diag_kind='kde', size = 1.6)
After applying a natural logarithm scaling to the data, the distribution of each feature should appear much more normal. For any pairs of features you may have identified earlier as being correlated, observe here whether that correlation is still present (and whether it is now stronger or weaker than before).
Run the code below to see how the sample data has changed after having the natural logarithm applied to it.
# Display the log-transformed sample data
display(log_samples)
Detecting outliers in the data is extremely important in the data preprocessing step of any analysis. The presence of outliers can often skew results which take into consideration these data points. There are many "rules of thumb" for what constitutes an outlier in a dataset. Here, we will use Tukey's Method for identfying outliers: An outlier step is calculated as 1.5 times the interquartile range (IQR). A data point with a feature that is beyond an outlier step outside of the IQR for that feature is considered abnormal.
In the code block below, you will need to implement the following:
Q1
. Use np.percentile
for this.Q3
. Again, use np.percentile
.step
.outliers
list.NOTE: If you choose to remove any outliers, ensure that the sample data does not contain any of these points!
Once you have performed this implementation, the dataset will be stored in the variable good_data
.
outliers = np.array([], dtype='int64')
# For each feature find the data points with extreme high or low values
for feature in log_data.keys():
# TODO: Calculate Q1 (25th percentile of the data) for the given feature
Q1 = np.percentile(log_data[feature],25)
# TODO: Calculate Q3 (75th percentile of the data) for the given feature
Q3 = np.percentile(log_data[feature], 75)
# TODO: Use the interquartile range to calculate an outlier step (1.5 times the interquartile range)
step = 1.5*(Q3 - Q1)
# Display the outliers
feature_outliers = log_data[~((log_data[feature] >= Q1 - step) & (log_data[feature] <= Q3 + step))]
feature_outliers_index = feature_outliers.index.values
outliers = np.append(outliers, feature_outliers_index)
print"Data points considered outliers for the feature '{}':".format(feature)
print"Numbers of outlier of {}: {}".format(feature, feature_outliers.count()[feature])
display(feature_outliers)
# OPTIONAL: Select the indices for data points you wish to remove
dule_outliers, indices = np.unique(outliers, return_inverse=True)
counts = np.bincount(indices)
dule_outliers = dule_outliers[counts>1]
outliers = np.unique(outliers)
print dule_outliers
print outliers
# Remove the outliers, if any were specified
good_data = log_data.drop(log_data.index[dule_outliers]).reset_index(drop = True)
# Produce a scatter matrix for each pair of features in the data
sns.pairplot(good_data, diag_kind='kde', size = 2.0)
Are there any data points considered outliers for more than one feature based on the definition above? Should these data points be removed from the dataset? If any data points were added to the outliers
list to be removed, explain why.
Answer:
In this section you will use principal component analysis (PCA) to draw conclusions about the underlying structure of the wholesale customer data. Since using PCA on a dataset calculates the dimensions which best maximize variance, we will find which compound combinations of features best describe customers.
Now that the data has been scaled to a more normal distribution and has had any necessary outliers removed, we can now apply PCA to the good_data
to discover which dimensions about the data best maximize the variance of features involved. In addition to finding these dimensions, PCA will also report the explained variance ratio of each dimension — how much variance within the data is explained by that dimension alone. Note that a component (dimension) from PCA can be considered a new "feature" of the space, however it is a composition of the original features present in the data.
In the code block below, you will need to implement the following:
sklearn.decomposition.PCA
and assign the results of fitting PCA in six dimensions with good_data
to pca
.log_samples
using pca.transform
, and assign the results to pca_samples
.from sklearn.decomposition import PCA
# TODO: Apply PCA by fitting the good data with the same number of dimensions as features
pca = PCA(n_components = 6).fit(good_data)
# TODO: Transform log_samples using the PCA fit above
pca_samples = pca.transform(log_samples)
# Generate PCA results plot
pca_results = vs.pca_results(good_data, pca)
np.cumsum(pca.explained_variance_ratio_)
How much variance in the data is explained in total by the first and second principal component? What about the first four principal components? Using the visualization provided above, discuss what the first four dimensions best represent in terms of customer spending.
Hint: A positive increase in a specific dimension corresponds with an increase of the positive-weighted features and a decrease of the negative-weighted features. The rate of increase or decrease is based on the indivdual feature weights.
Answer:
Run the code below to see how the log-transformed sample data has changed after having a PCA transformation applied to it in six dimensions. Observe the numerical value for the first four dimensions of the sample points. Consider if this is consistent with your initial interpretation of the sample points.
# Display sample log-data after having a PCA transformation applied
display(pd.DataFrame(np.round(pca_samples, 4), columns = pca_results.index.values))
When using principal component analysis, one of the main goals is to reduce the dimensionality of the data — in effect, reducing the complexity of the problem. Dimensionality reduction comes at a cost: Fewer dimensions used implies less of the total variance in the data is being explained. Because of this, the cumulative explained variance ratio is extremely important for knowing how many dimensions are necessary for the problem. Additionally, if a signifiant amount of variance is explained by only two or three dimensions, the reduced data can be visualized afterwards.
In the code block below, you will need to implement the following:
good_data
to pca
.good_data
using pca.transform
, and assign the results to reduced_data
.log_samples
using pca.transform
, and assign the results to pca_samples
.# TODO: Apply PCA by fitting the good data with only two dimensions
pca = PCA(n_components = 2).fit(good_data)
# TODO: Transform the good data using the PCA fit above
reduced_data = pca.transform(good_data)
# TODO: Transform log_samples using the PCA fit above
pca_samples = pca.transform(log_samples)
# Create a DataFrame for the reduced data
reduced_data = pd.DataFrame(reduced_data, columns = ['Dimension 1', 'Dimension 2'])
Run the code below to see how the log-transformed sample data has changed after having a PCA transformation applied to it using only two dimensions. Observe how the values for the first two dimensions remains unchanged when compared to a PCA transformation in six dimensions.
# Display sample log-data after applying PCA transformation in two dimensions
display(pd.DataFrame(np.round(pca_samples, 4), columns = ['Dimension 1', 'Dimension 2']))
A biplot is a scatterplot where each data point is represented by its scores along the principal components. The axes are the principal components (in this case Dimension 1
and Dimension 2
). In addition, the biplot shows the projection of the original features along the components. A biplot can help us interpret the reduced dimensions of the data, and discover relationships between the principal components and original features.
Run the code cell below to produce a biplot of the reduced-dimension data.
# Create a biplot
vs.biplot(good_data, reduced_data, pca)
Once we have the original feature projections (in red), it is easier to interpret the relative position of each data point in the scatterplot. For instance, a point the lower right corner of the figure will likely correspond to a customer that spends a lot on 'Milk'
, 'Grocery'
and 'Detergents_Paper'
, but not so much on the other product categories.
From the biplot, which of the original features are most strongly correlated with the first component? What about those that are associated with the second component? Do these observations agree with the pca_results plot you obtained earlier?
In this section, you will choose to use either a K-Means clustering algorithm or a Gaussian Mixture Model clustering algorithm to identify the various customer segments hidden in the data. You will then recover specific data points from the clusters to understand their significance by transforming them back into their original dimension and scale.
What are the advantages to using a K-Means clustering algorithm? What are the advantages to using a Gaussian Mixture Model clustering algorithm? Given your observations about the wholesale customer data so far, which of the two algorithms will you use and why?
Answer:
* From the previous biplot, we can see two clusters overlapped. So the chosen algorithim is Gaussian Mixture Model because of its ability to apply "soft" classification. Since our sample size is not a large one, GMM seems a better fit.
Depending on the problem, the number of clusters that you expect to be in the data may already be known. When the number of clusters is not known a priori, there is no guarantee that a given number of clusters best segments the data, since it is unclear what structure exists in the data — if any. However, we can quantify the "goodness" of a clustering by calculating each data point's silhouette coefficient. The silhouette coefficient for a data point measures how similar it is to its assigned cluster from -1 (dissimilar) to 1 (similar). Calculating the mean silhouette coefficient provides for a simple scoring method of a given clustering.
In the code block below, you will need to implement the following:
reduced_data
and assign it to clusterer
.reduced_data
using clusterer.predict
and assign them to preds
.centers
.pca_samples
and assign them sample_preds
.sklearn.metrics.silhouette_score
and calculate the silhouette score of reduced_data
against preds
.score
and print the result.from sklearn import mixture
from sklearn.metrics import silhouette_score
# TODO: Apply your clustering algorithm of choice to the reduced data
def gmm_cluster(data, num_components):
data = reduced_data
clusterer = mixture.GMM(n_components =num_components).fit(data)
preds = clusterer.predict(data)
score = silhouette_score(data, preds)
return score
silhouette_scores_matrix = pd.DataFrame(index=['Score'])
for i in range(2,11):
silhouette_scores_matrix[i] = pd.Series(gmm_cluster(reduced_data, i),
index = silhouette_scores_matrix.index)
display(silhouette_scores_matrix)
# Apply the selected clustering algorithm to the reduced data
clusterer = mixture.GMM(n_components=2).fit(reduced_data)
# Predict the cluster for each data point
preds = clusterer.predict(reduced_data)
# Find the cluster centers
centers = clusterer.means_
# Predict the cluster for each transformed sample data point
sample_preds = clusterer.predict(pca_samples)
# Calculate the mean silhouette coefficient for the number of clusters chosen
score = silhouette_score(reduced_data, preds)
import time
from sklearn.cluster import KMeans
from sklearn import mixture
import matplotlib.pyplot as plt
n = 1000
k = 6
kmeans_train_times = []
for k in xrange(1, 7):
cum_time = 0.
for i in xrange(n):
start = time.time()
KMeans(n_clusters=k).fit(reduced_data)
cum_time += (time.time() - start)
train_time = cum_time / n
kmeans_train_times.append([k, train_time])
km_df = pd.DataFrame(kmeans_train_times, columns=['KM_Clusters', 'KM_Time'])
gmm_train_times = []
for k in xrange(1, 7):
cum_time = 0.
for i in xrange(n):
start = time.time()
mixture.GMM(n_components=k).fit(reduced_data)
cum_time += (time.time() - start)
train_time = cum_time / n
gmm_train_times.append([k, train_time])
gmm_df = pd.DataFrame(gmm_train_times, columns=['GMM_Components', 'GMM_Time'])
times_df = km_df.join(gmm_df)
plt.plot(times_df.GMM_Components, times_df.GMM_Time * 1000., label='GMM Train Time')
plt.plot(times_df.GMM_Components, times_df.KM_Time * 1000., label='Kmeans Train Time')
plt.legend(loc='best')
plt.ylabel('Train time (in millisec.)')
plt.xlabel('Cluster/Components Used in Training')
plt.title('Training Time for Different Cluster/Component Sizes \n Averaged Over {} Runs Per Size'.format(n))
plt.show()
Report the silhouette score for several cluster numbers you tried. Of these, which number of clusters has the best silhouette score?
Answer:
Once you've chosen the optimal number of clusters for your clustering algorithm using the scoring metric above, you can now visualize the results by executing the code block below. Note that, for experimentation purposes, you are welcome to adjust the number of clusters for your clustering algorithm to see various visualizations. The final visualization provided should, however, correspond with the optimal number of clusters.
# Display the results of the clustering from implementation
vs.cluster_results(reduced_data, preds, centers, pca_samples)
Each cluster present in the visualization above has a central point. These centers (or means) are not specifically data points from the data, but rather the averages of all the data points predicted in the respective clusters. For the problem of creating customer segments, a cluster's center point corresponds to the average customer of that segment. Since the data is currently reduced in dimension and scaled by a logarithm, we can recover the representative customer spending from these data points by applying the inverse transformations.
In the code block below, you will need to implement the following:
centers
using pca.inverse_transform
and assign the new centers to log_centers
.np.log
to log_centers
using np.exp
and assign the true centers to true_centers
.# TODO: Inverse transform the centers
log_centers = pca.inverse_transform(centers)
# TODO: Exponentiate the centers
true_centers = np.exp(log_centers)
# Display the true centers
segments = ['Segment {}'.format(i) for i in range(0,len(centers))]
true_centers = pd.DataFrame(np.round(true_centers), columns = data.keys())
true_centers.index = segments
print 'True Centers'
display(true_centers)
# Compare the true centers to the mean and median of the data
print "Compared to the mean: "
display(true_centers - data.mean().round())
print "Compared to the median: "
display(true_centers - data.median().round())
#feedback
true_centers = true_centers.append(data.describe().ix['mean'])
true_centers.plot(kind = 'bar', figsize = (16, 4))
Consider the total purchase cost of each product category for the representative data points above, and reference the statistical description of the dataset at the beginning of this project. What set of establishments could each of the customer segments represent?
Hint: A customer who is assigned to 'Cluster X'
should best identify with the establishments represented by the feature set of 'Segment X'
.
Answer:
For each sample point, which customer segment from Question 8 best represents it? Are the predictions for each sample point consistent with this?
Run the code block below to find which cluster each sample point is predicted to be.
# Display the predictions
for i, (pred, sample) in enumerate(zip(sample_preds, samples.values)):
print "Sample point", i, "predicted to be in Cluster", pred
print "Data for this sample: ", sample
sns.heatmap(samples, annot=True, fmt="d")
Answer:
For sample point 0 and 1, the values for 'Grocery', 'Milk' and 'Detergents_Paper' are above average, so the predicted cluster seems to be consistent with the sample.
For sample point 2 the values for Fresh and Froze purchases are above average, but 'Detergents_Paper' are sinificant lower, which is also consistent with the findings.
In this final section, you will investigate ways that you can make use of the clustered data. First, you will consider how the different groups of customers, the customer segments, may be affected differently by a specific delivery scheme. Next, you will consider how giving a label to each customer (which segment that customer belongs to) can provide for additional features about the customer data. Finally, you will compare the customer segments to a hidden variable present in the data, to see whether the clustering identified certain relationships.
Companies will often run A/B tests when making small changes to their products or services to determine whether making that change will affect its customers positively or negatively. The wholesale distributor is considering changing its delivery service from currently 5 days a week to 3 days a week. However, the distributor will only make this change in delivery service for customers that react positively. How can the wholesale distributor use the customer segments to determine which customers, if any, would react positively to the change in delivery service?
Hint: Can we assume the change affects all customers equally? How can we determine which group of customers it affects the most?
Answer:
How can the wholesale distributor use the customer segments to determine which customers, if any, would react positively to the change in delivery service? It is safe to assume that Customers who buy large amount of Fresh, Milk and Frozen would be effected by the delivery service changes. If the wholesale distributor is considering changing its delivery service from currently 5 days a week to 3 days a week, it would be good idea to cluster those three features together, since retails make larger order and possibly have more space to stock items, they are likely to make their orders once or twice a week.
Can we assume the change affects all customers equally? How can we determine which group of customers it affects the most? No, we cannot assume the cahnge affects all customers equally. That is why we need to run the A/B tests. We can randomly select samples from each cluster and apply delivery changes. After collecting customer satisfaction suveies, we will be able to assume how many customers will be able to accept the changes.
Additional structure is derived from originally unlabeled data when using clustering techniques. Since each customer has a customer segment it best identifies with (depending on the clustering algorithm applied), we can consider 'customer segment' as an engineered feature for the data. Assume the wholesale distributor recently acquired ten new customers and each provided estimates for anticipated annual spending of each product category. Knowing these estimates, the wholesale distributor wants to classify each new customer to a customer segment to determine the most appropriate delivery service.
How can the wholesale distributor label the new customers using only their estimated product spending and the customer segment data?
Hint: A supervised learner could be used to train on the original customers. What would be the target variable?
Answer: Since the customer segment has been an engineered feature for the data, it can be used as a new feature in training supervised learning models. We can run a SVM or KNN to predict which cluster a new customer would fall into.
At the beginning of this project, it was discussed that the 'Channel'
and 'Region'
features would be excluded from the dataset so that the customer product categories were emphasized in the analysis. By reintroducing the 'Channel'
feature to the dataset, an interesting structure emerges when considering the same PCA dimensionality reduction applied earlier to the original dataset.
Run the code block below to see how each data point is labeled either 'HoReCa'
(Hotel/Restaurant/Cafe) or 'Retail'
the reduced space. In addition, you will find the sample points are circled in the plot, which will identify their labeling.
# Display the clustering results based on 'Channel' data
print 'clustering withnout outliers: '
vs.channel_results(reduced_data, dule_outliers, pca_samples)
How well does the clustering algorithm and number of clusters you've chosen compare to this underlying distribution of Hotel/Restaurant/Cafe customers to Retailer customers? Are there customer segments that would be classified as purely 'Retailers' or 'Hotels/Restaurants/Cafes' by this distribution? Would you consider these classifications as consistent with your previous definition of the customer segments?
Answer:
Note: Once you have completed all of the code implementations and successfully answered each question above, you may finalize your work by exporting the iPython Notebook as an HTML document. You can do this by using the menu above and navigating to
File -> Download as -> HTML (.html). Include the finished document along with this notebook as your submission.


|
Standard Reference Data Program |
Data Gateway |
Chemistry WebBook |
Go To: Top, Constants of diatomic molecules, References, Notes / Error Report
Data compilation copyright by the U.S. Secretary of Commerce on behalf of the U.S.A. All rights reserved.
Data compiled as indicated in comments:
LBLHLM - S.G. Lias, J.E. Bartmess, J.F. Liebman, J.L. Holmes, R.D. Levin, and W.G. Mallard
LLK - S.G. Lias, R.D. Levin, and S.A. Kafafi
RDSH - H.M. Rosenstock, K. Draxl, B.W. Steiner, and J.T. Herron
| IE (eV) | Method | Reference | Comment |
|---|---|---|---|
| 8.61 ± 0.02 | PE | Dyke, Ellis, et al., 1987 | LBLHLM |
| 7.5 ± 0.5 | EI | Smoes, Drowart, et al., 1976 | LLK |
| 7.9 ± 0.1 | EI | Ackermann, Rauh, et al., 1976 | LLK |
| 6. ± 0.5 | EI | Inghram, Chupka, et al., 1957 | RDSH |
Go To: Top, Gas phase ion energetics data, References, Notes / Error Report
Data compilation copyright by the U.S. Secretary of Commerce on behalf of the U.S.A. All rights reserved.
Data compiled by: K.P. Huber and G. Herzberg
| State | Te | ωe | ωexe | ωeye | Be | αe | γe | De | βe | re | Trans. | ν00 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Weak emission bands at 35476 and 36379 cm-1, no analysis. | ||||||||||||
| Cheetham and Barrow, 1967 | ||||||||||||
| V (2Δ)5/2 | [0.375] 1 2 | [3.3E-7] | [1.749] | V → X2 R | (33280) 1 (Z) | |||||||
| Cheetham and Barrow, 1967 | ||||||||||||
| U (2Δ)5/2 | [0.3715] 2 | [3.3E-7] | [1.7572] | U → X2 R | (33110) (Z) | |||||||
| Cheetham and Barrow, 1967 | ||||||||||||
| T (2Δ)5/2 | 35954 | (891) | [0.37688] 3 | [2.70E-7] | [1.74461] | T → X2 R | 32380.77 Z | |||||
| Cheetham and Barrow, 1967 | ||||||||||||
| State | Te | ωe | ωexe | ωeye | Be | αe | γe | De | βe | re | Trans. | ν00 |
| S (2Δ)5/2 | 35864 | (871) | [0.37536] 3 | [2.79E-7] | [1.74814] | S → X2 R | 32280.40 Z | |||||
| Cheetham and Barrow, 1967 | ||||||||||||
| R (2Δ)3/2 | 32445 | (885) | [0.38393] 3 | [2.89E-7] 4 | [1.72852] | R → X1 R | 32373.60 Z | |||||
| Cheetham and Barrow, 1967 | ||||||||||||
| Q | (29306) | [(895)] 5 | Q ← X1 | (29240) 5 | ||||||||
| Weltner and McLeod, 1965 | ||||||||||||
| Q' (2Δ)5/2 | 27353.0 | [896.1] Z | (4.07) | 0.381834 6 | 0.00219 | [2.744E-7] | 1.73326 | Q' → X2 R | 23785.20 Z | |||
| Cheetham and Barrow, 1967 | ||||||||||||
| State | Te | ωe | ωexe | ωeye | Be | αe | γe | De | βe | re | Trans. | ν00 |
| P (2Δ)3/2 | 26736.19 | 902.68 Z | 4.08 | 0.377500 7 | 0.00181 | [2.573E-7] | 1.74318 | P ↔ X1 R | 26673.04 Z | |||
| Premaswarup, 1955; missing citation; Premaswarup and Barrow, 1957; Weltner and McLeod, 1965; Cheetham and Barrow, 1967 | ||||||||||||
| O | (26342) | (913) 5 | (4.5) | O ← X1 | (26284) 5 | |||||||
| Weltner and McLeod, 1965 | ||||||||||||
| O' (2Φ)7/2 | 26186 | (899) | [0.381304] | [2.745E-7] | [1.734462] | O' → X1 R | 22616.07 Z | |||||
| Cheetham and Barrow, 1967 | ||||||||||||
| N (2Π)3/2 | 25657 | (900) | [0.377207] | [2.649E-7] | [1.74386] | N → X2 R | 22087.70 Z | |||||
| Cheetham and Barrow, 1967 | ||||||||||||
| N ↔ X1 R | 25593.13 Z | |||||||||||
| Weltner and McLeod, 1965; Cheetham and Barrow, 1967 | ||||||||||||
| State | Te | ωe | ωexe | ωeye | Be | αe | γe | De | βe | re | Trans. | ν00 |
| M (2Φ)5/2 | 24123.7 | [890.31] Z | 4.1 H | 0.377064 | 0.00184 | [2.635E-7] | 1.74419 | M ↔ X1 R | 24058.42 Z | |||
| missing citation; Premaswarup and Barrow, 1957; Weltner and McLeod, 1965; Cheetham and Barrow, 1967 | ||||||||||||
| L (2Π)1/2 | 23408.3 | [887.70] Z | 4.1 H | 0.377424 8 | 0.00195 | [2.706E-7] | 1.74335 | L ↔ X1 R | 23341.74 Z | |||
| missing citation; Premaswarup and Barrow, 1957; Weltner and McLeod, 1965; Cheetham and Barrow, 1967 | ||||||||||||
| K' (2Φ)7/2 | 22981.58 | 903.06 Z | 3.56 | 0.38081 | 0.00192 | [2.756E-7] | 1.73559 | K' → X2 R | 19413.32 Z | |||
| Cheetham and Barrow, 1967 | ||||||||||||
| (22396) | (901.7) 5 | (3.34) | K ↔ X1 | (22333) 5 | ||||||||
| Weltner and McLeod, 1965 | ||||||||||||
| State | Te | ωe | ωexe | ωeye | Be | αe | γe | De | βe | re | Trans. | ν00 |
| J | (22196) | (892) 5 | (3) | J ← X1 | (22128) 5 | |||||||
| Weltner and McLeod, 1965 | ||||||||||||
| (I) | Ne matrix emission and absorption spectra suggest the existance of an additional state close to H. | |||||||||||
| Weltner and McLeod, 1965 | ||||||||||||
| H | (20868) | [(900)] 9 | H ↔ X1 | (20805) 9 | ||||||||
| Weltner and McLeod, 1965 | ||||||||||||
| G | G ← X1 | (18007) 5 | ||||||||||
| Weltner and McLeod, 1965 | ||||||||||||
| State | Te | ωe | ωexe | ωeye | Be | αe | γe | De | βe | re | Trans. | ν00 |
| F | (16770) | [(922)] 5 | F ← X1 | (16718) 5 | ||||||||
| Weltner and McLeod, 1965 | ||||||||||||
| F 10 | R | 16051 Z | ||||||||||
| Cheetham and Barrow, 1967 | ||||||||||||
| E (2Φ)5/2 | 15928 | (935) 5 | (5) | [0.38618] 11 | [3.26E-7] | [1.72348] | E ↔ X1 R | 15880.62 Z | ||||
| Weltner and McLeod, 1965; Cheetham and Barrow, 1967 | ||||||||||||
| D | (14437) | (943) 12 | D ↔ X1 | (14395) 5 13 | ||||||||
| Weltner and McLeod, 1965; Cheetham and Barrow, 1967 | ||||||||||||
| State | Te | ωe | ωexe | ωeye | Be | αe | γe | De | βe | re | Trans. | ν00 |
| C (2Δ)3/2 | 13612 | (942) | [0.387547] | [2.624E-7] | [1.72044] | C ↔ X1 R | 13569.27 Z | |||||
| Weltner and McLeod, 1965; Cheetham and Barrow, 1967 | ||||||||||||
| B (2Φ)5/2 | 12900 | (931) | [0.386851] | [2.674E-7] | [1.72198] | B ↔ X1 R | 12852.02 Z | |||||
| Weltner and McLeod, 1965; Cheetham and Barrow, 1967 | ||||||||||||
| A | (12134) | [(939)] 14 | A ↔ X1 | (12090) 15 | ||||||||
| Weltner and McLeod, 1965; Cheetham and Barrow, 1967 | ||||||||||||
| A' (2Π)1/2 | [0.389] | [1.717] | A' → X1 R | (11062) (Z) | ||||||||
| Cheetham and Barrow, 1967 | ||||||||||||
| State | Te | ωe | ωexe | ωeye | Be | αe | γe | De | βe | re | Trans. | ν00 |
| A" (2Δ)3/2 | 10908 | (933) | [0.387291] | [2.668E-7] | [1.72100] | A" → X1 R | 10860.95 Z | |||||
| Cheetham and Barrow, 1967 | ||||||||||||
| X2 (2Δ)5/2 | 3504.39 | 1030.81 Z | 3.59 | 0.403584 | 0.00187 | [2.503E-7] | 1.68591 | |||||
| X1 (2Δ)3/2 | 0 | 1028.69 Z | 3.51 | 0.402840 | 0.00182 | [2.450E-7] | 1.68746 16 | |||||
| Weltner and McLeod, 1965 |
| 1 | This level could possibly be T(v=1). |
| 2 | Extensive perturbations. |
| 3 | Perturbations. |
| 4 | Cheetham and Barrow, 1967 give 2.289 which appears to be a misprint. |
| 5 | From the Ne matrix absorption spectrum. |
| 6 | Perturbations in v=0. |
| 7 | v=1 perturbed by a state of higher B value. |
| 8 | Λ-type doubling Δv(v=0) = 0.0927(J+1/2). |
| 9 | From Ne matrix absorption and emission spectra. |
| 10 | Incompletely analysed emission band. |
| 11 | Perturbed by a state of larger B value. |
| 12 | Calculated from Ta18O frequency in neon. |
| 13 | In the gas phase probably at 14362 cm-1. |
| 14 | From the Ar matrix absorption spectrum. |
| 15 | From Cheetham and Barrow, 1967; the observed band is too weak for analysis. |
| 16 | IR spectrum 18 |
| 17 | Average of two thermochemical values (mass-spectrometry). Inghram, Chupka, et al., 1957, Krikorian and Carpenter, 1965 |
| 18 | In rare gas matrices. |
Go To: Top, Gas phase ion energetics data, Constants of diatomic molecules, Notes / Error Report
Data compilation copyright by the U.S. Secretary of Commerce on behalf of the U.S.A. All rights reserved.
Dyke, Ellis, et al., 1987
Dyke, J.M.; Ellis, A.M.; Feher, M.; Morris, A.; Paul, A.J.; Stevens, J.C.H.,
High-temperature photoelectron spectroscopy - A study of niobium monoxide and tantalum monoxide,
J. Chem. Soc. Faraday Trans. 2, 1987, 83, 1555. [all data]
Smoes, Drowart, et al., 1976
Smoes, S.; Drowart, J.; Myers, C.E.,
Determination of the atomization energies of the molecules TaO(g) TaO2(g) by the mass-spectrometric Knudsen-cell method,
J. Chem. Thermodyn., 1976, 8, 225. [all data]
Ackermann, Rauh, et al., 1976
Ackermann, R.J.; Rauh, E.G.; Thorn, R.J.,
The thermodynamics of ionization of gaseous oxides; the first ionization potentials of the lanthanide metals and monoxides,
J. Chem. Phys., 1976, 65, 1027. [all data]
Inghram, Chupka, et al., 1957
Inghram, M.G.; Chupka, W.A.; Berkowitz, J.,
Thermodynamics of the Ta-O system: the dissociation energies of TaO and TaO2,
J. Chem. Phys., 1957, 27, 569. [all data]
Cheetham and Barrow, 1967
Cheetham, C.J.; Barrow, R.F.,
Rotational analysis of electronic bands of gaseous TaO,
Trans. Faraday Soc., 1967, 63, 1835. [all data]
Weltner and McLeod, 1965
Weltner, W., Jr.; McLeod, D., Jr.,
J. Chem. Phys., 1965, 42, 882. [all data]
Premaswarup, 1955
Premaswarup, D.,
Vibrational analysis of the tantalum oxide bands,
Indian J. Phys., 1955, 29, 109. [all data]
Premaswarup and Barrow, 1957
Premaswarup, D.; Barrow, R.F.,
Rotational analysis of the tantalum oxide bands,
Nature (London), 1957, 180, 602. [all data]
Krikorian and Carpenter, 1965
Krikorian, O.H.; Carpenter, J.H.,
Enthalpies of formation of gaseous tantalum oxide and tantalum dioxide,
J. Phys. Chem., 1965, 69, 4399. [all data]
Go To: Top, Gas phase ion energetics data, Constants of diatomic molecules, References
Copyright for NIST Standard Reference Data is governed by the Standard Reference Data Act.
|
Standard Reference Data Program |
Data Gateway |
Chemistry WebBook |
If you have comments or questions about this site, please contact us.


FFCC
FAQ
Contact Us
Welcome
To Fully Flexible Credit Companion.
Automate Your Timetable.
Get Started Below.
Using your phone?
Download
1
2
3
Choose Your Theory Slot
Morning
Evening
Submit
FAQ


#include <string_ops.h>
Return substrings from Tensor
of strings.
For each string in the input Tensor
, creates a substring starting at index pos
with a total length of len
.
If len
defines a substring that would extend beyond the length of the input string, then as many characters as possible are used.
A negative pos
indicates distance within the string backwards from the end.
If pos
specifies an index which is out of range for any of the input strings, then an InvalidArgumentError
is thrown.
pos
and len
must have the same shape, otherwise a ValueError
is thrown on Op creation.
NOTE: Substr
supports broadcasting up to two dimensions. More about broadcasting here
Examples
Using scalar pos
and len
:
input = [b'Hello', b'World'] position = 1 length = 3
output = [b'ell', b'orl']
Using pos
and len
with same shape as input
:
input = [[b'ten', b'eleven', b'twelve'], [b'thirteen', b'fourteen', b'fifteen'], [b'sixteen', b'seventeen', b'eighteen']] position = [[1, 2, 3], [1, 2, 3], [1, 2, 3]] length = [[2, 3, 4], [4, 3, 2], [5, 5, 5]]
output = [[b'en', b'eve', b'lve'], [b'hirt', b'urt', b'te'], [b'ixtee', b'vente', b'hteen']]
Broadcasting pos
and len
onto input
:
input = [[b'ten', b'eleven', b'twelve'], [b'thirteen', b'fourteen', b'fifteen'], [b'sixteen', b'seventeen', b'eighteen'], [b'nineteen', b'twenty', b'twentyone']] position = [1, 2, 3] length = [1, 2, 3]
output = [[b'e', b'ev', b'lve'], [b'h', b'ur', b'tee'], [b'i', b've', b'hte'], [b'i', b'en', b'nty']]
Broadcasting input
onto pos
and len
:
input = b'thirteen' position = [1, 5, 7] length = [3, 2, 1]
output = [b'hir', b'ee', b'n']
Arguments:
Returns:
Constructors and Destructors |
|
|---|---|
Substr(const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input pos, ::tensorflow::Input len)
|
Public attributes |
|
|---|---|
operation
|
|
output
|
Public functions |
|
|---|---|
node() const
|
::tensorflow::Node *
|
operator::tensorflow::Input() const
|
|
operator::tensorflow::Output() const
|
|
Operation operation
::tensorflow::Output output
Substr( const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input pos, ::tensorflow::Input len )
::tensorflow::Node * node() const
operator::tensorflow::Input() const
operator::tensorflow::Output() const


"The Wedding Singer" Sings a Familiar Tune by Homer Yen (c) 1998
Meet Robbie Hart (Adam Sandler), a cloyingly good-natured man.  He wants to settle down in his hometown and marry his high school sweetheart. Once a lead singer for his garage rock band, he now works as a wedding singer. He possesses charm and knows how to put a positive spin on any festive occasion...that is until he is left standing alone at the altar.
He is now miserable and vents his frustration at wedding guests by lamenting about life and singing songs like "Love Stinks". But he does find comfort with Julia (Drew Barrymore), a waitress that works at the reception hall where he sings. Julia's life, however, is equally miserable. Engaged to a wealthy but low-life jerk that seems more interested in himself, she questions whether he's the 'one'. Eventually, their misery brings them together and then...well, you know.
But their path to happiness (and ours) is not without a few obstacles. Robbie's financee wants another chance. Julia's mother doesn't want her to marry a wedding singer. Julia's sister becomes attracted to him. Conversations are misconstrued. And the scriptwriter goes to great pains to keep them apart. We know that they'll get together long before they finally realize that they're even attracted to one another. In fact, it's my guess that the movie bigwigs knew that there wasn't much meat in this movie. So, to compensate, they added another comical element, where the story is set in the '80s and ample opportunities are created to poke fun at this era.
For example, one of Robbie's band members dresses like Boy George; one of Robbie's friends wears the trademark red, leather jacket and white glove like Michael Jackson. And there are allusions to the future which elicited a few chuckles. At one point, a women looks at Robbie and Julia and says, "I can just tell when people will be together forever...just like Donald and Ivana; Burt and Loni." There's even a cameo by Billy Idol.
But whether you like this movie or not will depend on two things. The first is whether you like Adam Sandler. As a comedian and jokester, he's fun to watch. But he doesn't show the heft here to be a leading man. Drew Barrymore is levels above him. She is a delight to watch, but you begin to wonder what she's doing with a wedding singer...or what she's even doing in this movie.  If you are, then you can appreciate some of the cultural humor and the all-80s soundtrack. If you aren't, then this won't be a very pleasant experience. I, however, am a child of the 80s and thoroughly enjoyed Barrymore's performance. "The Wedding Singer" was flat some of the times, but at other times, managed to hit the right notes.
Grade: C+
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


--- title: Overwatch Retribution Event - A Success or a Bust? date: 2018-04-27 tags: - rajiblaze - overwatch - retribution - discussion layout: post author: Rajiblaze excerpt_separator: "" Description: Was the Retribution event good or meh? ---
Currently my pc is out of service for a while, so I’m very limited on what games to play on my much slower laptop. Surprisingly, Overwatch is one of those games I can still play!...barely. It takes a while to load everything and there is a slight input lag, but I can still play the game. Of course it’s not optimal for any serious pvp matches, so thank goodness this event came when it did. This really goes to show that Overwatch needs more pve content, as I thought the Retribution mission was outstanding. It’s like an improved version over last year’s event (which was also amazing). Everything about it I loved. The overall presentation, the use of ingame cutscenes (ala WoW), the variety of enemies, the level design. If only Blizzard can make a permanent version of one these events I’ll be golden, but for now these event-only missions will do.
How was the event for you? It’s almost over so there’s time to get the skins you want. As of now, I was only able to get the new Reaper skin, but I play him often, so that’s cool! I wouldn’t mind getting just one more skin, however it’s not a big deal. Let me know what you think in the comments!