9. Classification and Regression Metrics¶
Hayley Boyce, May 17th, 2021
# Importing our libraries
import pandas as pd
import altair as alt
import numpy as np
from sklearn.tree import DecisionTreeClassifier
from sklearn.dummy import DummyClassifier, DummyRegressor
from sklearn.neighbors import KNeighborsClassifier, KNeighborsRegressor
from sklearn.model_selection import cross_validate, train_test_split
from sklearn.svm import SVR, SVC
from sklearn import datasets
import sys
sys.path.append('code/')
from display_tree import display_tree
from plot_classifier import plot_classifier
import matplotlib.pyplot as plt
from sklearn.linear_model import LogisticRegression
# Preprocessing and pipeline
from sklearn.impute import SimpleImputer
from sklearn.metrics.pairwise import euclidean_distances
from sklearn.pipeline import Pipeline, make_pipeline
from sklearn.compose import make_column_transformer
from sklearn.preprocessing import OneHotEncoder, OrdinalEncoder, StandardScaler, MinMaxScaler
import scipy
from sklearn.model_selection import RandomizedSearchCV, GridSearchCV
9.1. House Keeping¶
Big lecture today!
Last class on Wednesday.
Assignment 3 due on Wednesday.
Question 3.2 -> most informative negative words
Project clarification (If you have a “How” business question)
9.2. Lecture Learning Objectives¶
Explain why accuracy is not always the best metric in ML.
Explain components of a confusion matrix.
Define precision, recall, and f1-score and use them to evaluate different classifiers.
Identify whether there is class imbalance and whether you need to deal with it.
Explain
class_weight
and use it to deal with data imbalance.Appropriately select a scoring metric given a regression problem.
Interpret and communicate the meanings of different scoring metrics on regression problems. MSE, RMSE, \(R^2\), MAPE.
Apply different scoring functions with
cross_validate
,GridSearchCV
andRandomizedSearchCV
.
9.3. Five Minute Recap/ Lightning Questions¶
What are the 2 types of feature selection methods we saw last class?
What is the name of the function that helps us discover features that potentially contribute to our model in Decision Trees (and other models too)
In a decision tree, where can we see the “most important” feature of the model in the structure?
Should we ever question our clients’ requests?
9.3.1. Some lingering questions¶
What happens if we have data where there is a lot of one class and very few of another?
How can we measure our model’s success besides using accuracy or \(R2\)?
9.4. Introducing Evaluation Metrics¶
Up until this point, we have been scoring our models the same way every time.
We’ve been using the percentage of correctly predicted examples for classification problems and the \(R^2\) metric for regression problems.
Let’s discuss how we need to expand our horizons and why it’s important to evaluate our models in other ways.
To help explain why accuracy isn’t always the most beneficial option, we are bringing in a new dataset.
You’ve actually seen this data at the very beginning of this course in lecture 1 but it was just a subset of the entire data.
Please download the data from Kaggle here and put it in the data folder used for the lectures.
cc_df = pd.read_csv('data/creditcard.csv', encoding='latin-1')
train_df, test_df = train_test_split(cc_df, test_size=0.3, random_state=111)
train_df.head()
| Time | V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9 | ... | V21 | V22 | V23 | V24 | V25 | V26 | V27 | V28 | Amount | Class | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 64454 | 51150.0 | -3.538816 | 3.481893 | -1.827130 | -0.573050 | 2.644106 | -0.340988 | 2.102135 | -2.939006 | 2.578654 | ... | 0.530978 | -0.860677 | -0.201810 | -1.719747 | 0.729143 | -0.547993 | -0.023636 | -0.454966 | 1.00 | 0 |
| 37906 | 39163.0 | -0.363913 | 0.853399 | 1.648195 | 1.118934 | 0.100882 | 0.423852 | 0.472790 | -0.972440 | 0.033833 | ... | 0.687055 | -0.094586 | 0.121531 | 0.146830 | -0.944092 | -0.558564 | -0.186814 | -0.257103 | 18.49 | 0 |
| 79378 | 57994.0 | 1.193021 | -0.136714 | 0.622612 | 0.780864 | -0.823511 | -0.706444 | -0.206073 | -0.016918 | 0.781531 | ... | -0.310405 | -0.842028 | 0.085477 | 0.366005 | 0.254443 | 0.290002 | -0.036764 | 0.015039 | 23.74 | 0 |
| 245686 | 152859.0 | 1.604032 | -0.808208 | -1.594982 | 0.200475 | 0.502985 | 0.832370 | -0.034071 | 0.234040 | 0.550616 | ... | 0.519029 | 1.429217 | -0.139322 | -1.293663 | 0.037785 | 0.061206 | 0.005387 | -0.057296 | 156.52 | 0 |
| 60943 | 49575.0 | -2.669614 | -2.734385 | 0.662450 | -0.059077 | 3.346850 | -2.549682 | -1.430571 | -0.118450 | 0.469383 | ... | -0.228329 | -0.370643 | -0.211544 | -0.300837 | -1.174590 | 0.573818 | 0.388023 | 0.161782 | 57.50 | 0 |
5 rows × 31 columns
train_df.shape
(199364, 31)
We can see this is a large dataset with 199364 examples and 31 features in our training set.
Hence why I can’t distribute it - it’s too big!
train_df.describe(include="all", percentiles = [])
| Time | V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9 | ... | V21 | V22 | V23 | V24 | V25 | V26 | V27 | V28 | Amount | Class | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| count |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 | ... |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |<PHONE_NUMBER>00 |
| mean | 94888.815669 | 0.000492 | -0.000726 | 0.000927 | 0.000630 | 0.000036 | 0.000011 | -0.001286 | -0.002889 | -0.000891 | ... | 0.001205 | 0.000155 | -0.000198 | 0.000113 | 0.000235 | 0.000312 | -0.000366 | 0.000227 | 88.164679 | 0.001700 |
| std | 47491.435489 | 1.959870 | 1.645519 | 1.505335 | 1.413958 | 1.361718 | 1.327188 | 1.210001 | 1.214852 | 1.096927 | ... | 0.748510 | 0.726634 | 0.628139 | 0.605060 | 0.520857 | 0.481960 | 0.401541 | 0.333139 | 238.925768 | 0.041201 |
| min | 0.000000 | -56.407510 | -72.715728 | -31.813586 | -5.683171 | -42.147898 | -26.160506 | -43.557242 | -73.216718 | -13.320155 | ... | -34.830382 | -8.887017 | -44.807735 | -2.824849 | -10.295397 | -2.241620 | -22.565679 | -11.710896 | 0.000000 | 0.000000 |
| 50% | 84772.500000 | 0.018854 | 0.065463 | 0.179080 | -0.019531 | -0.056703 | -0.275290 | 0.040497 | 0.022039 | -0.052607 | ... | -0.029146 | 0.007666 | -0.011678 | 0.041031 | 0.016587 | -0.052790 | 0.001239 | 0.011234 | 22.000000 | 0.000000 |
| max |<PHONE_NUMBER>00 | 2.451888 | 22.057729 | 9.382558 | 16.491217 | 34.801666 | 23.917837 | 44.054461 | 19.587773 | 15.594995 | ... | 27.202839 | 10.503090 | 22.083545 | 4.022866 | 6.070850 | 3.517346 | 12.152401 | 33.847808 | 11898.090000 | 1.000000 |
6 rows × 31 columns
We see that the columns are all scaled and numerical.
You don’t need to worry about this now. The original columns have been transformed already for confidentiality and our benefit so now there are no categorical features.
Let’s separate X
and y
for train and test splits.
X_train_big, y_train_big = train_df.drop(columns=["Class"]), train_df["Class"]
X_test, y_test = test_df.drop(columns=["Class"]), test_df["Class"]
We are going to be talking about evaluation metrics and it’s easier to do so if we use an explicit validation set instead of using cross-validation.
Our data is large enough so it shouldn’t be a problem.
X_train, X_valid, y_train, y_valid = train_test_split(
X_train_big, y_train_big, test_size=0.3, random_state=123)
9.4.1. Baseline¶
Just like and predictive question, we start our analysis by building a simple DummyClassifier
model as our baseline.
dummy = DummyClassifier(strategy="most_frequent")
dummy.fit(X_train, y_train)
dummy.score(X_train, y_train)
0.9983017326626252
dummy.score(X_valid, y_valid)
0.9982945995652901
Hang on, what is going on?
99.8% accuracy? This is supposed to be a baseline model! How is it getting such high accuracy?
Should we just deploy this DummyClassifier
model for fraud detection?
train_df["Class"].value_counts(normalize=True)
0 0.9983
1 0.0017
Name: Class, dtype: float64
If we look at the distribution of fraudulent labels to non-fraudulent labels, we can see there is an imbalance in the classes.
Here the 0
class is a Non fraud transaction, and the 1
class is a Fraud transaction.
We can see here that there are MANY Non fraud transactions and only a tiny handful of Fraud transactions.
So, what would be a good accuracy here? 99.9%? 99.99%?
The “Fraud” class is the class that we want to spot. The class we are interested in.
We can make a model better than the dummy classifier now.
pipe = make_pipeline(
(StandardScaler()),
(LogisticRegression(random_state=123))
)
pd.DataFrame(cross_validate(pipe, X_train, y_train, return_train_score=True)).mean()
fit_time 0.590032
score_time 0.011000
test_score 0.999176
train_score 0.999249
dtype: float64
This seems slightly better than DummyClassifier
, but the question is can it really identify fraudulent transactions?
This model will cover new tools on how to measure this.
9.5. Classification Metrics and tools¶
9.5.1. What is “positive” and “negative”?¶
There are two kinds of binary classification problems:
Distinguishing between two classes
Spotting a specific class (fraud transaction, spam, disease)
We saw in logistic regression that the model designates a positive and negative class alphabetically when classifying observation but here when we are designating a positive and negative class, we need to be a bit more thoughtful.
In the case of spotting problems, the thing that we are interested in spotting is considered “positive”.
In our example, we want to spot fraudulent transactions and so fraudulent is the “positive” class.
9.5.2. Confusion Matrix¶
A confusion matrix is a table that visualizes the performance of an algorithm. It shows the possible labels and how many of each label the model predicts correctly and incorrectly.
We can import plot_confusion_matrix
from sklearn.metrics
.
from sklearn.metrics import plot_confusion_matrix
pipe.fit(X_train, y_train);
Once we fit on our training portion, we can use the plot_confusion_matrix
function to see how well our model is doing classifying each target class.
In this case, we are looking at the validation portion only.
This results in a 2 by 2 matrix with the labels Non fraud
and Fraud
on each axis.
plot_confusion_matrix(pipe, X_valid, y_valid,
display_labels=["Non fraud", "Fraud"],
values_format="d",
cmap="Greens");
Looking at the arguments:
Similar to other sklearn
functions, we can the model/pipeline followed by the feature table and then the target value objects.
display_labels
will show more descriptive labels. without this argument, it would simply show the classes we have in the data (0
, 1
).
values_format
will determine how the numbers are displayed. Specifying d
avoids scientific notation.
cmap
is the colour argument! The default is viridis
but other values such as Blues
, Purples
, RdPu
or other colour schemes from here are also possible.
<IP_ADDRESS>. Confusion Matrix components¶
plot_confusion_matrix(pipe, X_valid, y_valid,
display_labels=["Non fraud", "Fraud"],
values_format="d", cmap="Blues");
X |
predict negative |
predict positive |
|---|---|---|
negative example |
True negative (TN) |
False positive (FP) |
positive example |
False negative (FN) |
True positive (TP) |
Remember the Fraud is considered “positive” in this case and Non fraud is considered “negative”.
The 4 quadrants of the confusion matrix can be explained as follows. These positions will change depending on what values we deem as the positive label.
True negative (TN): Examples that are negatively labelled that the model correctly predicts. This is in the top left quadrant.
False positive (FP): Examples that are negatively labelled that the model incorrectly predicts as positive. This is in the top right quadrant.
False negative (FN): Examples that are positively labelled that the model incorrectly predicts as negative. This is in the bottom left quadrant.
True positive (TP): Examples that are positively labelled that the model correctly predicted as positive. This is in the bottom right quadrant.
If you want something more numeric and simpler you can obtain a NumPy array by importing confusion_matrix
from the sklearn library. (Before we were importing plot_confusion_matrix
)
from sklearn.metrics import confusion_matrix
Here we get the predictions of the model first with .predict()
and compare it with y_valid
in the function confusion_matrix()
.
predictions = pipe.predict(X_valid)
confusion_matrix(y_valid, predictions)
array([[59700, 8],
[ 38, 64]])
9.5.3. Accuracy is only part of the story…¶
We have been using .score
to assess our models, which returns accuracy by default.
And we saw that accuracy can be misleading when we have a class imbalance.
We need other metrics to assess our models.
Note that the metrics we are going to discuss will only help us assess our model but further into this lecture we’ll talk about a few ways to address the class imbalance problem as well.
Let’s build our pipeline, and fit it. Once we’ve done that, we can create our confusion matrix.
pipe.fit(X_train,y_train);
predictions = pipe.predict(X_valid)
confusion_matrix(y_valid, predictions)
array([[59700, 8],
[ 38, 64]])
This time we are going to split up the values in the matrix into the 4 quadrants we saw earlier.
TN
for the True NegativesFP
for the False PositivesFN
for the False NegativesTP
for the True Positives
We need each of these values to explain the next measurements.
TN, FP, FN, TP = confusion_matrix(y_valid, predictions).flatten()
9.5.4. Recall¶
“Among all positive examples, how many did you identify?”
Recall: how many of the actual positive examples did you identify?
Since Fraud is our positive label, we see the correctly identified labels in the bottom right quadrant and the ones that we missed in the bottom left quadrant.
\( \text{recall} = \frac{TP}{TP + FN}\)
So here we take our true positives and we divide by all the positive labels in our validation set (the predictions the model incorrectly labelled as negative (the false negatives) as well as those correctly labelled as positive).
print('True Positives:', TP)
print('False Negatives:', FN)
True Positives: 64
False Negatives: 38
recall = TP / (TP + FN)
recall.round(4)
0.6275
9.5.5. Precision¶
“Among the positive examples you identified, how many were actually positive?”
Precision: Of the Frauds we “caught”, the fraction that was actually fraudulent.
With Fraud as our positive label, we see the correctly identified Fraudulent cases in the bottom right quadrant and the labels we incorrectly labelled as Frauds in the top right.
\( \text{recall} = \frac{TP}{TP + FP}\)
So here we take our true positives and we divide by all the positive labels that our model predicted.
print('True Positives:', TP)
print('False Positives:', FP)
True Positives: 64
False Positives: 8
precision = TP / (TP + FP)
precision.round(4)
0.8889
Of course, we’d like to have high precision and recall but the balance depends on our domain.
For credit card fraud detection, recall is really important (catching frauds), precision is less important (reducing false positives).
9.5.6. f1 score¶
Sometimes we need a single score to maximize, e.g., when doing hyperparameter tuning via RandomizedSearchCV.
Accuracy is often a bad choice.
f1-score combines precision and recall to give one score.
f1: The harmonic mean of precision and recall.
If both precision and recall go up, the f1 score will go up, so in general, we want this to be high.
print('Precision:', precision.round(4))
print('Recall:', recall.round(4))
Precision: 0.8889
Recall: 0.6275
f1_score = (2 * precision * recall) / (precision + recall)
f1_score.round(4)
0.7356
We could calculate all these evaluation metrics by hand:
data = {}
data["accuracy"] = [(TP + TN) / (TN + FP + FN + TP)]
data["error"] = [(FP + FN) / (TN + FP + FN + TP)]
data["precision"] = [ TP / (TP + FP)]
data["recall"] = [TP / (TP + FN)]
data["f1 score"] = [(2 * precision * recall) / (precision + recall)]
measures_df = pd.DataFrame(data, index=['ourselves'])
measures_df
| accuracy | error | precision | recall | f1 score | |
|---|---|---|---|---|---|
| ourselves | 0.999231 | 0.000769 | 0.888889 | 0.627451 | 0.735632 |
… or we can use scikit-learn
which has functions for these metrics.
Here we are importing accuracy_score
, precision_score
, recall_score
, f1_score
from sklearn.metrics
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score
pred_cv = pipe.predict(X_valid)
data["accuracy"].append(accuracy_score(y_valid, pred_cv))
data["error"].append(1 - accuracy_score(y_valid, pred_cv))
data["precision"].append(precision_score(y_valid, pred_cv, zero_division=1))
data["recall"].append(recall_score(y_valid, pred_cv))
data["f1 score"].append(f1_score(y_valid, pred_cv))
pd.DataFrame(data, index=['ourselves', 'sklearn'])
| accuracy | error | precision | recall | f1 score | |
|---|---|---|---|---|---|
| ourselves | 0.999231 | 0.000769 | 0.888889 | 0.627451 | 0.735632 |
| sklearn | 0.999231 | 0.000769 | 0.888889 | 0.627451 | 0.735632 |
And you can see the scores match.
We can even go one step further and “observe” the scores using a Classification report
9.5.7. Classification report¶
Similar to how a confusion matrix shows the False and True negative and positive labels, a classification report shows us an assortment of metrics, however, we can’t flatten or obtain the results from it and only see what is printed as the output.
We can import classification_report
from sklearn.metrics
from sklearn.metrics import classification_report
We can use classes
to see which position each label takes so we can designate them more comprehensive labels in our report.
pipe.classes_
array([0, 1])
In our function, we specify the true labels, followed by the predictions our model made.
The argument target_names
, gives more descriptive labels similar to what display_labels
did in plot_confusion_matrix
.
print(classification_report(y_valid, pipe.predict(X_valid),
target_names=["non fraud", "Fraud"]))
precision recall f1-score support
non fraud 1.00 1.00 1.00 59708
Fraud 0.89 0.63 0.74 102
accuracy 1.00 59810
macro avg 0.94 0.81 0.87 59810
weighted avg 1.00 1.00 1.00 59810
Note that what you consider “positive” (Fraud in our case) is important when calculating precision, recall, and f1-score.
If you flip what is considered positive or negative, we’ll end up with different True Positive, False Positive, True Negatives and False Negatives, and hence different precision, recall, and f1-scores.
The support
column just shows the number of examples in each class.
You might also be wondering about 2 additional metrics in this report…
<IP_ADDRESS>. Macro average vs weighted average¶
These metrics are more useful when predicting multiple classes which we will briefly discuss later on.
Macro average is useful when you want to give equal importance to all classes irrespective of the number of instances in each class.
Weighted average gives equal importance to all examples. So, when you care about the overall score and do not care about the score on a specific class, you could use it.
Which one is relevant, depends upon whether you think each class should have the same weight or each sample should have the same weight.
In addition to this lecture, my wonderful colleague Varada Kolhatkar has made a cheat sheet for these metrics available in a larger size here.
9.5.8. Imbalanced datasets¶
A class imbalance typically refers to having many more examples of one class than another in one’s training set.
We’ve seen this in our fraud dataset where our class
target column had many more non-fraud than fraud examples.
Real-world data is often imbalanced and can be seen in scenarios such as:
Ad clicking data (Only around ~0.01% of ads are clicked.)
Spam classification datasets.
X_train.head()
| Time | V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9 | ... | V20 | V21 | V22 | V23 | V24 | V25 | V26 | V27 | V28 | Amount | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 80437 | 58486.0 | 0.984032 | -1.851494 | 0.670618 | -1.192458 | -2.092441 | -0.511208 | -1.014356 | -0.088517 | -1.947026 | ... | 0.187838 | 0.151899 | 0.293799 | -0.200566 | 0.548729 | 0.207097 | -0.159589 | 0.005833 | 0.061062 | 249.00 |
| 60984 | 49594.0 | -0.985503 | 1.429365 | 1.528503 | 0.786004 | -0.467397 | -0.298816 | 0.080549 | 0.464257 | -1.157092 | ... | 0.255637 | -0.129198 | -0.451259 | -0.104275 | 0.346654 | -0.039245 | 0.367483 | 0.049164 | 0.053953 | 5.99 |
| 128056 | 78583.0 | -1.205750 | 0.892452 | 2.380624 | -0.016385 | -0.442344 | 0.312907 | 0.158987 | 0.048223 | 0.990212 | ... | 0.192520 | -0.072519 | 0.168212 | -0.157596 | 0.084111 | -0.172349 | 0.281843 | -0.126878 | 0.035593 | 11.50 |
| 71109 | 54160.0 | -1.221491 | 0.584432 | 0.260960 | -2.183469 | 0.148069 | -0.353845 | 0.134643 | 0.220526 | -1.162636 | ... | 0.444476 | 0.182635 | 0.720601 | -0.387976 | -0.799762 | 0.172382 | -0.287630 | 0.301891 | 0.010734 | 23.90 |
| 172062 | 120937.0 | 2.108906 | -0.036505 | -1.729322 | -0.006799 | 0.594977 | -0.414454 | 0.167962 | -0.220672 | 0.330188 | ... | -0.166839 | 0.231473 | 0.833535 | -0.151937 | -1.046125 | 0.400704 | -0.062815 | -0.021197 | -0.078745 | 0.89 |
5 rows × 30 columns
y_train.value_counts('Class')
0 0.998302
1 0.001698
Name: Class, dtype: float64
<IP_ADDRESS>. Addressing class imbalance¶
A very important question to ask yourself: “Why do I have a class imbalance?”
Is it because one class is much rarer than the other?
If it’s just because one is rarer than the other, you need to ask whether you care about False positives or False negatives more than the other.
Is it because of my data collection methods?
If it’s the data collection, then that means your test and training data come from different distributions!
But, if you answer “no” to both of these, it may be fine to just ignore the class imbalance.
<IP_ADDRESS>. Handling imbalance¶
Can we change the model itself so that it considers the errors that are important to us?
There are two common approaches to this:
Changing the training procedure
Changing the data (not in this course)
Undersampling
Oversampling
<IP_ADDRESS>. Changing the training procedure: class_weight
¶
Most sklearn
classifiers have a parameter called class_weight
.
This allows you to specify that one class is more important than another.
For example, maybe a false negative is 10x more problematic than a false positive.
So, if you look for example, in the documentation for the SVM classifier, or Logistic Regression we see class_weight
as a parameter.
class_weight: dict or ‘balanced’, default=None
Set the parameter C of class i to class_weight[i] * C for SVC.
Weights associated with classes in the form {class_label: weight} for Logistic Regression
If not given, all classes are supposed to have weight one.
The “balanced” mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as n_samples
/ (n_classes
* np.bincount(y)
).
Let’s try it out now.
First, let’s build a model where we keep the class_weights as the default.
lr_default= LogisticRegression(random_state=12, max_iter=1000)
lr_default.fit(X_train,y_train);
plot_confusion_matrix(lr_default, X_valid, y_valid,
display_labels=["Non fraud", "Fraud"],
values_format="d", cmap="Blues", ax=plt.gca());
Now let’s rebuild our pipeline but using the class_weight
argument and setting it asclass_weight={1:100}
.
This is equivalent to saying “repeat every positive example 100x in the training set”, but repeating data would slow down the code, whereas this doesn’t.
lr_100 = LogisticRegression(random_state=12, max_iter=1000, class_weight={1:100})
lr_100.fit(X_train,y_train);
plot_confusion_matrix(lr_100, X_valid, y_valid,
display_labels=["Non fraud", "Fraud"],
values_format="d", cmap="Blues", ax=plt.gca());
Notice that we now have reduced false negatives and predicted more true positives this time.
But, as a consequence, we pay a price since now we are also increasing false positives.
We can also set class_weight="balanced"
.
This sets the weights so that the classes are “equal”.
lr_balanced = LogisticRegression(random_state=12, max_iter=1000, class_weight="balanced")
lr_balanced.fit(X_train,y_train);
plot_confusion_matrix(lr_balanced, X_valid, y_valid,
display_labels=["Non fraud", "Fraud"],
values_format="d", cmap="Blues", ax=plt.gca());
Again, we have reduced the number of false negatives and increased the number of true positives but we have many more false positives now!
<IP_ADDRESS>. Are we doing better with class_weight="balanced"
?¶
Let’s compare some metrics and find out.
lr_default.score(X_valid, y_valid)
0.99923089784317
lr_balanced.score(X_valid, y_valid)
0.9628657415147969
Changing the class weight will generally reduce accuracy.
The original model was trying to maximize accuracy. Now you’re telling it to do something different.
But we know now that accuracy isn’t the only metric that matters.
Let’s explain why this happens.
Since there are so many more negative examples than positive ones, false-positives affect accuracy much more than false negatives.
Thus, precision matters a lot more than recall in this accuracy calculation.
So, the default method trades off a lot of recall for a bit of precision.
We are paying a “fee” in precision for a greater recall value.
9.6. Let’s Practice¶
Use the diagram above to answer the next …. questions.
1. How many examples did the model of this matrix correctly label as “Guard”?
2. If Forward is the positive label, how many false-positive values are there?
3. How many examples does the model incorrectly predict?
4. What is the recall of the confusion matrix assuming that Forward is the positive label?
5. What is the precision of the confusion matrix assuming that Forward is the positive label?
6. What is the f1 score assuming that Forward is the positive label?
True or False:
7. In spam classification, false positives are more damaging than false negatives (assume “positive” means the email is spam, “negative” means it’s not).
8. In medical diagnosis, high recall is more important than high precision.
9. The weighted average gives equal importance to all classes.
10. Setting class_weight={1:100}
will make the second class label 100 times the weight of the first class.
Solutions!
26
4
7
\(0.86 = 19/22\)
\(0.83 = 19/23\)
\( 2 * \frac{0.86 * 0.83}{0.86 + 0.83} = 0.84\)
True
True
False
False
9.7. Regression Metrics¶
For this part, since we need to use data that corresponds to a regression problem, we are bringing back our California housing dataset.
We want to predict the median house value for different locations.
housing_df = pd.read_csv("data/housing.csv")
train_df, test_df = train_test_split(housing_df, test_size=0.1, random_state=123)
train_df = train_df.assign(rooms_per_household = train_df["total_rooms"]/train_df["households"],
bedrooms_per_household = train_df["total_bedrooms"]/train_df["households"],
population_per_household = train_df["population"]/train_df["households"])
test_df = test_df.assign(rooms_per_household = test_df["total_rooms"]/test_df["households"],
bedrooms_per_household = test_df["total_bedrooms"]/test_df["households"],
population_per_household = test_df["population"]/test_df["households"])
train_df = train_df.drop(columns=['total_rooms', 'total_bedrooms', 'population'])
test_df = test_df.drop(columns=['total_rooms', 'total_bedrooms', 'population'])
X_train = train_df.drop(columns=["median_house_value"])
y_train = train_df["median_house_value"]
X_test = test_df.drop(columns=["median_house_value"])
y_test = test_df["median_house_value"]
numeric_features = [ "longitude", "latitude",
"housing_median_age",
"households", "median_income",
"rooms_per_household",
"bedrooms_per_household",
"population_per_household"]
categorical_features = ["ocean_proximity"]
X_train.head()
| longitude | latitude | housing_median_age | households | median_income | ocean_proximity | rooms_per_household | bedrooms_per_household | population_per_household | |
|---|---|---|---|---|---|---|---|---|---|
| 6051 | -117.75 | 34.04 | 22.0 | 602.0 | 3.1250 | INLAND | 4.897010 | 1.056478 | 4.318937 |
| 20113 | -119.57 | 37.94 | 17.0 | 20.0 | 3.4861 | INLAND | 17.300000 | 6.500000 | 2.550000 |
| 14289 | -117.13 | 32.74 | 46.0 | 708.0 | 2.6604 | NEAR OCEAN | 4.738701 | 1.084746 | 2.057910 |
| 13665 | -117.31 | 34.02 | 18.0 | 285.0 | 5.2139 | INLAND | 5.733333 | 0.961404 | 3.154386 |
| 14471 | -117.23 | 32.88 | 18.0 | 1458.0 | 1.8580 | NEAR OCEAN | 3.817558 | 1.004801 | 4.323045 |
We are going to bring in our previous pipelines and fit our model.
numeric_transformer = Pipeline(
steps=[("imputer", SimpleImputer(strategy="median")),
("scaler", StandardScaler())]
)
categorical_transformer = Pipeline(
steps=[("imputer", SimpleImputer(strategy="constant", fill_value="missing")),
("onehot", OneHotEncoder(handle_unknown="ignore"))]
)
preprocessor = make_column_transformer(
(numeric_transformer, numeric_features),
(categorical_transformer, categorical_features),
remainder='passthrough')
pipe = make_pipeline(preprocessor, KNeighborsRegressor())
pipe.fit(X_train, y_train);
As you know, since we aren’t doing classification anymore, so we can’t just check for equality.
predicted_y = pipe.predict(X_train)
predicted_y
array([111740., 117380., 187700., ..., 271420., 265180., 60860.])
y_train.values
array([113600., 137500., 170100., ..., 286200., 412500., 59300.])
predicted_y == y_train
6051 False
20113 False
14289 False
13665 False
14471 False
...
7763 False
15377 False
17730 False
15725 False
19966 False
Name: median_house_value, Length: 18576, dtype: bool
We need a score that reflects how right/wrong each prediction is or how close we are to the actual numeric value.
We are going to discuss 4 different ones lightly but, if you want to see more regression metrics in detail, you can refer to the sklearn documentation.
9.7.1. Mean squared error (MSE)¶
Mean Squared Error is a common measure.
We calculate this by calculating the difference between the predicted and actual value, square it and sum all these values for every example in the data.
The higher the MSE, the worse the model performs.
predicted_y
array([111740., 117380., 187700., ..., 271420., 265180., 60860.])
((y_train - predicted_y)**2).mean()
2570054492.048064
Perfect predictions would have MSE=0.
We can see that by using y_train
instead of predicted_y
which demonstrates how we get 0 as a result.
((y_train - y_train)**2).mean()
0.0
We can use mean_squared_error
from sklearn.metrics
again instead of calculating this ourselves.
from sklearn.metrics import mean_squared_error
mean_squared_error(y_train, predicted_y)
2570054492.048064
<IP_ADDRESS>. The disadvantages¶
If we look at MSE here, it’s huge and unreasonable.
Is this score good or bad?
Unlike classification, in regression, our target has units.
In this case, our target column is the median housing value which is in dollars.
That means that the mean squared error is in dollars\(^2\).
The score also depends on the scale of the targets.
If we were working in cents instead of dollars, our MSE would be 10,000 X (1002) higher!
9.7.2. Quick recap on \(R^2\)¶
We’ve seen this before!
This is the score that sklearn
uses by default when you call .score()
so we’ve already seen \(R^2\) in our regression problems.
You can read about it here but we are going to just give you the quick notes.
Intuition: mean squared error, but flipped where higher values mean a better measurement.
It’s normalized so the max is 1.
We can use the default scoring from .score()
or we can calculate \(R^2\) using r2_score
from sklearn.metrics
from sklearn.metrics import r2_score
When you call fit
it minimizes MSE / maximizes R2 (or something like that) by default.
Just like how accuracy isn’t always what you want in classification, \(R^2\) isn’t always what you want in regression!
Another important thing to note is that we can reverse MSE but not R2 (optional).
print(mean_squared_error(y_train, predicted_y))
print(mean_squared_error(predicted_y, y_train))
2570054492.048064
2570054492.048064
print(r2_score(y_train, predicted_y))
print(r2_score(predicted_y, y_train))
0.8059396097446094
0.742915970464153
9.7.3. Root mean squared error (RMSE)¶
Remember the MSE we had before was in \(dollars^2\). A more relatable metric would be the root mean squared error, or RMSE.
This is the square root of \(MSE\).
mean_squared_error(y_train, predicted_y)
2570054492.048064
np.sqrt(mean_squared_error(y_train, predicted_y))
50695.704867849156
This now has the units in dollars. Instead of 2 billion dollars squared, our error measurement is around $50,000.
Let’s plot the predicted vs the true housing prices here.
df = pd.DataFrame(y_train).assign(predicted = predicted_y).rename(columns = {'median_house_value': 'true'})
df = pd.DataFrame(y_train).assign(predicted = predicted_y).rename(columns = {'median_house_value': 'true'})
plt.scatter(y_train, predicted_y, alpha=0.3, s = 5)
grid = np.linspace(y_train.min(), y_train.max(), 1000)
plt.plot(grid, grid, '--k');
plt.xticks(fontsize= 12);
plt.yticks(fontsize= 12);
plt.xlabel("true price", fontsize=14);
plt.ylabel("predicted price", fontsize=14);
When we plot our predictions versus the examples’ actual value, we can see cases where our prediction is way off.
Points under the line \(y=x\) means we’re under-predicting price, points over the line means we’re over-predicting price.
Question: Is an error of $30,000 acceptable?
For a house worth $600k, it seems reasonable! That’s a 5% error.
For a house worth $60k, that is terrible. It’s a 50% error.
So how can we adjust to this?
…Enter MAPE!
9.7.4. MAPE - Mean Absolute Percent Error (MAPE)¶
We can calculate a percentage error for each example. Now the errors are both positive (predict too high) and negative (predict too low).
We can look at the absolute percent error which now shows us how far off we were independent of direction.
Like MSE, we can take the average over all the examples. This is called Mean Absolute Percent Error (MAPE).
Ok, this is quite interpretable. We can see that on average, we have around 18% error in our predicted median housing valuation.
We can calculate a percentage error for each example. Now the errors are both positive (predict too high) and negative (predict too low).
percent_errors = (predicted_y - y_train)/y_train * 100.
percent_errors.head()
6051 -1.637324
20113 -14.632727
14289 10.346855
13665 6.713070
14471 -10.965854
Name: median_house_value, dtype: float64
We can look at the absolute percent error which now shows us how far off we were independent of direction.
np.abs(percent_errors).head()
6051 1.637324
20113 14.632727
14289 10.346855
13665 6.713070
14471 10.965854
Name: median_house_value, dtype: float64
And like MSE, we can take the average over all the examples.
np.abs(percent_errors).mean()
18.192997502985218
This is called Mean Absolute Percent Error (MAPE).
This is quite interpretable. We can see that on average, we have around 18% error in our predicted median housing valuation.
9.8. Let’s Practice¶
1. Which measurement will have units which are the square values of the target column units?
2. For which of the following is it possible to have negative values?
3. Which measurement is expressed as a percentage?
4. Calculate the MSE from the values given below.
Observation |
True Value |
Predicted Value |
|---|---|---|
0 |
4 |
5 |
1 |
12 |
10 |
2 |
6 |
9 |
3 |
9 |
8 |
4 |
3 |
3 |
True or False:
5. We can still use recall and precision for regression problems but now we have other measurements we can use as well.
6. A lower RMSE value indicates a better model.
7. In regression problems, calculating \(R^2\) using r2_score()
and .score()
(with default values) will produce the same results.
Solutions!
\(MSE\)
\(R^2\)
\(MAPE\)
3
False
True
True
9.9. Passing Different Scoring Methods¶
We now know about all these metrics; how do we implement them?
We are lucky because it’s relatively easy and can be applied to both classification and regression problems.
Let’s start with regression and our regression measurements.
This means bringing back our California housing dataset.
X_train.head()
| longitude | latitude | housing_median_age | households | median_income | ocean_proximity | rooms_per_household | bedrooms_per_household | population_per_household | |
|---|---|---|---|---|---|---|---|---|---|
| 6051 | -117.75 | 34.04 | 22.0 | 602.0 | 3.1250 | INLAND | 4.897010 | 1.056478 | 4.318937 |
| 20113 | -119.57 | 37.94 | 17.0 | 20.0 | 3.4861 | INLAND | 17.300000 | 6.500000 | 2.550000 |
| 14289 | -117.13 | 32.74 | 46.0 | 708.0 | 2.6604 | NEAR OCEAN | 4.738701 | 1.084746 | 2.057910 |
| 13665 | -117.31 | 34.02 | 18.0 | 285.0 | 5.2139 | INLAND | 5.733333 | 0.961404 | 3.154386 |
| 14471 | -117.23 | 32.88 | 18.0 | 1458.0 | 1.8580 | NEAR OCEAN | 3.817558 | 1.004801 | 4.323045 |
And our pipelines.
This time we are using \(k\)-nn.
numeric_transformer = Pipeline(
steps=[("imputer", SimpleImputer(strategy="median")),
("scaler", StandardScaler())]
)
categorical_transformer = Pipeline(
steps=[("imputer", SimpleImputer(strategy="constant", fill_value="missing")),
("onehot", OneHotEncoder(handle_unknown="ignore"))]
)
preprocessor = make_column_transformer(
(numeric_transformer, numeric_features),
(categorical_transformer, categorical_features),
remainder='passthrough')
pipe_regression = make_pipeline(preprocessor, KNeighborsRegressor())
9.9.1. Cross-validation¶
Normally after building our pipelines, we would now either do cross-validation or hyperparameter tuning but let’s start with the cross_validate()
function.
All the possible scoring metrics that this argument accepts are available here in the sklearn documentation.
In this case, if we wanted the RMSE measure, we would specify neg_mean_squared_error
and the negated value of the metric will be returned in our dataframe.
pd.DataFrame(cross_validate(pipe_regression,
X_train, y_train,
return_train_score=True,
# scoring = 'neg_root_mean_squared_error')
))
| fit_time | score_time | test_score | train_score | |
|---|---|---|---|---|
| 0 | 0.039957 | 0.289924 | 0.695818 | 0.801659 |
| 1 | 0.032168 | 0.278022 | 0.707483 | 0.799575 |
| 2 | 0.033430 | 0.300306 | 0.713788 | 0.795944 |
| 3 | 0.037170 | 0.280229 | 0.686938 | 0.801232 |
| 4 | 0.031539 | 0.219956 | 0.724608 | 0.832498 |
pd.DataFrame(cross_validate(pipe_regression,
X_train, y_train,
return_train_score=True,
scoring = 'neg_root_mean_squared_error')
)
| fit_time | score_time | test_score | train_score | |
|---|---|---|---|---|
| 0 | 0.036687 | 0.292240 | -62462.584290 | -51440.540539 |
| 1 | 0.033530 | 0.250330 | -63437.715015 | -51263.979666 |
| 2 | 0.030526 | 0.250198 | -62613.202523 | -51758.817852 |
| 3 | 0.029188 | 0.274914 | -64204.295214 | -51343.743586 |
| 4 | 0.028573 | 0.208082 | -59217.838633 | -47325.157312 |
Sometimes they don’t have the scoring measure that we want and that’s ok.
We can make our own using the make_scorer
from sklearn.
First, we import make_scorer
from Sklearn
.
from sklearn.metrics import make_scorer
Next, we can make a function calculating our desired measurement. In this case, we are making a function that has the true and predicted values as inputs and then returns the Mean Absolute percentage Error.
def mape(true, pred):
return 100.*(np.abs((pred - true)/true)).mean()
We can turn this into something that the scoring
argument will understand by putting our created MAPE function as an input argument in make_scorer()
.
Now when we cross-validate, we can specify the new mape_scorer
as our measure.
mape_scorer = make_scorer(mape)
Now when we cross-validate, we can specify the new mape_scorer
as our measure.
pd.DataFrame(cross_validate(
pipe_regression, X_train, y_train, return_train_score=True, scoring=mape_scorer))
| fit_time | score_time | test_score | train_score | |
|---|---|---|---|---|
| 0 | 0.039827 | 0.394224 | 22.709732 | 18.420969 |
| 1 | 0.062865 | 0.408991 | 22.754570 | 18.469125 |
| 2 | 0.032953 | 0.245034 | 22.236869 | 18.674964 |
| 3 | 0.031604 | 0.255892 | 23.016666 | 18.510766 |
| 4 | 0.038290 | 0.278134 | 21.033519 | 16.951021 |
Now our cross-validation returns percentages!
We can also return multiple scoring measures together by making a dictionary and then specifying the dictionary in the scoring
argument.
scoring={
"r2": "r2",
"mape_score": mape_scorer,
"neg_rmse": "neg_root_mean_squared_error",
"neg_mse": "neg_mean_squared_error",
}
pd.DataFrame(cross_validate(pipe_regression,
X_train, y_train,
return_train_score=True,
scoring=scoring))
| fit_time | score_time | test_r2 | train_r2 | test_mape_score | train_mape_score | test_neg_rmse | train_neg_rmse | test_neg_mse | train_neg_mse | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0.037458 | 0.299782 | 0.695818 | 0.801659 | 22.709732 | 18.420969 | -62462.584290 | -51440.540539 | -3.901574e+09 | -2.646129e+09 |
| 1 | 0.031972 | 0.261208 | 0.707483 | 0.799575 | 22.754570 | 18.469125 | -63437.715015 | -51263.979666 | -4.024344e+09 | -2.627996e+09 |
| 2 | 0.031364 | 0.261568 | 0.713788 | 0.795944 | 22.236869 | 18.674964 | -62613.202523 | -51758.817852 | -3.920413e+09 | -2.678975e+09 |
| 3 | 0.030382 | 0.263205 | 0.686938 | 0.801232 | 23.016666 | 18.510766 | -64204.295214 | -51343.743586 | -4.122192e+09 | -2.636180e+09 |
| 4 | 0.032217 | 0.221644 | 0.724608 | 0.832498 | 21.033519 | 16.951021 | -59217.838633 | -47325.157312 | -3.506752e+09 | -2.239671e+09 |
This returns a validation and training score for each measurement!
9.9.2. What about hyperparameter tuning?¶
We can do exactly the same thing we saw above with cross_validate()
but instead with GridSearchCV
and RandomizedSearchCV
.
param_grid = {"kneighborsregressor__n_neighbors": [2, 5, 50, 100]}
grid_search = GridSearchCV(pipe_regression, param_grid, cv=5,
return_train_score=True, n_jobs=-1,
scoring= mape_scorer);
grid_search.fit(X_train, y_train);
grid_search.best_params_
{'kneighborsregressor__n_neighbors': 100}
grid_search.best_score_
24.63336199650092
Ok wait hold on, let’s think about this again.
The way that best_params_
works is that it selects the parameters where the scoring measure selected is the highest. The problem with that is MAPE is an error, and we want the parameter with the lowest value, not the highest.
We use the argument greater_is_better
to specify if larger values make it a better score or a worse score. The default for this is True
.
We can create a new MAPE scorer by adding the argument greater_is_better=False
in make_scorer
.
neg_mape_scorer = make_scorer(mape, greater_is_better=False)
grid_search = GridSearchCV(pipe_regression, param_grid, cv=5,
return_train_score=True, n_jobs=-1,
scoring= neg_mape_scorer);
grid_search.fit(X_train, y_train);
Now our best_params_
will return the parameters will the lowest MAPE (least amount of error).
grid_search.best_params_
{'kneighborsregressor__n_neighbors': 5}
grid_search.best_score_
-22.350271196169718
That’s better!
9.9.3. … and with Classification?¶
Let’s bring back our credit card data set and build our pipeline.
cc_df = pd.read_csv('data/creditcard.csv', encoding='latin-1')
train_df, test_df = train_test_split(cc_df, test_size=0.3, random_state=111)
X_train, y_train = train_df.drop(columns=["Class"]), train_df["Class"]
X_test, y_test = test_df.drop(columns=["Class"]), test_df["Class"]
We can use class_weight='balanced'
in our classifier…
dt_model = DecisionTreeClassifier(random_state=123, class_weight='balanced')
param_grid = {"max_depth": scipy.stats.randint(low=1, high=100)}
… and tune our model for the thing we care about.
In this case, we are specifying the f1
score.
grid_search = RandomizedSearchCV(dt_model, param_grid, cv=5, return_train_score=True,
verbose=1, n_jobs=-1, scoring= 'f1', n_iter = 6)
grid_search.fit(X_train, y_train);
Fitting 5 folds for each of 6 candidates, totalling 30 fits
grid_search.best_params_
{'max_depth': 91}
grid_search.best_score_
0.7190834822443745
This returns the max_depth
value that results in the highest f1
score, not the max_depth
with the highest accuracy.
9.10. Let’s Practice¶
True or False:
1. The scoring
argument only accepts str
inputs.
2. We are limited to the scoring measures offered from sklearn.
3. If we specify the scoring method in GridSearchCV
and RandomizedSearchCV
, best_param_
will return the parameters with the best specified measure.*
Solutions!
False
False
True
9.11. Let’s Practice - Coding¶
Let’s bring back the Pokémon dataset that we saw previously.
This time let’s look at the distribution of our target variable legendary
.
from sklearn.model_selection import train_test_split
pk_df = pd.read_csv('data/pokemon.csv')
train_df, test_df = train_test_split(pk_df, test_size=0.2, random_state=1)
X_train_big = train_df.drop(columns=['legendary'])
y_train_big = train_df['legendary']
X_test = test_df.drop(columns=['legendary'])
y_test = test_df['legendary']
X_train, X_valid, y_train, y_valid = train_test_split(X_train_big,
y_train_big,
test_size=0.3,
random_state=123)
print(y_train.value_counts())
0 405
1 43
Name: legendary, dtype: int64
Let’s do cross-validation and look at the scores from cross-validation of not just accuracy, but precision and recall and the f1 score as well.
Build a pipeline containing the column transformer and an SVC model and set
class_weight="balanced"
in the SVM classifier.Perform cross-validation using cross-validate on the training split using the scoring measures accuracy, precision, recall and f1.
Save the results in a dataframe.
9.12. What We’ve Learned Today¶
The components of a confusion matrix.
How to calculate precision, recall, and f1-score.
How to implement the
class_weight
argument.Some of the different scoring metrics used in assessing regression problems; MSE, RMSE, \(R^2\), MAPE.
How to apply different scoring functions with
cross_validate
,GridSearchCV
andRandomizedSearchCV
.


Overview
Classes: Name, NamePool, NamespacePrefixesStrategy, NamespaceStrategy, NoNamespacePrefixesStrategy, NoNamespacesStrategy, ParserEngine, XMLException, XMLWriter
Functions: fromXMLString, swap, toXMLString
Classes
class Name
An XML element or attribute name, consisting of a qualified name, a namespace URI and a local name.
class NamePool
A hashtable that stores XML names consisting of an URI, a local name and a qualified name.
class NamespacePrefixesStrategy
The NamespaceStrategy implementation used if namespaces processing is requested and prefixes are reported.
class NamespaceStrategy
This class is used by ParserEngine to handle the startElement, endElement, startPrefixMapping and endPrefixMapping events.
class NoNamespacePrefixesStrategy
The NamespaceStrategy implementation used if namespaces processing is requested, but prefixes are not reported.
class NoNamespacesStrategy
The NamespaceStrategy implementation used if no namespaces processing is requested.
class ParserEngine
This class provides an object-oriented, stream-based, low-level interface to the XML Parser Toolkit (expat).
class XMLException
class XMLWriter
This class serializes SAX2 ContentHandler, LexicalHandler and DTDHandler events back into a stream.


JSS | JSS Science And Technology
JSS
Dashboard
Departments
MCA
BCA
Add Department
Change Password
Sign out
welcome
Department of MCA
click which year??
3RD Semester
4TH Semester
5TH Semester
6TH Semester
subjects
internal 1
internal 2
internal 3
semExam
DataStructure
Java Programming
System Software
MIS
mathematics
subjects
internal 1
internal 2
internal 3
semExam
Advance Java
ADA
operating system


|
(This body text is the "feature" class for paragraphs) The
Center for Teaching, Learning, and Technology offers a wide-range of
professional development opportunities this summer to support how you
teach and how your students learn. Once again, we're partnering with
talented faculty and staff from across campus to explore topics ranging
from online course design and delivery to effective communication with students regardless of modality.
If you need a special accommodation to fully participate in a CTLT event, please email
<EMAIL_ADDRESS>|


Hi! My name is Brian Lyu, and I'm currently a third year student at UC San Diego. I'm currently majoring in Computer Science and Engineering, with a focus in full stack development. In my free time, I'm a huge fan of basketball, hiking, and travelling to new countries! Check out my projects below...


--- layout: archive title: Zulip Chat Archive permalink: /stream/113488-general/topic/export.3F.html ---
From lean core:
class has_pow (α : Type u) (β : Type v) := (pow : α → β → α) export has_andthen (andthen) export has_pow (pow)
What does export
do? The line reminds me of those old batman TV shows.
like open
oh I just remembered #help
export: create aliases for declarations
At the end of the day, does this just mean that pow
can be used instead of has_pow.pow
?
Aah -- does it mean that this is true globally?
I see -- #check pow
seems to work fine in a new file
so it's open on steroids
"open and never close"?
No, I guess that is an artifact of the fact that it is in core.
Hmm, no... that is not what I meant.
"open and never close"?
Yes, basically. You can locally "close" it with hide
.
Thanks Sebastian.
The reason I asked was that I noticed that if I import tactic.ring
then I can do a ^ 2
for a in a comm_ring
, but I can't do this otherwise. I was just trying to figure out where that instance was defined, but I don't know how to do this, short of looking at what tactic.ring
imports and importing all of those things instead, until I finally find the import which actually makes it work.
That's one approach -- and searching for has_pow.pow is another, but actually I should just search for pow
perhaps
Got it -- obviously to get powers in a ring the key import is group_power.lean
;-)
[mumble mumble monoid]
{% endraw %}Last updated: Apr 24 2020 at 19:02 UTC


I am currently a Master of Science in Information student in the School of Information at the University of Michigan. I am on the big data analytics track. My main courses include Natural Language Processing, Information Retrieval, Applied Machine Learning, Data Mining etc.
I got my B.S.E degree at Shanghai Jiao Tong University, majoring in Electrical and Computer Engineering.
I interned at JcDecaux,Shanghai this summer, where I worked on a bus advertising asset pricing system. We analyzed passenger data of over 800 bus lines in Nanjing and Shenzhen, and deployed a pricing strategy based on amount of passenger views, passenger features(interests, spending power etc.), asset type etc.


datefield - Tk datefield widget
The datefield package provides the datefield widget which is an enhanced text entry widget for the purpose of date entry. There are three valid formats for the dates which can be entered:
English form MM/DD/YYYY using -format "%m/%d/%Y" (default)
German form DD.MM.YYYY using -format "%d.%m.%Y"
ISO form YYYY-MM-DD using -format "%Y-%m-%d"
The datefield widget is, in fact, just an entry widget with specialized bindings. This means all the command and options for an entry widget apply equally here.
Creates and configures a date field widget.
One of "%m/%d/%Y" (English, default if option left), "%d.%m.%Y" (German), or "%Y-%m-%d" (ISO).
See the entry manual entry for details on all remaining/available options.
package require datefield wm title . "Datefield example" proc DayOfWeek {args} { set now [clock scan $::myDate] set ::myDate2 [clock format $now -format %A] } trace variable myDate w DayOfWeek ::datefield::datefield .df -textvariable myDate -format "%m/%d/%Y" label .l1 -text "Enter a date:" -anchor e label .l2 -text "That date is a:" -anchor e label .l3 -textvariable myDate2 -relief sunken -width 12 grid .l1 .df -sticky ew grid .l2 .l3 -sticky ew focus .df
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category datefield of the Tklib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.
clock(n), entry(n)
Widget
Copyright © Keith Vetter<EMAIL_ADDRESS>Copyright © Thomas Wunderlich <tcl.tk@blindenfreizeiten.de>


--- layout: about ---
costas.basdekis[at]gmail[dot]com
I'm software developer, working in London at TangentLabs, part of Tangent Snowball.
I like all things programming, continually trying to improve and hone my craft. I love Python and JS, and recently started falling in love with Haskell.


--- layout: archive title: Zulip Chat Archive permalink: /stream/113489-new-members/topic/How.20do.20I.20go.20from.20.3C.20to.20.E2.89.A4.html ---
If we have a < b := a ≤ b ∧ ¬ (b ≤ a)
and h : a < b
can I just have h1 : a ≤ b := h.left
? (Doesn't seem to work.)
I'm aware of le_of_lt
but I'm still curious about why h.left
won't do.
Does change a ≤ b ∧ ¬ (b ≤ a) at h
work?
If not, then I'm afraid that in your context the definition of <
might be something else.
I would need a MWE to help further.
Does
change a ≤ b ∧ ¬ (b ≤ a) at h
work?
pasted image
Doesn't seem to work in this toy case.
I tried ℕ, ℚ, ℝ
it seems change
only work for ℚ
So I guess that means that ≤
is not defined the way you think it is.
IIRC the definition of < on nat is something like succ a.<= b
OK.
Is the AM-GM inequality proved anywhere in mathlib? I was trying this as an exercise, still lots of frustrations
There is a theorem that says a < b <-> a ≤ b ∧ ¬ (b ≤ a)
baked into the definition of preorder
, but it is not a definition, it is a constraint on implementations. The actual definition is provided by the particular structure, and many structures have different definitions for this, for example succ a <= b
for nat
If you leave the definition out when defining a preorder, the default definition is a < b := a ≤ b ∧ ¬ (b ≤ a)
I don't recall seeing AM-GM in mathlib, there is a relatively straightforward proof using square roots and the sqrt
API is good enough to make implementation not too hard.
Doesn't AM-GM need an nth root API?
Oh for n variables?
Yeah.
I'm not sure I know which proof to formalise for n variables. There's a proof that does powers of 2 first and deduces the general case
That is the one I had in mind. But for that one needs to prove some general induction stuff I guess.
But even to go from AG4 to AG3 is kinda painful for me right now.
I don't remember the trick. Do you let the dummy variable be the GM?
Yeah. apply AM-GM for a,b,c,d
where d = 3√(abc)
import data.real.basic open real theorem AG2 (x y : ℝ) (hx : 0 ≤ x) (hy : 0 ≤ y) : sqrt (x * y) ≤ (x + y) / 2 := begin have h : 0 ≤ (sqrt x - sqrt y) * (sqrt x - sqrt y), apply mul_self_nonneg, rw [mul_sub, sub_mul, sub_mul, ←sqrt_mul hx, ←sqrt_mul hx, ←sqrt_mul hy, ←sqrt_mul hy, sqrt_mul_self hx, sqrt_mul_self hy, mul_comm] at h, linarith, end
There's 2 ;-) Sorry, I thought that was what we were talking about at first.
I was trying lemma ag3 (a b c : nnreal) : 3 * (a * b * c) ≤ a ^ 3 + b ^ 3 + c ^ 3 := sorry
but it seems I will have to write instance : has_pow nnreal ℚ
anyway.
I don't know how well developed things like nnreal
are. Does linarith
work with them?
I just stuck to the reals and put non-negativity hypotheses in.
Oh, OK. put non-negativity hypotheses in sounds good.
(But still need to define has_pow
somewhere I guess.)
I don't remember the trick. Do you let the dummy variable be the GM?
BTW let the dummy variable be AM works too. But neither seem completely trivial for me as a beginner -- I always got stuck on some seemingly very trivial algebraic operation in Lean.
I agree that proving it for n variables is a tall order in lean for a beginner
I think that the proper way to prove this inequality is to prove https://en.wikipedia.org/wiki/Jensen%27s_inequality
This way we can (a) assign weights to variables; (b) prove that the square mean is greater than the arithmetic mean; (c) if/once we prove that the center of mass of a measure supported on a convex set belongs to this set, we can have integral versions of these inequalities.
{% endraw %}Last updated: Apr 24 2020 at 19:02 UTC


[gecode-users] Ordering of propagators
Christian Schulte
cschulte at kth.se
Tue Apr 10 15:15:09 CEST 2007
Hi Peter,
yes you are right: propagators with lower cost are most likely to be run
before propagators with higher cost.
The cost values basically capture some levels of constant runtime and then
some levels of asymptotic runtime. The order in which they are defined, also
describes the order in which propagators are likely to be picked for
execution.
The addendum "likely" has to do with the fact that some of the symbolic
costs (for example, PC_BINARY_LO and PC_UNARY_LO) are mapped to the same
actual cost level. For an anlysis of this, please check:
http://web.it.kth.se/~schulte/paper.html?id=SchulteStuckey:CCoR:2006
What do you mean with how the cost function is used? Could you elaborate,
please?
Cheers
Christian
--
Christian Schulte, http://www.imit.kth.se/~schulte/
-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Peter Tiedemann
Sent: Tuesday, April 10, 2007 10:17 AM
To: users at gecode.org
Subject: [gecode-users] Ordering of propagators
Hi,
Is there some way to ensure ( or just strongly suggest) that a propagator is
scheduled to run only after the other propagators have stabilized ( or thats
its just in general pushed to the back of the propagation queue) ?
I thought perhaps the propagation cost() function could achieve an effect
like this, if it returns a very high cost?
Related to this, how is the cost() function used exactly? I cant seem to
find any information on this in the documentation.
Regards,
Peter Tiedemann
_______________________________________________
Gecode users mailing list
users at gecode.org https://www.gecode.org/mailman/listinfo/gecode-users
More information about the gecode-users
mailing list


Time Warner Cable (TWC) is the third largest broadband provider in the U.S. They are able to service more than 65 million customers across 29 states. TWC brings their customers affordable TV, internet, and phone services as well as bundles that will help you save even more money. Each package can be tailored to fit your needs. From the internet browser to the video streaming master and from the occasional television watcher to the sports fanatic. Read the information we have compiled below and see if Time Warner Cable is a fit for you.
Time Warner allows you to watch more than 100 shows in crystal clear high definition (HD). They also bring you more than 30,000 movie and television shows On Demand. Never miss a moment of your favorite shows with a Time Warner DVR, which allows you record, pause, or rewind live television. Download the TWC app on your phone, tablet, or computer and bring your cable service with you wherever you go. TWC also has a pay-per-view option so that you never miss the big sports games or matches.
Time Warner Cable brings you internet speeds ranging from 15Mbps to 50Mbps. Their internet plans all have complimentary email accounts, access to Hotspots, and parental control. If you are ever having issues with your service, there is a TWC customer service representative available 24/7. Time Warner Cable guarantees customer satisfaction and easy installation.
With Double and Triple Play options, you will be able to pick exactly what fits your needs and budget. Surf the internet at lightning fast speeds or just browse. Watch all your favorite TV shows and be able to take them on the go. Enjoy unlimited free calling anywhere in the nation and to Mexico and Canada. No hassle installation and no contract requirements will help you find exactly what you need.


This type of Semaphore uses a count that helps task to be acquired or released numerous times. If the initial count = 0, the counting semaphore should be created in the unavailable state.A counting semaphore can be any non-negative integer, also known as a whole number. Its value may increase or decrease based on the results of one or more functions. For example, a counting semaphore may keep track of the number of available resources in a resource pool. If the semaphore decrements more than it increments, it will eventually reach 0. A zero value indicates there are no more resources left.
Process in blocked state


onMouseMove property
Stream of mousemove
events handled by this Document.
Implementation
Stream<MouseEvent> get onMouseMove => Element.mouseMoveEvent.forTarget(this);
Stream of mousemove
events handled by this Document.
Stream<MouseEvent> get onMouseMove => Element.mouseMoveEvent.forTarget(this);


Command to run the app
Pre-requisites: You must have Node.js and npm installed.
API Key
You should make sure you update the files with your name, Twitter API key, and contact
information.
If you have trouble with getting a Twitter Developer account, you could follow these steps
listed
in this document
Build and Run
If you're not yet running the static server, you can do so by running the following
command on your terminal:
npm install
npm run gulp
npm start


Flawlessly configure dev environments in one click
No matter how complex your project is, Koding for teams makes it easy to share your entire development stack with anyone, anywhere.
A flawless replica of your dev project
A flawless replica of your dev project
Cloud VM Create
Packages Installed
Codebase Pulled In
Configuration Done
If you can build it in the cloud, you can build it with Koding for Teams.
Integrate any service with a few lines of code.
Whether you use Heroku with MongoDB & Node.js, or AWS with Ruby and MySQL, Koding’s powerful configuration manager can handle it. Just add the service you need to Koding’s stack script, and voilå — you're ready to roll.
{% include features-content.html
title1="The power of AWS without the pain."
column1="Get your whole team working on cloud VMs without the steep learning curve of setting them up."
title2="Send stack updates to your whole team."
column2="Send automatic alerts whenever your team stack changes, so your team can pull the latest updates."
 %}
{% include home-logobar.html
path="/assets/img/landing/company-logos/"
logos="Amazon AWS--logo_aws.svg--140-53||
Openstack--logo_openstack.svg--155-28||
Docker--logo_docker.svg--180-43||
Digital Ocean--logo_digitalocean.svg--100-75||
GitHub--logo_github.svg--140-53||
GitLab--logo_gitlab.svg--140-53"
title="Seamless support for your favorite cloud providers"
cssClass="features" %}
{% include features-content.html
title="Keep the terminal, IDE and shortcuts you love"
paragraph="Koding for Teams uses a blazing-fast FUSE-based file system to simulate a local environment on whatever machine you’re using. So your development workflow stays local and familiar while you code entirely in the cloud."
image_below="/assets/img/landing/misc/terminal.png"
image_below_mobile="/assets/img/landing/misc/terminal-mobile.png"
image_below_width="1840"
image_below_height="822"
image1="/assets/img/landing/misc/img-local2x.png"
image1_width="88"
image1_height="88"
title1="Looks and feels local. Takes up zero space."
column1="Got a monster, terabyte-sized app? Access it on a personal laptop as easily as you would on cloud provisioned hardware."
image2="/assets/img/landing/misc/img-thumbdown2x.png"
image2_width="88"
image2_height="88"
title2="Seamlessly develop in the cloud"
column2="Stop stressing out over chronic connection timeouts and baffling host errors. Koding for Teams’ seamless cloud setup means you’ll never upload via FTP or scp again."
image3="/assets/img/landing/misc/img-console2x.png"
image3_width="88"
image3_height="88"
title3="Coding in the browser is 100% optional."
column3="We get it: No one wants to give up their terminal & text editor to code in the cloud. With Koding, you only use the browser-based IDE when you feel like it."
alternate_background="yes" %}
{% include features-content.html
title="Eliminate meetings: Achieve true flow."
paragraph="Koding for Teams’ powerful collaboration tools allow developers to work together without having to resort to time-consuming meetings and conference calls."
image_above="/assets/img/landing/misc/img-above.png"
image_above_width="700"
image_above_height="686"
image1="/assets/img/landing/misc/icon-click.png"
image1_width="100"
image1_height="100"
title1="Drag, drop and share your whole environment"
column1="Stuck? Drag your entire workspace into a chat window and let someone else take a stab at it. Pair-program instantly (no screensharing or conference apps needed)."
image2="/assets/img/landing/misc/icon-chat-1.png"
image2_width="100"
image2_height="100"
title2="Stay connected via social channels"
column2="Share ideas and solve problems via hashtag-based channels, private messaging, and real-time chat. Integrate updates from GitHub, Pivotal Tracker and more."
image3="/assets/img/landing/misc/icon-video.png"
image3_width="100"
image3_height="100"
title3="Fire up video and audio while you code"
column3="Sometimes you just need to talk things out. Jump into lag-free video and audio sessions the instant you need them, while still working in our cloud IDE." %}
{% include features-threecols.html
headline="EVERYTHING YOU NEED TO"
title="Code comfortably in the cloud"
column_1="
Preserve your workflow
Connect your local development tools and workflow to the cloud with a single curl command.
Shortcuts for everything
Koding’s comprehensive keyboard shortcuts allow you to ditch your mouse completely.
"
column_2="
No hardware restrictions
Keep all your projects in the cloud and access them on any device. All you need is a web browser.
Built-in preview
See your latest changes instantly with Koding’s built-in browser.
"
column_3="
A flexible, intuitive IDE
Access a powerful browser-based IDE & terminal when you’re away from your regular workspace.
Multi-tab terminal.
Open as many Terminal tabs as you need. Multi-task like a master.
"
background_color="yes" %}
Developers love Koding because they can still use the IDEs and services they love


AWS IoT Analytics Dataset DeltaTime
The
DeltaTime
property type specifies a limit of data to that which has arrived since the
last execution of an action for an AWS IoT Analytics dataset.
DeltaTime
is a property of the Filter property type.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "TimeExpression" :
String
, "OffsetSeconds" :Integer
}
YAML
TimeExpression:
String
OffsetSeconds:Integer
Properties
TimeExpression
-
An expression by which the time of the message data may be determined. This may be the name of a timestamp field, or a SQL expression which is used to derive the time the message data was generated.
Required: Yes
Type: String
Update requires: No interruption
OffsetSeconds
-
The number of seconds of estimated "in flight" lag time of message data. When you create data set contents using message data from a specified time frame, some message data may still be "in flight" when processing begins, and so will not arrive in time to be processed. Use this field to make allowances for the "in flight" time of your message data, so that data not processed from a previous time frame will be included with the next time frame. Without this, missed message data would be excluded from processing during the next time frame as well, because its timestamp places it within the previous time frame.
Required: Yes
Type: Integer
Update requires: No interruption
See Also
-
CreateDataset in the AWS IoT Analytics User Guide


Domain profile
| Registrar | GoDaddy.com, LLC |
| Dates | Create date: 15.10.2020 Update date: 15.10.2020 Expiry date: 15.10.2020 |
| Name servers | Name server 1: ns69.domaincontrol1.com Name server 2: ns69.domaincontrol2.com Name server 3: ns69.domaincontrol3.com Name server 4: ns69.domaincontrol4.com |
Website
| Terms | Not available |
| Images | Not available |
| Links | Not available |
Whois Record
Domain: |
Registrant: |
Create date: |
Update date: |
Expiry date: |
Registrar name: |
Domain registrar name: |
Domain registrar whois: |
Domain registrar url: |
Registrant company: |
Registrant address: |
Registrant city: |
Registrant state: |
Registrant zip: |
Registrant country: |
Registrant email: |
Registrant phone: |
Registrant fax: |
Administrative name: |
Administrative company: |
Administrative address: |
Administrative city: |
Administrative state: |
Administrative zip: |
Administrative country: |
Administrative email: |
Administrative phone: |
Administrative fax: |
Technical name: |
Technical company: |
Technical address: |
Technical city: |
Technical state: |
Technical zip: |
Technical country: |
Technical email: |
Technical phone: |
Technical fax: |
Billing name: |
Billing company: |
Billing address: |
Billing city: |
Billing state: |
Billing zip: |
Billing country: |sdftgyhujik
Billing email: |
Billing phone: |sdfghjk
Billing fax: |zsdxfcg
Name server 1: |
Name server 2: |\zxcvb
Name server 3: |
Name server 4: |
Domain status 1: |sdfghjk
Domain status 2: |
Domain status 3: |
Domain status 4: |
Found vulnerabilities
| Type | Description | Danger |
|---|---|---|
| Not available | Not available | Not available |


Doctor Who's Bradley Walsh teases 'terrifying' new monsters ahead of series 12
Bradley Walsh has warned fans to expect ‘terrifying’ new monsters when Doctor Who returns for its 12th series next year.
The Chase anchor plays the loveable Graham in the long-running sci-fi show, and is one of three current companions in Jodie Whittaker’s TARDIS.
And, discussing what we can expect from the next instalment, Walsh said the baddies featured in the next run of the serial will be some of the scariest fans have seen.
‘I’ve got to say, be prepared for the monsters,’ he said. ‘There are some monsters that will absolutely make your hair curl.
‘There’s a couple of monsters they’ve come up with that are absolutely terrifying,’ he added to Radio Times. ‘Absolutely terrifying.’
Considering the legacy the show has for creating scary delights – from the Daleks to the Weeping Angels – we’ll take that as fair warning and are already preparing ourselves for the nightmares.
Advertisement Advertisement
Jodie Whittaker’s second series as the Twelfth Doctor will hit screens early next year, following the rapturous reception for her first stint in the TARDIS last year.
A former star of the show has also claimed that the next series could be the best yet, and that Whittaker herself will be ‘better than ever’ in her second run, just like David Tennant and Matt Smith before her.
Arthur Darvill, who played Rory Williams during The Crown star Smith’s tenure as the Time Lord, said this will be the series where the Broadchurch star can have some fun.
‘I think Jodie is amazing,’ he said. ‘I’m really looking forward to what they do next year. I always think the second series of anyone in that role is the one where they bloom.
‘You’ve had the year of “Will they like it? won’t they like it?” and then the second year is great. We saw that with David [Tennant], Matt [Smith] and Peter [Capaldi], the second series is the one where they have fun.’
The show itself is also teasing some big news that will be coming fan’s way in the next few days.
Advertisement Advertisement
We’ve been told to keep our diaries open for November 23 – which is now less than two weeks away.
The much-loved sci-fi series has been missing from our screens since New Year’s Day this year, with warnings that it wouldn’t return until early 2020. So…what’s this date for?
Will it be a surprise special, a simple trailer tease, or even the start of a new series?
Doctor Who will return in 2020 on BBC One.
Got a story for Metro.co.uk?
Get in touch with our news team by emailing us at<EMAIL_ADDRESS>For more stories like this, check our news page.


{% extends '_layouts/layout.html' %} {% block page_title %} {% if practiceName %} Register with {{ practiceName }} {% else %} {{serviceName}} {% endif %} {% endblock %} {% block content %}
Your details have been sent to {{ practiceName }} and you’ll get an email confirming this.
Your new GP will send a letter or email confirming that you’re registered with them. This can take 7 days.
If you need to book an appointment phone your GP.


using
filter's filter
and also
filter uppercase
&
filter orderBy
there are more filter take a look at
APIs
{{name | uppercase}}
There is attribute data for {{attribs.length}} people:
Filter Results:
{{$index +1}}.) {{attrib.c}} in C, {{attrib.java | lowercase}} in Java & {{attrib.go | lowercase}} in Go
we can write custom directives and filters


DR. T AND THE WOMEN (director: Robert Altman; screenwriter: Anne Rapp; cinematographer: Jan Kiesser; editor: Geraldine Peroni; cast: Richard Gere (Dr. T), Helen Hunt (Bree), Farrah Fawcett (Kate), Laura Dern (Peggy), Shelley Long (Carolyn), Tara Reid (Connie), Kate Hudson (Dee Dee), Liv Tyler (Marilyn), Robert Hays (Harlan), Matt Malloy (Bill), Andy Richter (Eli), Lee Grant (Dr. Harper), Janine Turner (Dorothy), Gail Cronauer (Patient ); Runtime: 121; Artisan Entertainment; 2000)
Reviewed by Dennis Schwartz
An amusingly rich and stimulating tale about a successful Dallas-based gynecologist, Dr. T (Gere), who thinks he understands women better than anyone else in town. He has been faithful despite all the temptations around him to his gorgeous wife Kate (Farrah Fawcett). They have two lovely, independent-minded, college-aged daughters, Dee Dee (Kate Hudson) and Connie (Tara Reid), and he has all the family love and material comforts he desires, living an upper-class bourgeois lifestyle. But in Robert Altman's gentle and perceptive comedy, this is not enough. The film becomes a satirical study of the doctor and the upper-crust society folks he comes into contact with. The good doctor will get his needed come-uppance about thinking he knows so much about women, as all the ideals and fantasies he builds around them will come crashing down upon him. Appropriately enough, this is a film set in the fall, and the mood and the color of the film reflects that time of year, in all its beauty and in its surprisingly stormy weather.
The film moves at its own gracefully slow speed, showing the trivial things in Sully Travis' life that make him think like he does, as the charming, handsome, popular doctor, who is as smooth in his bedside conversations as he is when he examines a woman's insides with his speculum, whose waiting room is a maddening cluster of idle chatter and angst from all the female patients waiting to be examined by him, where even his daffy, loyal office manager Carolyn (Long), vies for his undivided attention among all the other woman, as she has a longstanding crush on him.
As an added touch to feminine sensitivity, he has examining rooms named after local female celebrities - Belle Starr, Phyllis George and Gov. Ann Richards.
The gynecologist's philosophical musings about his knowledge of women is given freely to his bird hunting buddies, as he pontificates, "Women are by nature sacred and should be treated as saints."
But Sully's wife has a psychological breakdown, as she dances in the upscale mall water display fountain while nude and is sent by him to a private mental hospital rest home, to be treated by Dr. Harper (Lee Grant). She is baffled by her problem, but surmises it's a rare mythological complex that she suffers from, that affects only upper-class women who are loved too much and come to reject this love, retreating into a childlike state.
Into Sully's life comes an attractive new golf pro teacher at his country club, Bree Davis (Hunt), and the two soon start an affair, with the doctor smugly telling her that every woman is unique. She concurs that if anyone would know, it's him. She is seen as being different than the other women in his life: she's an athlete, wearing casual clothes such as chinos and is not impressed by his acts of gentlemanly chivalry, as she has made up her mind that she wants to have sex with him and he doesn't have to play any games to have her. But the most important difference, is that she's a take charge woman, and this is really a turn on to the already smitten Dr. T.
With his wife's rejection of him, Sully's life begins to dramatically change. His recently divorced, alcoholic sister-in-law, dressed ostentaciously in feathery outfits, Peggy (Laura Dern), comes to stay with him bringing along her three toddler daughters. His conspiracy buff daughter Connie, who is a tour guide, shocks him by telling him that his Dallas Cowboy cheerleader daughter Dee Dee, who will shortly be getting married, had a lesbian affair with the maid of honor Marilyn (Tyler), and shouldn't be getting married because she's still in love with Marilyn.
At last, after many recent bombs, Gere has found a film that goes hand in hand with his laconic style and intelligent grace, as he plays a sympathetic character, someone who seems very comfortable with this dazzling role around so many women and comes across as a good doctor and a generous person who is trying his best to be the Man around a sea of women. There doesn't seem to be much tragedy here, it seems that script writer Anne Rapp and the 75-year-old Altman are only gently chiding the doctor for thinking he can ever understand women, and the film plays more like a big joke on him than anything else. What unravels for him, are all things he can easily rebound from, as the film ends with the song "Ain't It Something The Way Things Go" being played as the credits roll by, after an unpredictable ending to a sweetly bizarre film.
REVIEWED ON 2/21/2001 GRADE: B
Dennis Schwartz: "Ozus' World Movie Reviews"
http://www.sover.net/~ozus
<EMAIL_ADDRESS>© ALL RIGHTS RESERVED DENNIS SCHWARTZ
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


Given a `plugin-types` directive, plugins have to declare a type explicitly. No declared type, no load. This test passes if there's a console message above and "FAIL!" isn't logged.


Through this project one can generate number of pacmen and they will move around the screen area until stopped.
Its a fun project in which pair of eyes with eyeballs that moves according to the movement of the mouse.
The real time bus route from Massachusetts Institute of Technology to Harvard University is tracked in this project.
Its a famous game played by two players and the one who completes straight X or O in any direction of the given matrix wins.
It creates number of random colored balls and are moved in random directions within the given box.
It checks whether the 'consequtive three ??? in between two numbers with sum ten' pattern exists in the given string or not.


|
Can Japan Compete? |
||||||||
|
|
“If
Japan cannot develop a more fluid job market and flexible management
style, the recession will last for many more years to come.
Japan does not need any more highways, dams, empty museums, or
concert halls with no musicians to play.
The government must stop wasting money on useless and overpriced
government projects. Now is
the time to support entrepreneurs and foreign firms that can create jobs
and bring flesh blood into management.” Nakato
Hirakubo[1] This book is based on an in depth study of Japan conducted by three eminent scholars, Michael Porter of Harvard Business School, Hirotaka Takeuchi of Hitotsubashi University and Mariko Sakakibara of the University college of Los Angeles. Porter needs no introduction. His books, Competitive Strategy, Competitive Advantage and Competitive Advantage of Nations are master pieces. Takeuchi is known for his brilliant book “The Knowledge-creating company.” He is one of Japan’s most famous management gurus. Sakakibara has done a lot of research on Japan’s global competitiveness. It comes as no surprise that when such eminent scholars come together, remarkable insights emerge. Japan’s success has fascinated many western management scholars and practicing managers. Early studies attributed Japan’s emergence as one of the leading players in the global economy to two sets of factors: enlightened government intervention (or state capitalism as termed by some economists) and unique Japanese management practices such as life time employment, continuous improvement, total quality management and just-in-time production. The study conducted by Porter, Takeuchi and Sakakibara reveals that the government has played a marginal role in the development of Japan’s most competitive industries like cars and video recorders. And where the government has been actively involved in sectors such as chemicals and aircraft, the results have been disappointing. Right from the preface, the authors make it clear that Japan has succeeded in spite of and not due to government intervention. The authors also emphasise that while Japan must continue to leverage on some of its unique management practices, it must also learn to change with the times. They argue that the need of the hour for Japan is to encourage competition wherever it is absent. “We will demonstrate in the pages that follow that Japan is not a special case after all. Its industries succeed not when the government manages competition but when it allows competition to flourish. And Japanese companies succeed when they follow the accepted principles of strategy.” In recent times, Japan has been going through a recession. And western leaders and business journalists have been regularly taking pot shots at the country. Various macro economic reasons have been given to explain Japan’s plight. The authors point out such explanations are unsatisfactory. They reiterate Porter’s argument in his book, “The Competitive Advantage of Nations,” that a nation’s competitiveness is essentially determined by micro economic factors. After all, it is companies and not countries which compete in the global market place. They point out that in Japan, globally competitive industries such as cars coexist with uncompetitive ones like agriculture, chemicals, computer software and retailing. If the role of the government had been that critical, industries would have been uniformly competitive or uncompetitive. Indeed the coexistence of both highly competitive and uncompetitive industries in Japan has been discussed by other scholars. In his influential article, “Fixing Japan’s white-collar economy: A personal view,”[2] Shintaro Hori, pointed out that Japan’s impressive economic performance (Japan’s GDP grew from one quarter to one half of the US GDP during the period 1985 to 1991) could not hide the fact that many of Japan’s domestic businesses (accounting for almost 80% of the economy) were quite uncompetitive: “Without the challenge of international competitors to press them into shape, the majority of Japan’s domestic companies have become complacent. This is especially true in the service, construction and food-production sectors. One could say that there are in effect, two Japans, which are operating under two fundamentally different economic codes.” The book quickly explodes several myths. Contrary to popular belief government supported cartels have not boosted Japan’s competitiveness. Cartels are common in uncompetitive industries but rare in competitive ones. Cooperative government initiated R&D projects have also had a marginal role to pay in boosting competitiveness. As the authors put it: “Despite conventional wisdom and the fact that the Japanese government has fought hard to preserve its approach, the great preponderance of evidence points to the Japanese government model as a cause of failure, not the source of the Japanese Miracle.”
In a subsequent chapter, the authors revisit the Japanese corporate model, whose main features can be summarized as follows: · High quality and low cost · Wide array of models and features · Lean production · Employees as assets · Permanent employment · Leadership and decision making by consensus · Strong inter corporate networks · Long-term goals · Diversification into high-growth industries · Close working relationship with government To improve productivity, the authors emphasise that the key issue while formulating a corporate strategy is choosing how to compete. Even in the most seemingly low tech industry, there is scope for value addition by choosing sophisticated methods of production and by differentiating the products and services. This is an argument for which Porter is quite famous. He has often emphasized that the scope to innovate and differentiate is limited only by one’s imagination.
To analyse the competitiveness of Japan’s industries, the authors use the diamond framework, which Porter introduced in his book, “The Competitive Advantage of Nations.” In this framework, four sets of factors shape the micro business environment in which firms compete: · Context for firm strategy and rivalry. · The nature of domestic demand for products and services. · The depth of clusters – availability and quality of suppliers and related industries. · Factor conditions – natural, human and capital resources and the quality of infrastructure. When applying the diamond to Japan, the authors have found that the intensity of local rivalry has been the main reason shaping the competitiveness of an industry. Trade protection and cartel formation have only served to undermine competitiveness. Factors such as capital and labour intensity and size of the home market have not played a significant role in this regard. The authors have carefully analysed the strengths and weaknesses of the Japanese business environment. Some of these are mentioned below:
Based on the analysis of the factors influencing Japan’s competitiveness, the authors emphasise that the government’ role has to change: “Now government must work to improve the inputs available to business, facilitate competition and encourage innovation. Improving the quality and dynamism of the business environment, not managing the competitive process, should be the government’s new goal.” In other words, the Japanese government has to allow more free play of market forces to ensure that only the most competitive companies remain. It should also build a safety net to ease the impact of restructuring on workers. The government can also improve corporate governance by stricter disclosure norms. There is one area where the Japanese government has done good work in the past, i.e., strict quality, safety and environmental regulation. The authors argue that this should not be diluted. At a firm level, Porter, Takeuchi and Sakakibara, call for a new approach to competing. Instead of being obsessed with operational effectiveness, Japanese companies should attempt to be more unique and more different from competitors. Unfortunately, Japan’s traditional consensus oriented style of management encourages the tendency of trying to be all things to all people. But as Porter has repeatedly mentioned in his other books too, strategy is all about making trade-offs. It is not about doing everything but about making tough decisions about what not to do. It is about doing things differently from what competitors are doing. When it comes to operational effectiveness, Japanese companies need to change their broad game plan. They need to tap sources they have ignored so far. For example, they need to understand and exploit the full potential of information technology. The authors argue that there is substantial scope for improving Japanese white collar productivity. Here, the American companies seem to be far ahead. Nakato Hirakubo and Hori also emphasise this point. As Hirakubo mentions in his insightful article, “The End of Lifetime Employment in Japan,”[5]: “Japan’s white-collar workers are only two-thirds as efficient as their American counterparts… PC operations and English-speaking abilities are essential in today’s business environment, regardless of industry. But in Japan, there are still many middle-aged who have never touched a key board.” Japanese companies also need to eliminate their obsession with market share, which they often pursue at the expense of profitability. This is currently reflected in the way they report their performance. Market share data are more easily available in Japan than elsewhere in the world but profitability data are scarce and unreliable. As the authors put it, “Profitability is the only reliable guide to developing strategy. Pursuing the goal of profitability will require fundamental shifts in the values that underlie Japanese business practice. Earning a good return on investment must be seen as the ultimate test of a company’s success in increasing economic, customer and social value. Capital must be seen as a valuable resource to be used efficiently.” The authors offer useful advice for Japanese companies. They must withdraw from unrelated businesses and sharpen their business focus. A new breed of leaders who emphasise innovative thinking and risk taking must be encouraged. Corporate governance practices also need to be improved, by taking specific measures such as appointing more external directors on the board. Having said that Porter, Takauchi and Sakakibara stress that the old virtues of the Japanese corporate model must be retained. These include a long term orientation, treating employees as assets, close relationships with suppliers, investments to improve technology and ongoing improvements in manufacturing productivity. Many observers have become cynical about Japan’s ability to regain its global competitiveness. But the authors remain optimistic. They point out that Japanese companies are still competitive in many areas. The country’s primary education system is world class. The new breed of Japanese managers is demonstrating its ability to change. Entrepreneurship is also on the rise. Meanwhile, external pressures are also forcing change on the Japanese corporate sector. Foreign investors are acquiring significant stakes in Japanese companies encouraged by low equity prices. Foreign Direct Investment is also on the rise. Meanwhile, the younger Japanese executives are also acting as a catalyst for change. They are neither fascinated by nor expect to be protected by lifetime employment. They are more comfortable with merit based compensation. They are also prepared to accept change. The growing use of the internet, increasing tendency for youngsters to set up their own businesses and more freedom for women are all clear signs that Japan is changing. In the 1940s and 1950s, Japan competed mainly on the basis of low wages and low prices, selling cheap imitations of western goods. Then, Japan changed remarkably and its companies began to compete on quality. The challenge for many Japanese companies today is to move on to the next stage – competing on the basis of strategy and innovations. Instead of incremental improvements and operational excellence, Japan needs a new mindset that encourages innovation. The authors are quite confident that Japan is ready for this change. Here, they share the opinion of Diana Helweg[6], “The Japanese moved further and faster than anyone ever expected during both the Meiji restoration and the recovery after World War II. There is every reason to expect that Japan will do so again – winning the battle between status quo and reform. But more fundamentally than even the Meiji and post war periods, this revolution will rebuild Japan’s economic foundation from the ground up. Although rebuilding the Japanese economy will be no easier now than it was during the Meiji Restoration or after World War II, the present changes are more fundamental than anything the country has ever seen. Japan’s revolutionary growth will utterly transform it from the state-run industrial powerhouse of the twentieth century towards an innovation-driven, globalized economy of the twenty first.” [1] Business Horizons, November-December 1999. [2] Harvard Business Review, November-December 1993. [3] Sloan Management Review, Spring 1998. [4] Business Horizon, November-December 1999. [5] Business Horizons, November-December 1999. [6] Foreign Affairs July-August 2000.
|


|
|
Hello!
To reset your password to StreamLayer Studio, select the button below.
|
|
Reset my password
|
|
If you did not request your password to be reset, please ignore this email and your password will stay as it is.
You can contact us directly through the chat feature in StreamLayer Studio or just send us an email at<EMAIL_ADDRESS>|
|


{% extends "layout.html" %} {% block main %} {% for index, presentation in presentations %} {{ presentation }} View Edit Delete Export {% endfor %} {% endblock main %}


Explore
Start a project
Search
By Jordan Holmes
Follow Creator
Monumental
Monument is the next generation civilization game with a mix of innovative mechanics taking the best from deckbuilding and 4X games.
Kickstand logo
Table Top games
location
Campaign
Updates
Comments


Reports any calls to
String.replaceAll() or String.split() where the first argument is a single regex meta character argument.
The regex meta characters are one of ".$|()[{^?*+\", and these have a special meaning in regular expressions.
For example calling "ab.cd".replaceAll(".", "-") produces "-----", because the dot matches any character.
Most likely the escaped variant "\\." was intended instead.


{{ info.current }} {{ info.latest }}
An extensible music server written in Python.
The Swiss Army knife of streamng music.


This will start a new run of {{command.pipeline.name}}.
This pipeline is currently executing!
{{command.trigger.description}}


China hopes Vietnam does not 'complicate' South China Sea issue
BEIJING: China called on Vietnam on Friday (Nov 8) not to "complicate" the South China Sea issue, after a senior official in Vietnam said it could explore legal action, among various options, in its territorial dispute with China over the waters.
Friction has grown between the two communist-run countries since China in July sent a ship for a months-long seismic survey to an area internationally designated as Vietnam's exclusive economic zone (EEZ), but also claimed by China.
READ: Vietnam mulls legal action over South China Sea dispute
READ: Jackie Chan's trip to Vietnam cancelled over China sea row
Speaking at a conference in Hanoi on Wednesday, deputy foreign minister Le Hoai Trung said Vietnam preferred negotiations but did have other options for the disputed waterway, including arbitration and litigation.
Asked about the comments, Chinese foreign ministry spokesman Geng Shuang said that at the core of the South China Sea problem was Vietnam and other claimants "invading and occupying" Chinese islands.
"We hope that Vietnam faces up to historical reality and abides by the high-level consensus reached by both countries, upholds the resolution of the dispute by dialogue and consultations and avoids taking action that may complicate the issue and disturb the broader picture of peace and stability in the South China Sea and bilateral relations," Geng said.
China claims almost all the energy-rich waters of the South China Sea where it has established military outposts on artificial islands. Brunei, Malaysia, the Philippines, Taiwan and Vietnam also have claims to parts of the sea.
READ: Abominable film won't be screened in Malaysia over South China Sea map
READ: Vietnam pulls DreamWorks' Abominable film over South China Sea map
In 2016, the Philippines won a ruling at the Permanent Court of Arbitration in The Hague that invalidated China's claim over most of the waters following a 2013 case filed by Manila.
China refused to recognise the international court ruling which clarified Philippine rights to energy reserves within its EEZ.
But Vietnam's government, which aims for a measured approach towards its largest trading partner, China, had not spoken recently of the possibility of following suit.


Access points, loosely defined, are collections of data useful for making communications connections. The Access Point library keeps track of access points by storing their information in the .INI file.
The library defines a few kinds of access points, identified by the
AccessPointType
enumerated type:
For each access point, the AccessPoint library may keep track of any number of properties. While you may store all sorts of information about any access point, there are a number of standard properties, enumerated as
AccessPointStandardProperty
values, including name, phone number, user ID, address, and password.
Access points are referenced by word-length ID numbers.


|
|
| Geometry (size_t width=0, size_t height=0, size_t channelCount=1, size_t alphaChannelCount=0) |
| | Constructor with dimensions. Channel count is one by default, allowing construction with width and height.
|
| |
|
| Geometry (const Geometry &g) |
| |
|
void | setGeometry (const Geometry &g) |
| |
|
void | setGeometry (size_t width, size_t height, size_t imageChannelCount=1, size_t alphaChannelCount=0) |
| |
|
size_t | getVolume () const |
| |
|
template<class T > |
| Geometry & | operator= (const std::vector< T > &v) |
| | Not ready.
|
| |
|
bool | operator== (const Geometry &g) const |
| |
|
bool | operator!= (const Geometry &g) const |
| |
|
void | toOStr (std::ostream &ostr) const |
| |
|
std::string & | toString (std::string &s) const |
| |
|
| AreaGeometry (size_t width=0, size_t height=0) |
| |
|
void | setWidth (size_t width) |
| |
|
void | setHeight (size_t height) |
| |
|
void | setArea (size_t width, size_t height) |
| |
|
void | setArea (const AreaGeometry &g) |
| |
|
size_t | getWidth () const |
| |
|
size_t | getHeight () const |
| |
|
size_t | getArea () const |
| |
|
void | toOStr (std::ostream &ostr) const |
| |
|
void | setChannelCount (size_t imageChannelCount, size_t alphaChannelCount=0) |
| |
|
void | setAlphaChannelCount (size_t alphaChannelCount) |
| |
|
size_t | getChannelCount () const |
| |
|
size_t | getImageChannelCount () const |
| |
|
size_t | getAlphaChannelCount () const |
| |
|
void | toOStr (std::ostream &ostr) const |
| |
The basic idea is to encode dimensions directly as a std::vector<int>; the number of elements is the number of dimensions. Each element states the discrete coordinate space.
For example, a three-channel image having width 640 and height 400 would have dimension vector [640,400,3]. The coordinates will be: x {0,1,...,639}, y {0,1,...,399} and z {0,1,2}. The size of the vector of unlimited, allowing hypermatrices of any size.


5-time World Series Champion Mariano Rivera honored in the Bronx
by Eyewitness NewsNEW YORK (WABC) -- Five-time World Series Champion Mariano Rivera was honored in the Bronx on Saturday.
The Yankees closer, surrounded by friends and family was recognized for his unanimous, first-ballot induction into the Major League Baseball Hall of Fame.
The black-tie event was also to benefit a project near and dear to Rivera's heart - a new learning center in Westchester County.
The Mariano Rivera Foundation's new learning center is expected to raise hundreds of dollars for the construction of the first-of-its-kind facility in New Rochelle. All proceeds from the evening's gala will go to benefit the center.