#!/usr/bin/python
#from udacityplots import *
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
import pylab as pl
import numpy as np
import base64
import json
import subprocess
def prettyPicture(clf, X_test, y_test):
x_min = 0.0; x_max = 1.0
y_min = 0.0; y_max = 1.0
# Plot the decision boundary. For that, we will assign a color to each
# point in the mesh [x_min, m_max]x[y_min, y_max].
h = .01 # step size in the mesh
xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))
Z = clf.predict(np.c_[xx.ravel(), yy.ravel()])
# Put the result into a color plot
#matplotlib inline
Z = Z.reshape(xx.shape)
plt.xlim(xx.min(), xx.max())
plt.ylim(yy.min(), yy.max())
plt.pcolormesh(xx, yy, Z, cmap=pl.cm.seismic)
# Plot also the test points
grade_sig = [X_test[ii][0] for ii in range(0, len(X_test)) if y_test[ii]==0]
bumpy_sig = [X_test[ii][1] for ii in range(0, len(X_test)) if y_test[ii]==0]
grade_bkg = [X_test[ii][0] for ii in range(0, len(X_test)) if y_test[ii]==1]
bumpy_bkg = [X_test[ii][1] for ii in range(0, len(X_test)) if y_test[ii]==1]
plt.scatter(grade_sig, bumpy_sig, color = "b", label="fast")
plt.scatter(grade_bkg, bumpy_bkg, color = "r", label="slow")
plt.legend()
plt.xlabel("bumpiness")
plt.ylabel("grade")
#plt.savefig("test.png")
def output_image(name, format, bytes):
image_start = "BEGIN_IMAGE_f9825uweof8jw9fj4r8"
image_end = "END_IMAGE_0238jfw08fjsiufhw8frs"
data = {}
data['name'] = name
data['format'] = format
data['bytes'] = base64.encodestring(bytes)
print image_start+json.dumps(data)+image_end
#!/usr/bin/python
import random
def makeTerrainData(n_points=1000):
### make the toy dataset
random.seed(42)
grade = [random.random() for ii in range(0,n_points)]
bumpy = [random.random() for ii in range(0,n_points)]
error = [random.random() for ii in range(0,n_points)]
y = [round(grade[ii]*bumpy[ii]+0.3+0.1*error[ii]) for ii in range(0,n_points)]
for ii in range(0, len(y)):
if grade[ii]>0.8 or bumpy[ii]>0.8:
y[ii] = 1.0
### split into train/test sets
X = [[gg, ss] for gg, ss in zip(grade, bumpy)]
split = int(0.75*n_points)
X_train = X[0:split]
X_test = X[split:]
y_train = y[0:split]
y_test = y[split:]
grade_sig = [X_train[ii][0] for ii in range(0, len(X_train)) if y_train[ii]==0]
bumpy_sig = [X_train[ii][1] for ii in range(0, len(X_train)) if y_train[ii]==0]
grade_bkg = [X_train[ii][0] for ii in range(0, len(X_train)) if y_train[ii]==1]
bumpy_bkg = [X_train[ii][1] for ii in range(0, len(X_train)) if y_train[ii]==1]
# training_data = {"fast":{"grade":grade_sig, "bumpiness":bumpy_sig}
# , "slow":{"grade":grade_bkg, "bumpiness":bumpy_bkg}}
grade_sig = [X_test[ii][0] for ii in range(0, len(X_test)) if y_test[ii]==0]
bumpy_sig = [X_test[ii][1] for ii in range(0, len(X_test)) if y_test[ii]==0]
grade_bkg = [X_test[ii][0] for ii in range(0, len(X_test)) if y_test[ii]==1]
bumpy_bkg = [X_test[ii][1] for ii in range(0, len(X_test)) if y_test[ii]==1]
test_data = {"fast":{"grade":grade_sig, "bumpiness":bumpy_sig}
, "slow":{"grade":grade_bkg, "bumpiness":bumpy_bkg}}
return X_train, y_train, X_test, y_test
# return training_data, test_data
def classify(features_train, labels_train):
### import the sklearn module for GaussianNB
### create classifier
### fit the classifier on the training features and labels
### return the fit classifier
### your code goes here!
from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(features_train, labels_train)
return clf
#!/usr/bin/python
""" Complete the code in ClassifyNB.py with the sklearn
Naive Bayes classifier to classify the terrain data.
The objective of this exercise is to recreate the decision
boundary found in the lesson video, and make a plot that
visually shows the decision boundary """
features_train, labels_train, features_test, labels_test = makeTerrainData()
### the training data (features_train, labels_train) have both "fast" and "slow" points mixed
### in together--separate them so we can give them different colors in the scatterplot,
### and visually identify them
grade_fast = [features_train[ii][0] for ii in range(0, len(features_train)) if labels_train[ii]==0]
bumpy_fast = [features_train[ii][1] for ii in range(0, len(features_train)) if labels_train[ii]==0]
grade_slow = [features_train[ii][0] for ii in range(0, len(features_train)) if labels_train[ii]==1]
bumpy_slow = [features_train[ii][1] for ii in range(0, len(features_train)) if labels_train[ii]==1]
clf = classify(features_train, labels_train)
### draw the decision boundary with the text points overlaid
prettyPicture(clf, features_test, labels_test)
#output_image("test.png", "png", open("test.png", "rb").read())
def NBAccuracy(features_train, labels_train, features_test, labels_test):
""" compute the accuracy of your Naive Bayes classifier """
### import the sklearn module for GaussianNB
from sklearn.naive_bayes import GaussianNB
from sklearn.metrics import accuracy_score
### create classifier
clf = GaussianNB()
### fit the classifier on the training features and labels
clf.fit(features_train, labels_train)
### use the trained classifier to predict labels for the test features
###### method 1
accuracy = clf.score(features_test, labels_test)
###### method 2
pred = clf.predict(features_test)
accuracy = accuracy_score(pred, labels_test)
return accuracy
features_train, labels_train, features_test, labels_test = makeTerrainData()
def submitAccuracy():
accuracy = NBAccuracy(features_train, labels_train, features_test, labels_test)
return accuracy
print submitAccuracy()
Output -: 0.884
#!/usr/bin/python
"""
This is the code to accompany the Lesson 1 (Naive Bayes) mini-project.
Use a Naive Bayes Classifier to identify emails by their authors
authors and labels:
Sara has label 0
Chris has label 1
"""
import os
os.chdir('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/naive_bayes')
import sys
from time import time
sys.path.append("../tools/")
from email_preprocess import preprocess
### features_train and features_test are the features for the training
### and testing datasets, respectively
### labels_train and labels_test are the corresponding item labels
features_train, features_test, labels_train, labels_test = preprocess()
#########################################################
### your code goes here ###
from sklearn.metrics import accuracy_score
def train(feature_train, label_train):
from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
# train
t0 = time()
clf.fit(features_train, labels_train)
print "\nTraining time:", round(time()-t0, 3), "s"
return clf
# predict
t0 = time()
pred = train(features_train, labels_train).predict(features_test)
print "Predicting time:", round(time()-t0, 3), "s"
accuracy = accuracy_score(pred, labels_test)
print '\naccuracy = {0}'.format(accuracy)
no. of Chris training emails: 7936
no. of Sara training emails: 7884
training time: 1.33 s
predicting time: 0.203 s
accuracy = 0.973265073948
import sys
sys.path.append("C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/tools/")
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/choose_your_own')
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/svm')
import os
os.chdir('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/svm')
from class_vis import prettyPicture
from prep_terrain_data import makeTerrainData
import sys
import matplotlib.pyplot as plt
import copy
import numpy as np
import pylab as pl
from sklearn.metrics import accuracy_score
features_train, labels_train, features_test, labels_test = makeTerrainData()
########################## SVM #################################
from sklearn.svm import SVC
def submitAccuracy():
return accuracy_score(pred, labels_test)
clf = SVC(kernel="linear")
clf.fit(features_train, labels_train)
pred = clf.predict(features_test)
print accuracy_score(pred, labels_test)
clf = SVC(kernel="linear", gamma=1.0)
clf.fit(features_train, labels_train)
pred = clf.predict(features_test)
%matplotlib inline
prettyPicture(clf, features_test, labels_test)
clf = SVC(kernel="rbf", C=10**5)
clf.fit(features_train, labels_train)
pred = clf.predict(features_test)
%matplotlib inline
prettyPicture(clf, features_test, labels_test)
clf = SVC(kernel="rbf", gamma=10)
clf.fit(features_train, labels_train)
pred = clf.predict(features_test)
%matplotlib inline
prettyPicture(clf, features_test, labels_test)
#!/usr/bin/python
"""
This is the code to accompany the Lesson 2 (SVM) mini-project.
Use a SVM to identify emails from the Enron corpus by their authors:
Sara has label 0
Chris has label 1
"""
from sklearn.metrics import accuracy_score
from time import time
from email_preprocess import preprocess
### features_train and features_test are the features for the training
### and testing datasets, respectively
### labels_train and labels_test are the corresponding item labels
features_train, features_test, labels_train, labels_test = preprocess()
def my_svm(features_train, features_test, labels_train, labels_test, kernel='linear', C=1.0):
# the classifier
clf = SVC(kernel=kernel, C=C)
# train
t0 = time()
clf.fit(features_train, labels_train)
print "\ntraining time:", round(time()-t0, 3), "s"
# predict
t0 = time()
pred = clf.predict(features_test)
print "predicting time:", round(time()-t0, 3), "s"
accuracy = accuracy_score(pred, labels_test)
print '\naccuracy = {0}'.format(accuracy)
return pred
pred = my_svm(features_train, features_test, labels_train, labels_test)
No. of Chris Training emails: 7936
No. of Sara Training emails: 7884
Training time: 176.156 s
Predicting time: 18.561 s
Accuracy = 0.984072810011
features_train2 = features_train[:len(features_train)/100]
labels_train2 = labels_train[:len(labels_train)/100]
pred = my_svm(features_train2, features_test, labels_train2, labels_test)
Training time: 0.124 s
Predicting time: 1.123 s
Accuracy = 0.884527872582
pred = my_svm(features_train2, features_test, labels_train2, labels_test, 'rbf')
Training time: 0.128 s
Predicting time: 1.246 s
Accuracy = 0.616040955631
for C in [10, 100, 1000, 10000]:
print 'C =',C,
pred = my_svm(features_train2, features_test, labels_train2, labels_test, kernel='rbf', C=C)
print '\n\n'
C = 10
Training time: 0.133 s
Predicting time: 1.245 s
accuracy = 0.616040955631
C = 100
Training time: 0.109 s
Predicting time: 1.244 s
accuracy = 0.616040955631
C = 1000
Training time: 0.109 s
Predicting time: 1.19 s
accuracy = 0.821387940842
C = 10000
Training time: 0.11 s
Predicting time: 1.006 s
Accuracy = 0.892491467577
pred = my_svm(features_train, features_test, labels_train, labels_test, kernel='rbf', C=10000)
Training time: 116.73 s
Predicting time: 11.745 s
Accuracy = 0.990898748578
print pred[10]
print pred[26]
print pred[50]
print pred[10] = 1
print pred[26] = 0
print pred[50] = 1
print sum(pred)
import sys
sys.path.append("C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/tools/")
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/choose_your_own')
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/svm')
import os
os.chdir('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/decision_tree')
""" lecture and example code for decision tree unit """
import sys
from class_vis import prettyPicture, output_image
from prep_terrain_data import makeTerrainData
import matplotlib.pyplot as plt
import numpy as np
import pylab as pl
from sklearn import tree
features_train, labels_train, features_test, labels_test = makeTerrainData()
#def classify(features_train, labels_train, **kwargs):
# clf = tree.DecisionTreeClassifier(**kwargs)
# clf = clf.fit(features_train, labels_train)
# return clf
### the classify() function in classifyDT is where the magic
### happens--it's your job to fill this in!
clf = tree.DecisionTreeClassifier()
clf = clf.fit(features_train, labels_train)
#### grader code, do not modify below this line
%matplotlib inline
prettyPicture(clf, features_test, labels_test)
#output_image("test.png", "png", open("test.png", "rb").read())
features_train, labels_train, features_test, labels_test = makeTerrainData()
########################## DECISION TREE #################################
### your code goes here--now create 2 decision tree classifiers,
### one with min_samples_split=2 and one with min_samples_split=50
### compute the accuracies on the testing data and store
### the accuracy numbers to acc_min_samples_split_2 and
### acc_min_samples_split_50, respectively
clf2 = tree.DecisionTreeClassifier(min_samples_split=2)
clf2 = clf2.fit(features_train, labels_train)
clf50 = tree.DecisionTreeClassifier(min_samples_split=50)
clf50 = clf50.fit(features_train, labels_train)
#clf50 = classify(features_train, labels_train, min_samples_split=50)
#clf = tree.DecisionTreeClassifier(min_samples_split=50).fit(features_train, labels_train)
acc_min_samples_split_2 = clf2.score(features_test, labels_test)
acc_min_samples_split_50 = clf50.score(features_test, labels_test)
import scipy.stats
pk = [0.5, 0.5]
print scipy.stats.entropy(pk, base=2)
print scipy.stats.entropy([1,2], base=2)
print 1-0.75*scipy.stats.entropy([1,2], base=2)
"""
This is the code to accompany the Lesson 3 (decision tree) mini-project.
Use a Decision Tree to identify emails from the Enron corpus by author:
Sara has label 0
Chris has label 1
"""
from time import time
from email_preprocess import preprocess
### features_train and features_test are the features for the training
### and testing datasets, respectively
### labels_train and labels_test are the corresponding item labels
features_train, features_test, labels_train, labels_test = preprocess()
#########################################################
### your code goes here ###
clf = tree.DecisionTreeClassifier(min_samples_split=40)
clf = clf.fit(features_train, labels_train)
print clf.score(features_test, labels_test)
No. of Chris Training Emails: 7936
No. of Sara Training Emails: 7884
0.978384527873
print features_train.shape
# I made "percentile" an input argument for preprocess with default value 10
features_train, features_test, labels_train, labels_test = preprocess(percentile=1)
print features_train.shape
No. of Chris Training emails: 7936
No. of Sara Training emails: 7884
(15820L, 379L)
clf = tree.DecisionTreeClassifier(min_samples_split=40)
clf = clf.fit(features_train, labels_train)
print clf.score(features_test, labels_test)
import sys
sys.path.append("C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/tools/")
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/choose_your_own')
import os
os.chdir('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/choose_your_own')
import matplotlib.pyplot as plt
from prep_terrain_data import makeTerrainData
from class_vis import prettyPicture
features_train, labels_train, features_test, labels_test = makeTerrainData()
### the training data (features_train, labels_train) have both "fast" and "slow"
### points mixed together--separate them so we can give them different colors
### in the scatterplot and identify them visually
grade_fast = [features_train[ii][0] for ii in range(0, len(features_train)) if labels_train[ii]==0]
bumpy_fast = [features_train[ii][1] for ii in range(0, len(features_train)) if labels_train[ii]==0]
grade_slow = [features_train[ii][0] for ii in range(0, len(features_train)) if labels_train[ii]==1]
bumpy_slow = [features_train[ii][1] for ii in range(0, len(features_train)) if labels_train[ii]==1]
#### initial visualization
%matplotlib inline
plt.xlim(0.0, 1.0)
plt.ylim(0.0, 1.0)
plt.scatter(bumpy_fast, grade_fast, color = "b", label="fast")
plt.scatter(grade_slow, bumpy_slow, color = "r", label="slow")
plt.legend()
plt.xlabel("bumpiness")
plt.ylabel("grade")
plt.show()
################################################################################
### your code here! name your classifier object clf if you want the
### visualization code (prettyPicture) to show you the decision boundary
# import the classifiers
from sklearn.neighbors import KNeighborsClassifier
from sklearn.ensemble import AdaBoostClassifier, RandomForestClassifier
from sklearn.tree import DecisionTreeClassifier
clf = KNeighborsClassifier(n_neighbors=1)
clf.fit(features_train, labels_train)
# print the accuracy and display the decision boundary
print 'Accuracy = {0}'.format(clf.score(features_test, labels_test))
prettyPicture(clf, features_test, labels_test)
clf = RandomForestClassifier(n_estimators=100)
clf = clf.fit(features_train, labels_train)
# print the accuracy and display the decision boundary
print 'Accuracy = {0}'.format(clf.score(features_test, labels_test))
prettyPicture(clf, features_test, labels_test)
clf = AdaBoostClassifier(DecisionTreeClassifier(max_depth=1), n_estimators=200)
clf = clf.fit(features_train, labels_train)
# print the accuracy and display the decision boundary
print 'Accuracy = {0}'.format(clf.score(features_test, labels_test))
prettyPicture(clf, features_test, labels_test)
import sys
sys.path.append("C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/tools/")
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/choose_your_own')
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/datasets_questions')
import os
os.chdir('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/datasets_questions')
import pickle
enron_data = pickle.load(open("../final_project/final_project_dataset.pkl", "r"))
print 'Number of people in the Enron dataset: {0}'.format(len(enron_data))
Number of people in the Enron dataset: 146
print 'Number of features for each person in the Enron dataset: {0}'.format(len(enron_data.values()[0]))
Number of features for each person in the Enron dataset: 21
pois = [x for x, y in enron_data.items() if y['poi']]
print 'Number of POI\'s: {0}'.format(len(pois))
#enron_data.items()[0]
Number of POI's: 18
# DELETE ME
enron_data['PRENTICE JAMES']
{
'bonus': 'NaN',
'deferral_payments': 564348,
'deferred_income': 'NaN',
'director_fees': 'NaN',
'email_address'<EMAIL_ADDRESS>'exercised_stock_options': 886231,
'expenses': 'NaN',
'from_messages': 'NaN',
'from_poi_to_this_person': 'NaN',
'from_this_person_to_poi': 'NaN',
'loan_advances': 'NaN',
'long_term_incentive': 'NaN',
'other': 'NaN',
'poi': False,
'restricted_stock': 208809,
'restricted_stock_deferred': 'NaN',
'salary': 'NaN',
'shared_receipt_with_poi': 'NaN',
'to_messages': 'NaN',
'total_payments': 564348,
'total_stock_value': 1095040
}
enron_data['PRENTICE JAMES']['total_stock_value']
enron_data['COLWELL WESLEY']['from_this_person_to_poi']
enron_data['SKILLING JEFFREY K']['exercised_stock_options']
names = ['SKILLING JEFFREY K', 'FASTOW ANDREW S', 'LAY KENNETH L']
names_payments = {name:enron_data[name]['total_payments'] for name in names}
print sorted(names_payments.items(), key=lambda x: x[1], reverse=True)
[('LAY KENNETH L', 103559793), ('SKILLING JEFFREY K', 8682716), ('FASTOW ANDREW S', 2424083)]
import pandas as pd
df = pd.DataFrame(enron_data)
print 'Has salary data: {0}'.format(sum(df.loc['salary',:] != 'NaN'))
print 'Has email: {0}'.format(sum(df.loc['email_address',:] != 'NaN'))
Has salary data: 95
Has email: 111
# How many people in the E+F dataset (as it currently exists) have “NaN” for their total payments?
# What percentage of people in the dataset as a whole is this?
isnan = sum(df.loc['total_payments',:]=='NaN')
_,cols = df.shape
print 'total_payments == \'NaN\': {0} people = {1:.2f}%'.format(isnan, 100.*isnan/cols)
total_payments == 'NaN': 21 people = 14.38%
isnan = sum(df.loc['total_payments',pois]=='NaN')
print 'POI total_payments == \'NaN\': {0} people = {1:.2f}%'.format(isnan, 100.*isnan/len(pois))
POI total_payments == 'NaN': 0 people = 0.00%
import sys
sys.path.append("C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/tools/")
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/choose_your_own')
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/datasets_questions')
import os
os.chdir('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/regression')
import numpy
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
from class_vis import prettyPicture, output_image
from ages_net_worths import ageNetWorthData
ages_train, ages_test, net_worths_train, net_worths_test = ageNetWorthData()
from sklearn import linear_model
def studentReg(ages_train, net_worths_train):
reg = linear_model.LinearRegression()
reg.fit(ages_train, net_worths_train)
return reg
reg = studentReg(ages_train, net_worths_train)
%matplotlib inline
plt.clf()
plt.scatter(ages_train, net_worths_train, color="b", label="train data")
plt.scatter(ages_test, net_worths_test, color="r", label="test data")
plt.plot(ages_test, reg.predict(ages_test), color="black")
plt.legend(loc=2)
plt.xlabel("ages")
plt.ylabel("net worths")
reg = linear_model.LinearRegression()
reg.fit(ages_train, net_worths_train)
### get Katie's net worth (she's 27)
### sklearn predictions are returned in an array, so you'll want to index into
### the output to get what you want, e.g. net_worth = predict([[27]])[0][0] (not
### exact syntax, the point is the [0] at the end). In addition, make sure the
### argument to your prediction function is in the expected format - if you get
### a warning about needing a 2d array for your data, a list of lists will be
### interpreted by sklearn as such (e.g. [[27]]).
km_net_worth = reg.predict([[27]])[0][0]
### get the slope
### again, you'll get a 2-D array, so stick the [0][0] at the end
slope = reg.coef_[0][0]
### get the intercept
### here you get a 1-D array, so stick [0] on the end to access
### the info we want
intercept = reg.intercept_[0]
### get the score on test data
test_score = reg.score(ages_test, net_worths_test)
### get the score on the training data
training_score = reg.score(ages_train, net_worths_train)
import pickle
from feature_format import featureFormat, targetFeatureSplit
dictionary = pickle.load( open("../final_project/final_project_dataset_modified.pkl", "r") )
def finance_regression(dictionary, features_list, fit_test=False):
data = featureFormat( dictionary, features_list, remove_any_zeroes=True)
target, features = targetFeatureSplit( data )
### training-testing split needed in regression, just like classification
from sklearn.cross_validation import train_test_split
feature_train, feature_test, target_train, target_test = train_test_split(features, target, test_size=0.5, random_state=42)
train_color = "b"
test_color = "r"
reg = linear_model.LinearRegression()
reg.fit(feature_train, target_train)
### draw the scatterplot, with color-coded training and testing points
import matplotlib.pyplot as plt
for feature, target in zip(feature_test, target_test):
plt.scatter( feature, target, color=test_color )
for feature, target in zip(feature_train, target_train):
plt.scatter( feature, target, color=train_color )
### labels for the legend
plt.scatter(feature_test[0], target_test[0], color=test_color, label="test")
plt.scatter(feature_test[0], target_test[0], color=train_color, label="train")
# draw the regression line, once it's coded
plt.plot( feature_test, reg.predict(feature_test) )
plt.xlabel(features_list[1])
plt.ylabel(features_list[0])
plt.legend()
if fit_test:
reg.fit(feature_test, target_test)
plt.plot(feature_train, reg.predict(feature_train), color="r")
return (reg, feature_train, target_train, feature_test, target_test)
(reg, feature_train, target_train, feature_test, target_test) = finance_regression(dictionary, ["bonus", "salary"])
print 'slope = {0}'.format(reg.coef_[0])
print 'intercept = {0}'.format(reg.intercept_)
slope = 5.44814028881
intercept = -102360.543294
print 'score on training set = {0}'.format(reg.score(feature_train, target_train))
score on training set = 0.0455091926995
print 'score on test set = {0}'.format(reg.score(feature_test, target_test))
score on test set = -1.48499241737
(reg, feature_train, target_train, feature_test, target_test) = finance_regression(dictionary, ['bonus', 'long_term_incentive'])
(reg, feature_train, target_train, feature_test, target_test) = finance_regression(dictionary, ["bonus", "salary"], fit_test=True)
print 'slope = {0}'.format(reg.coef_[0])
slope = 2.27410114127
import sys
sys.path.append("C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/tools/")
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/choose_your_own')
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/datasets_questions')
import os
os.chdir('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/outliers')
import random
import numpy
import matplotlib.pyplot as plt
import pickle
from outlier_cleaner import outlierCleaner
### load up some practice data with outliers in it
ages = pickle.load( open("practice_outliers_ages.pkl", "r") )
net_worths = pickle.load( open("practice_outliers_net_worths.pkl", "r") )
### ages and net_worths need to be reshaped into 2D numpy arrays
### second argument of reshape command is a tuple of integers: (n_rows, n_columns)
### by convention, n_rows is the number of data points
### and n_columns is the number of features
ages = numpy.reshape( numpy.array(ages), (len(ages), 1))
net_worths = numpy.reshape( numpy.array(net_worths), (len(net_worths), 1))
from sklearn.cross_validation import train_test_split
ages_train, ages_test, net_worths_train, net_worths_test = train_test_split(ages, net_worths, test_size=0.1, random_state=42)
# fit a linear regression
from sklearn import linear_model
reg = linear_model.LinearRegression()
reg.fit(ages_train, net_worths_train)
print 'slope = {0}'.format(reg.coef_[0][0])
%matplotlib inline
plt.plot(ages, reg.predict(ages), color="blue")
plt.scatter(ages, net_worths)
slope = 5.07793064344
print 'score = {0}'.format(reg.score(ages_test, net_worths_test))
score = 0.878262478835
def outlierCleaner(predictions, ages, net_worths):
"""
Clean away the 10% of points that have the largest
residual errors (difference between the prediction
and the actual net worth).
Return a list of tuples named cleaned_data where
each tuple is of the form (age, net_worth, error).
"""
errors = net_worths-predictions
threshold = numpy.percentile(numpy.absolute(errors), 90)
#print threshold
#print numpy.max(numpy.absolute(errors))
#print numpy.sort(numpy.absolute(errors), axis=0)
cleaned_data = [(age, net_worth, error) for age, net_worth, error in zip(ages, net_worths, errors) if abs(error) <= threshold]
return cleaned_data
reg = linear_model.LinearRegression()
reg.fit(ages_train, net_worths_train)
plt.plot(ages, reg.predict(ages), color='blue')
# plot all points in blue
plt.scatter(ages, net_worths, color='blue')
# plot the current training points in orange
plt.scatter(ages_train, net_worths_train, color='orange')
### identify and remove the most outlier-y points
predictions = reg.predict(ages_train)
cleaned_data = outlierCleaner( predictions, ages_train, net_worths_train )
### only run this code if cleaned_data is returning data
if len(cleaned_data) > 0:
# the non-outlier ages, net worths, and errors
ages_train2, net_worths_train2, errors_train2 = zip(*cleaned_data)
ages_train2 = numpy.reshape( numpy.array(ages_train2), (len(ages_train2), 1))
net_worths_train2 = numpy.reshape( numpy.array(net_worths_train2), (len(net_worths_train2), 1))
# refit the cleaned data
reg2 = linear_model.LinearRegression()
reg2.fit(ages_train2, net_worths_train2)
plt.plot(ages, reg2.predict(ages), color='red')
plt.scatter(ages_train2, net_worths_train2, color='red')
plt.xlabel("ages")
plt.ylabel("net worths")
else:
print "outlierCleaner() is returning an empty list, no refitting to be done"
print 'new slope = {0}'.format(reg2.coef_[0][0])
new slope = 6.36859480694
print 'new score = {0}'.format(reg2.score(ages_test, net_worths_test))
new score = 0.983189455686
from feature_format import featureFormat, targetFeatureSplit
### read in data dictionary, convert to numpy array
data_dict = pickle.load( open("../final_project/final_project_dataset.pkl", "r") )
features = ["salary", "bonus"]
data = featureFormat(data_dict, features)
plt.scatter(data[:,0], data[:,1])
plt.xlabel("salary")
plt.ylabel("bonus")
import pandas as pd
df = pd.DataFrame(data_dict)
df.loc['salary',:] = pd.to_numeric(df.loc['salary',:], errors='coerce')
df.loc['bonus',:] = pd.to_numeric(df.loc['bonus',:], errors='coerce')
print df.loc['salary',:].idxmax(axis=1)
Outlier name: TOTAL
data_dict.pop('TOTAL', 0)
data = featureFormat(data_dict, features)
plt.scatter(data[:,0], data[:,1])
plt.xlabel("salary")
plt.ylabel("bonus")
#print df.columns[name wdf.loc['salary',:] > 1*10**6 and df.loc['bonus',:] > 5*10**6]
print [name for name in df.columns if df.loc['salary', name] > 10**6 and df.loc['bonus',name] > 5*10**6]
['LAY KENNETH L', 'SKILLING JEFFREY K', 'TOTAL']
import sys
sys.path.append("C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/tools/")
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/choose_your_own')
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/datasets_questions')
import os
os.chdir('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/outliers')
import pickle
import numpy
import matplotlib.pyplot as plt
from feature_format import featureFormat, targetFeatureSplit
%matplotlib inline
def Draw(pred, features, poi, mark_poi=True, name="image.png", f1_name="feature 1", f2_name="feature 2"):
""" some plotting code designed to help you visualize your clusters """
### plot each cluster with a different color--add more colors for
### drawing more than five clusters
colors = ["b", "c", "k", "m", "g"]
for ii, pp in enumerate(pred):
plt.scatter(features[ii][0], features[ii][1], color = colors[pred[ii]])
### if you like, place red stars over points that are POIs (just for funsies)
if mark_poi:
for ii, pp in enumerate(pred):
if poi[ii]:
plt.scatter(features[ii][0], features[ii][1], color="r", marker="*")
plt.xlabel(f1_name)
plt.ylabel(f2_name)
### load in the dict of dicts containing all the data on each person in the dataset
data_dict = pickle.load( open("../final_project/final_project_dataset.pkl", "r") )
### there's an outlier--remove it!
data_dict.pop("TOTAL", 0)
# the features to be used
features_list = ['poi', 'salary', 'exercised_stock_options']
def finance_kmeans(data_dict, features_list):
data = featureFormat(data_dict, features_list )
poi, finance_features = targetFeatureSplit( data )
# plot the first 2 features
for f in finance_features:
plt.scatter( f[0], f[1] )
# k-means clustering
from sklearn.cluster import KMeans
clf = KMeans(2)
clf.fit(finance_features)
pred = clf.predict(finance_features)
# show the clustering
Draw(pred, finance_features, poi, mark_poi=False, name="clusters.pdf", f1_name=features_list[1], f2_name=features_list[2])
return None
finance_kmeans(data_dict, features_list)
features_list = ['poi', 'salary', 'exercised_stock_options', 'total_payments']
finance_kmeans(data_dict, features_list)
import pandas as pd
df = pd.DataFrame(data_dict)
df.loc['exercised_stock_options',:] = pd.to_numeric(df.loc['exercised_stock_options',:], errors='coerce')
print df.loc['exercised_stock_options',:].max(skipna=True)
print df.loc['exercised_stock_options',:].min(skipna=True)
Max : 34348384.0
Min: 3285.0
df.loc['salary',:] = pd.to_numeric(df.loc['salary',:], errors='coerce')
print df.loc['salary',:].max(skipna=True)
print df.loc['salary',:].min(skipna=True)
Max : 1111258.0
Min: 477.0
import sys
sys.path.append("C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/tools/")
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/choose_your_own')
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/datasets_questions')
import os
os.chdir('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/outliers')
import numpy as np
from sklearn.preprocessing import MinMaxScaler
weights = np.array([[115.], [140.], [175.]])
scaler = MinMaxScaler()
rescaled_weight = scaler.fit_transform(weights)
import pickle
import numpy
#import matplotlib.pyplot as plt
from feature_format import featureFormat, targetFeatureSplit
### load in the dict of dicts containing all the data on each person in the dataset
data_dict = pickle.load( open("../final_project/final_project_dataset.pkl", "r") )
### there's an outlier--remove it!
data_dict.pop("TOTAL", 0)
# the features to be used
features_list = ['poi', 'salary', 'exercised_stock_options']
data = featureFormat(data_dict, features_list)
_, salary, stock = zip(*data)
# put the features into 2-D numpy arrays
salary = np.array(salary).reshape((len(salary),1))
stock = np.array(stock).reshape((len(stock),1))
# rescale
scaler = MinMaxScaler()
salary = scaler.fit_transform(salary)
print '$200,000 becomes {0}'.format(scaler.transform([[200000.]])[0][0])
stock = scaler.fit_transform(stock)
print '$1,000,000 becomes {0}'.format(scaler.transform([[1000000.]])[0][0])
$200,000 becomes 0.179976207145
$1,000,000 becomes 0.0291134511597
import sys
sys.path.append("C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/tools/")
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/choose_your_own')
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/datasets_questions')
import os
os.chdir('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/text_learning')
from sklearn.feature_extraction.text import CountVectorizer
vectorizer = CountVectorizer()
string1 = '''Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pharetra ornare lacinia.
Cras et facilisis sem. Mauris fermentum nec dui at aliquam. Mauris ante justo, aliquam
eget facilisis ac, elementum eget dolor. Nulla lacinia ac lorem vel tempus. Vivamus condimentum
vulputate semper. Nullam dictum, mauris dignissim auctor suscipit, dui turpis elementum turpis,
et tempor urna diam sed nisl. Vestibulum mollis quam at nisl egestas tincidunt. Nullam ut nibh
fringilla, ultricies neque vel, tempor erat. Phasellus vel sem vitae ligula viverra luctus hendrerit
ac quam. Vivamus dignissim, diam sed porttitor lacinia, elit erat lobortis tellus, nec euismod dolor turpis a leo.'''
string2 = '''Mauris felis nibh, tempor ac pulvinar sed, feugiat at neque. In enim elit, venenatis nec magna eu, vestibulum
lobortis libero. Nullam scelerisque pulvinar ex consectetur tempor. Morbi congue quis leo auctor facilisis. Mauris
et diam ultricies, interdum nisi ac, condimentum turpis. Donec a risus sed dolor blandit ultrices. Nulla ac ultrices
elit. Nulla dictum metus tortor, in sollicitudin enim rutrum id. Nulla magna felis, molestie vel odio et, congue ornare
nisi. Nunc molestie, mi non blandit sodales, neque diam varius quam, nec tempus metus neque vel nibh. Morbi sit amet
sapien nec ipsum feugiat lacinia ut eu orci. Mauris id enim tincidunt, aliquet augue quis, vehicula libero. Donec eu
laoreet nibh.'''
string3 = '''Donec urna massa, faucibus et interdum id, facilisis interdum augue. Nunc enim nulla, tristique sit amet velit
in, lacinia mollis mi. Nullam malesuada felis sed libero porttitor dapibus ut quis dolor. Curabitur vitae neque
at arcu condimentum suscipit. Quisque sollicitudin est a elit sollicitudin, ac consectetur nisi blandit. Vestibulum
rhoncus viverra orci, et porta purus maximus quis. Pellentesque consectetur velit eget orci rutrum mollis. Nullam
condimentum vehicula ante at dignissim. Curabitur gravida, lorem in vehicula gravida, enim arcu semper nulla,
id tempor magna eros vel tortor.'''
email_list = [string1, string2, string3]
bag_of_words = vectorizer.fit_transform(email_list)
print vectorizer.vocabulary_.get('id')
from nltk.corpus import stopwords
sw = stopwords.words('english')
print 'Number of stopwords: {0}'.format(len(sw))
Number of stopwords: 153
from nltk.stem.snowball import SnowballStemmer
stemmer = SnowballStemmer('english')
print stemmer.stem('responsiveness')
print stemmer.stem('responsivity')
print stemmer.stem('unresponsive')
respons
respons
unrespons
import string
def parseOutText(f):
""" given an opened email file f, parse out all text below the
metadata block at the top
(in Part 2, you will also add stemming capabilities)
and return a string that contains all the words
in the email (space-separated)
example use case:
f = open("email_file_name.txt", "r")
text = parseOutText(f)
"""
f.seek(0) ### go back to beginning of file (annoying)
all_text = f.read()
### split off metadata
content = all_text.split("X-FileName:")
words = ""
if len(content) > 1:
### remove punctuation
text_string = content[1].translate(string.maketrans("", ""), string.punctuation)
words = text_string
return words
ff = open("../text_learning/test_email.txt", "r")
text = parseOutText(ff)
print text
from nltk.stem.snowball import SnowballStemmer
def parseOutText(f):
'''
Input: a file containing text
Output: the stemmed words in the input text, all separated by a single space
'''
f.seek(0) ### go back to beginning of file (annoying)
all_text = f.read()
### split off metadata
content = all_text.split("X-FileName:")
# the stemmer
stemmer = SnowballStemmer('english')
# the string of words
words = ""
if len(content) > 1:
### remove punctuation
text_string = content[1].translate(string.maketrans("", ""), string.punctuation)
### split the text string into individual words, stem each word,
### and append the stemmed word to words (make sure there's a single
### space between each stemmed word)
for word in text_string.split():
# stem the word and add it to words
words += stemmer.stem(word) + ' '
return words[:-1]
ff = open("../text_learning/test_email.txt", "r")
text = parseOutText(ff)
print text
import pickle
from sklearn.feature_extraction.text import TfidfVectorizer
"""
Starter code to process the emails from Sara and Chris to extract
the features and get the documents ready for classification.
The list of all the emails from Sara are in the from_sara list
likewise for emails from Chris (from_chris)
The actual documents are in the Enron email dataset, which
you downloaded/unpacked in Part 0 of the first mini-project. If you have
not obtained the Enron email corpus, run startup.py in the tools folder.
The data is stored in lists and packed away in pickle files at the end.
"""
sw = ["sara", "shackleton", "chris", "germani"]
with open("from_sara.txt", "r") as from_sara, open("from_chris.txt", "r") as from_chris:
from_data = []
word_data = []
### temp_counter is a way to speed up the development--there are
### thousands of emails from Sara and Chris, so running over all of them
### can take a long time
### temp_counter helps you only look at the first 200 emails in the list so you
### can iterate your modifications quicker
temp_counter = 0
for name, from_person in [("sara", from_sara), ("chris", from_chris)]:
for path in from_person:
### only look at first 200 emails when developing
### once everything is working, remove this line to run over full dataset
#temp_counter += 1
if temp_counter < 200:
path = os.path.join('..', path[:-1])
with open(path, 'r') as email:
### use parseOutText to extract the text from the opened email
text = parseOutText(email)
### use str.replace() to remove any instances of the words
### ["sara", "shackleton ", "chris", "germani"]
for word in sw:
if(word in text):
text = text.replace(word, "")
### append the text to word_data
word_data.append(text.replace('\n',' ').strip())
### append a 0 to from_data if email is from Sara, and 1 if email is from Chris
if name=='sara':
from_data.append(0)
else:
from_data.append(1)
pickle.dump( word_data, open("your_word_data.pkl", "w") )
pickle.dump( from_data, open("your_email_authors.pkl", "w") )
print word_data[152]
# word data is a list of strings that we get by stemming the emails
### in Part 4, do TfIdf vectorization here
vectorizer = TfidfVectorizer(stop_words="english", lowercase=True)
vectorizer.fit_transform(word_data)
feature_names = vectorizer.get_feature_names()
print 'Number of different words: {0}'.format(len(feature_names))
Number of different words: 38757
print feature_names[34597]
import sys
sys.path.append("C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/tools/")
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/choose_your_own')
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/datasets_questions')
import os
os.chdir('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/feature_selection')
import pickle
import numpy
numpy.random.seed(42)
words_file = "../text_learning/your_word_data.pkl"
authors_file = "../text_learning/your_email_authors.pkl"
def my_func(words_file, authors_file):
'''
I will use this code later in the lesson so I made it a function
'''
### The words (features) and authors (labels), already largely processed.
### These files should have been created from the previous (Lesson 10)
### mini-project.
word_data = pickle.load( open(words_file, "r"))
authors = pickle.load( open(authors_file, "r") )
### test_size is the percentage of events assigned to the test set (the
### remainder go into training)
### feature matrices changed to dense representations for compatibility with
### classifier functions in versions 0.15.2 and earlier
from sklearn import cross_validation
features_train, features_test, labels_train, labels_test = cross_validation.train_test_split(word_data, authors, test_size=0.1, random_state=42)
from sklearn.feature_extraction.text import TfidfVectorizer
vectorizer = TfidfVectorizer(sublinear_tf=True, max_df=0.5,
stop_words='english')
features_train = vectorizer.fit_transform(features_train)
features_test = vectorizer.transform(features_test).toarray()
### a classic way to overfit is to use a small number
### of data points and a large number of features;
### train on only 150 events to put ourselves in this regime
features_train = features_train[:150].toarray()
labels_train = labels_train[:150]
from sklearn.tree import DecisionTreeClassifier
clf = DecisionTreeClassifier()
clf.fit(features_train, labels_train)
return clf, vectorizer, features_train, features_test, labels_train, labels_test
(clf, vectorizer, features_train, features_test, labels_train, labels_test) = my_func(words_file, authors_file)
print 'Number of training points = {0}'.format(len(features_train))
Number of training points = 150
print 'Accuracy on test set = {0}'.format(clf.score(features_test, labels_test))
Accuracy on test set = 0.947667804323
top_features = [(number, feature, vectorizer.get_feature_names()[number]) for number, feature in
zip(range(len(clf.feature_importances_)), clf.feature_importances_) if feature > 0.2]
print top_features
import string
from nltk.stem.snowball import SnowballStemmer
def parseOutText(f):
'''
Input: a file containing text
Output: the stemmed words in the input text, all separated by a single space
'''
f.seek(0) ### go back to beginning of file (annoying)
all_text = f.read()
### split off metadata
content = all_text.split("X-FileName:")
# the stemmer
stemmer = SnowballStemmer('english')
# the string of words
words = ""
if len(content) > 1:
### remove punctuation
text_string = content[1].translate(string.maketrans("", ""), string.punctuation)
### split the text string into individual words, stem each word,
### and append the stemmed word to words (make sure there's a single
### space between each stemmed word)
for word in text_string.split():
# stem the word and add it to words
words += stemmer.stem(word) + ' '
return words[:-1]
ff = open("../text_learning/test_email.txt", "r")
text = parseOutText(ff)
from sklearn.feature_extraction.text import TfidfVectorizer
"""
Starter code to process the emails from Sara and Chris to extract
the features and get the documents ready for classification.
The list of all the emails from Sara are in the from_sara list
likewise for emails from Chris (from_chris)
The actual documents are in the Enron email dataset, which
you downloaded/unpacked in Part 0 of the first mini-project. If you have
not obtained the Enron email corpus, run startup.py in the tools folder.
The data is stored in lists and packed away in pickle files at the end.
"""
def sara_and_chris(sw):
'''
I'm going to reuse this code later so I'm making it a function
'''
with open("../text_learning/from_sara.txt", "r") as from_sara, open("../text_learning/from_chris.txt", "r") as from_chris:
from_data = []
word_data = []
### temp_counter is a way to speed up the development--there are
### thousands of emails from Sara and Chris, so running over all of them
### can take a long time
### temp_counter helps you only look at the first 200 emails in the list so you
### can iterate your modifications quicker
temp_counter = 0
for name, from_person in [("sara", from_sara), ("chris", from_chris)]:
for path in from_person:
### only look at first 200 emails when developing
### once everything is working, remove this line to run over full dataset
#temp_counter += 1
if temp_counter < 200:
path = os.path.join('..', path[:-1])
with open(path, 'r') as email:
### use parseOutText to extract the text from the opened email
text = parseOutText(email)
### use str.replace() to remove any instances of the words
### ["sara", "shackleton ", "chris", "germani"]
for word in sw:
if(word in text):
text = text.replace(word, "")
### append the text to word_data
word_data.append(text.replace('\n',' ').strip())
### append a 0 to from_data if email is from Sara, and 1 if email is from Chris
if name=='sara':
from_data.append(0)
else:
from_data.append(1)
pickle.dump( word_data, open("your_word_data.pkl", "w") )
pickle.dump( from_data, open("your_email_authors.pkl", "w") )
return None
sw = ["sara", "shackleton", "chris", "germani", "sshacklensf"]
sara_and_chris(sw)
words_file = 'your_word_data.pkl'
authors_file = 'your_email_authors.pkl'
(clf, vectorizer, features_train, features_test, labels_train, labels_test) = my_func(words_file, authors_file)
top_features = [(number, feature, vectorizer.get_feature_names()[number]) for number, feature in
zip(range(len(clf.feature_importances_)), clf.feature_importances_) if feature > 0.2]
print top_features
# remove the 2 outlier words
sw = ["sara", "shackleton", "chris", "germani", "sshacklensf", "cgermannsf"]
sara_and_chris(sw)
# re-fit the tree
words_file = 'your_word_data.pkl'
authors_file = 'your_email_authors.pkl'
(clf, vectorizer, features_train, features_test, labels_train, labels_test) = my_func(words_file, authors_file)
print 'Accuracy on test set = {0}'.format(clf.score(features_test, labels_test))
Accuracy on test set = 0.816268486917
import sys
sys.path.append("C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/tools/")
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/choose_your_own')
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/datasets_questions')
import os
os.chdir('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/pca')
%matplotlib inline
# code provided with the course
%run eigenfaces.py
===================================================
Faces recognition example using eigenfaces and SVMs
===================================================
The dataset used in this example is a preprocessed excerpt of the
"Labeled Faces in the Wild", aka LFW_:
http://vis-www.cs.umass.edu/lfw/lfw-funneled.tgz (233MB)
.. _LFW: http://vis-www.cs.umass.edu/lfw/
original source: http://scikit-learn.org/stable/auto_examples/applications/face_recognition.html
Total dataset size:
n_samples: 1288
n_features: 1850
n_classes: 7
Extracting the top 150 eigenfaces from 966 faces
done in 0.276s
Projecting the input data on the eigenfaces orthonormal basis
done in 0.035s
Fitting the classifier to the training set
done in 19.882s
Best estimator found by grid search:
SVC(C=1000.0, cache_size=200, class_weight='balanced', coef0=0.0,
decision_function_shape=None, degree=3, gamma=0.001, kernel='rbf',
max_iter=-1, probability=False, random_state=None, shrinking=True,
tol=0.001, verbose=False)
Predicting the people names on the testing set
done in 0.058s
precision recall f1-score support
Ariel Sharon 0.50 0.62 0.55 13
Colin Powell 0.76 0.88 0.82 60
Donald Rumsfeld 0.73 0.70 0.72 27
George W Bush 0.92 0.87 0.89 146
Gerhard Schroeder 0.77 0.80 0.78 25
Hugo Chavez 0.75 0.60 0.67 15
Tony Blair 0.88 0.83 0.86 36
avg / total 0.83 0.83 0.83 322
[[ 8 0 3 2 0 0 0]
[ 2 53 1 3 0 1 0]
[ 4 1 19 2 0 0 1]
[ 1 11 2 127 3 1 1]
[ 0 2 0 1 20 1 1]
[ 0 2 0 1 2 9 1]
[ 1 1 1 2 1 0 30]]
Predicted Images
Eigen Faces
for n_components in [10, 15, 25, 50, 100, 250]:
pca = RandomizedPCA(n_components=n_components, whiten=True).fit(X_train)
eigenfaces = pca.components_.reshape((n_components, h, w))
X_train_pca = pca.transform(X_train)
X_test_pca = pca.transform(X_test)
# Train a SVM classification model
param_grid = {
'C': [1e3, 5e3, 1e4, 5e4, 1e5],
'gamma': [0.0001, 0.0005, 0.001, 0.005, 0.01, 0.1],
}
clf = GridSearchCV(SVC(kernel='rbf', class_weight='balanced'), param_grid)
clf = clf.fit(X_train_pca, y_train)
# Quantitative evaluation of the model quality on the test set
y_pred = clf.predict(X_test_pca)
if n_components==10:
print 'n_components' + classification_report(y_test, y_pred, target_names=target_names).split('\n')[0]
print '{0:12d}'.format(n_components) + classification_report(y_test, y_pred, target_names=target_names).split('\n')[2]
n_components precision recall f1-score support
10 Ariel Sharon 0.14 0.23 0.17 13
15 Ariel Sharon 0.45 0.38 0.42 13
25 Ariel Sharon 0.53 0.69 0.60 13
50 Ariel Sharon 0.62 0.77 0.69 13
100 Ariel Sharon 0.67 0.62 0.64 13
250 Ariel Sharon 0.60 0.69 0.64 13
import sys
sys.path.append("C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/tools/")
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/choose_your_own')
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/datasets_questions')
import os
os.chdir('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/validation')
from sklearn import datasets
from sklearn.svm import SVC
from sklearn import cross_validation
iris = datasets.load_iris()
features = iris.data
labels = iris.target
### set the random_state to 0 and the test_size to 0.4 so
### we can exactly check your result
features_train, features_test, labels_train, labels_test = cross_validation.train_test_split(iris.data, iris.target, test_size=0.4, random_state=0)
clf = SVC(kernel="linear", C=1.)
clf.fit(features_train, labels_train)
print clf.score(features_test, labels_test)
import pickle
from feature_format import featureFormat, targetFeatureSplit
data_dict = pickle.load(open("../final_project/final_project_dataset.pkl", "r") )
### first element is our labels, any added elements are predictor
### features. Keep this the same for the mini-project, but you'll
### have a different feature list when you do the final project.
features_list = ["poi", "salary"]
data = featureFormat(data_dict, features_list)
labels, features = targetFeatureSplit(data)
### it's all yours from here forward!
from sklearn.tree import DecisionTreeClassifier
clf = DecisionTreeClassifier()
clf.fit(features,labels)
clf.score(features,labels)
features_train, features_test, labels_train, labels_test = cross_validation.train_test_split(features, labels, test_size=0.3, random_state=42)
clf.fit(features_train, labels_train)
clf.score(features_test, labels_test)
Recall = P( predict A | truth is A )
Precision = P( truth is A | predict A )
import sys
sys.path.append("C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/tools/")
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/choose_your_own')
sys.path.append('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/datasets_questions')
import os
os.chdir('C:/Users/Jeff/udacity/Intro_to_Machine_Learning/ud120-projects/evaluation')
import pickle
from feature_format import featureFormat, targetFeatureSplit
data_dict = pickle.load(open("../final_project/final_project_dataset.pkl", "r") )
### add more features to features_list!
features_list = ["poi", "salary"]
data = featureFormat(data_dict, features_list)
labels, features = targetFeatureSplit(data)
# decision tree code from the previous lesson
from sklearn.tree import DecisionTreeClassifier
from sklearn import cross_validation
from sklearn.metrics import confusion_matrix, precision_score, recall_score, classification_report
features_train, features_test, labels_train, labels_test = cross_validation.train_test_split(features, labels, test_size=0.3, random_state=42)
clf = DecisionTreeClassifier()
clf.fit(features_train, labels_train)
pred = clf.predict(features_test)
print confusion_matrix(labels_test, pred)
[[21 4]
[ 4 0]]
print precision_score(labels_test, pred)
print classification_report(labels_test, pred)
precision recall f1-score support
0.0 0.84 0.84 0.84 25
1.0 0.00 0.00 0.00 4
avg / total 0.72 0.72 0.72 29
print recall_score(labels_test, pred)
predictions = [0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1]
true_labels = [0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0]
cm = confusion_matrix(true_labels, predictions)
print cm, '\n'
print '{0} True positives'.format(cm[1][1])
print '{0} True negatives'.format(cm[0][0])
print '{0} False positives'.format(cm[0][1])
print '{0} False negatives'.format(cm[1][0])
[[9 3]
[2 6]]
6 True positives
9 True negatives
3 False positives
2 False negatives
print precision_score(true_labels, predictions)
print recall_score(true_labels, predictions)


DivideTweet!
Enter your long tweet below, and it will automatically be divided into 280-character slices for you to simply copy, paste and post!
(x/y)
x/y
/x
{{ tweet }}


cookie-consent-js
- Example in plain HTML
API
Show the cookie settings dialog
Log the status to the developer console


SystemInfo adapter settings |
|
| Name(s) | Type | Source | RegExp/Filter | Convert | Role/Type | WriteCommand | Schedule |
|---|
On save adapter restarts with new config immediately
Save/load config
Create Json and download file
Load File:


| MATLAB 文件帮助: cv.HOGDescriptor | 查看 cv.HOGDescriptor 的代码 | Index |
HOGDescriptor Histogram of Oriented Gaussian (HOG) descriptor and detector
The class implements Histogram of Oriented Gradients object detector [Dalal2005].
The basic usage is the following for computing HOG descriptors:
hog = cv.HOGDescriptor();
descriptors = hog.compute(im);
This computes descriptors in a "dense" setting; Each row is a feature
vector computed from a window of size WinSize
slided across the input
image gradient. Each vector element is a histogram of gradient
orientations (quantized into NBins
directions). The histogram is
collected within a "cell" of pixels of size CellSize
, and locally
normalized (see HistogramNormType
and L2HysThreshold
) over larger
spatial "block" regions of size BlockSize
overlapped according to
BlockStride
. See cv.HOGDescriptor.getDescriptorSize.
If you need to compute descriptors for a set of certain "sparse"
keypoints (for example SIFT or SURF keypoints), use the Locations
option of the compute method:
keypoints = cv.FAST(im);
descriptors = hog.compute(im, 'Locations', {keypoints.pt});
The next step in object recognition using HOG descriptors is to feed the descriptors computed from positive and negative images into a linear SVM classifier trained to classify whether a window is an object or not. This trained SVM model is represented by a set of coefficients for each element in the feature vector. This vector is assigned to the cv.HOGDescriptor.SvmDetector property.
Alternatively, you can use the default built-in people detector which is accessible by name as:
% detect and localize upright people in images
hog.SVMDetector = 'DefaultPeopleDetector';
boxes = hog.detectMultiScale(im);
In this case, there is no need to train an SVM model.
Either way, you simply call the detect methods which use the saved
coefficients on the input feature-vector to compute a weighted sum. If
the sum is greater than a user-specified threshold HitThreshold
, then
it is classified an object (a pedestrian in the case of the builtin
detectors).
The cv.HOGDescriptor.detectMultiScale method detects at multiple scales
(see NLevels
and Scale
) and directly returns the bounding boxes. The
cv.HOGDescriptor.detect method returns a list of top-left corner points,
where the detected object size is the same as the detector's window
size.
[Dalal2005]:
Navneet Dalal and Bill Triggs. "Histogram of oriented gradients for human detection". CVPR 2005. http://lear.inrialpes.fr/pubs/2005/DT05/
| Superclasses | handle |
| Sealed | false |
| Construct on load | false |
| HOGDescriptor | Create a new or load an existing HOG descriptor and detector |
| BlockSize | Block size |
| BlockStride | Block stride of a grid |
| CellSize | Cell size of a grid |
| DerivAperture | Derivative of aperture |
| GammaCorrection | Gamma correction |
| HistogramNormType | Histogram normalization method |
| L2HysThreshold | L2 Hysterisis threshold |
| NBins | Number of bins |
| NLevels | Number of levels |
| SignedGradient | Signed gradient |
| SvmDetector | Coefficients for the linear SVM classifier. |
| WinSigma | Window sigma |
| WinSize | Window size |
| id | Object ID |
| addlistener | Add listener for event. | |
| checkDetectorSize | Checks the size of the detector is valid | |
| compute | Returns HOG block descriptors computed for the whole image | |
| computeGradient | Computes gradient | |
| delete | Destructor | |
| detect | Performs object detection without a multi-scale window | |
| detectMultiScale | Performs object detection with a multi-scale window | |
| detectMultiScaleROI | Evaluate specified ROI and return confidence value for each location in multiple scales | |
| detectROI | Evaluate specified ROI and return confidence value for each location | |
| eq | == (EQ) Test handle equality. | |
| findobj | Find objects matching specified conditions. | |
| findprop | Find property of MATLAB handle object. | |
| ge | >= (GE) Greater than or equal relation for handles. | |
| getDescriptorSize | Returns the number of coefficients required for the classification | |
| getWinSigma | Get window sigma | |
| groupRectangles | Groups the object candidate rectangles | |
| gt | > (GT) Greater than relation for handles. | |
| Sealed | isvalid | Test handle validity. |
| le | <= (LE) Less than or equal relation for handles. | |
| load | Loads a HOG descriptor config from a file | |
| lt | < (LT) Less than relation for handles. | |
| ne | ~= (NE) Not equal relation for handles. | |
| notify | Notify listeners of event. | |
| readALTModel | Read model from SVMlight format | |
| save | Saves a HOG descriptor config to a file |
| ObjectBeingDestroyed | Notifies listeners that a particular object has been destroyed. |


Across: 3. It can get very hot, contributing to thermophobia (3) 7,5dn. Swinging by to 24, should press label for violent 8 March 1973 (6 8) 8. Primarily really urbanised Hellweg region (4) 9. see 6 down 11. Northern city arraigns criminal (8) 12. Representative harbouring no love or jealousy (4) 14. Beers drunk around first of May, as they may provide a glow (6) 15. Cheats performed with modified sled (7) 16. Live alongside dilapidated flats in northern city (7) 18. Presentation of tipsy MP to monarch (7) 21. Some do so if ambushed while backing up fellow in mob (7) 23. Mother gets Abel's brother back, but he's crazy (6) 24. see 26 down 25. Playbill: "Leer - he speaks unfairly" (8) 27,19dn. Fancied lump developed as sickness sweeping the globe (3 8) 28. Soon to be completely unknown (4) 29. see 1 down 30. Animal mostly hung back (3) Down: 1,29ac. Abode Lily wrecked, target of 6 9 16 4 in 1973 (3 6) 2. Wild fury? Sole person who can fix it ... (8) 3. Moving any she-hunters? (6) 4. Group abridge scheme (7) 5. see 7 across 6,9ac. Militant group in favour of seeing a tiny bit of money (11 3) 10. On radio, promote group (4) 13. According to unusual map, "Beer Mile" not letting any water in (11) 17. see 26 down 19. see 27 across 20. Weather bureau can start to glimpse destruction (7) 22. G-men in field as regulars (4) 23. Board sorted mail but dropped last letter (6) 26,17,24ac. Reports bed with Warhol covered in fat as target of 6 9 20 on 7 5 (3 8 4)


Currently designing digital experiences @ Publicis Sapient.
Improving customer engagement & user experience of an online loyalty program
Empowering people with Type 1 Diabetes to travel with confidence
Enabling access to personal health information for a better patient experience
A social platform that motivates people to volunteer in their communities
A virtual shopping assistant for the visually impaired
A smart inventory tracking device that changes the way you manage food in your fridge
A lil' side hustle, launching soon...


{% extends 'base.html' %} {% block breadcrumbs %} Analytics API {% endblock breadcrumbs %} {% block body_content %}
Below is a full list of service parameters and their usage.


I solve code and write problems. If Go was a drug, I would be a drug addict. Sometimes I do TypeScript and SQL as well.
I spend a lot of time in the shell and enjoy writing shell scripts. When I run Linux there is usually some ricing involved.
PS. If I zone out midconversation, I'm probably thinking about code. Please forgive me.
mafredri @mafredri


Custom buttons are prepended to the taskbar, after which handlers can be attached to them.
Prepend icons to buttons


AKIRA
A film review by Chad Polenz
Copyright 1997 Chad Polenz
*** (out of 4 = good) 1987, not rated, 124 minutes [2 hours, 4 minutes] [animated - science fiction] Starring the voices of: Jimmy Flanders (Tetsuo), Drew Thomas (Kenada), Barbara Larsen (Kaye), produced by Ryohei Suzuki, Shunzo Kato, written by Katsuhiro Otomo, Izo Hashimoto, directed by Katsuhiro Otomo.
The Japanese probably have the wildest imaginations and the greatest spirit for action and adventure. They see animation in a much different manner than we do, and "Akira" is proof positive of that. The story takes place in the far future, in post-Apocolyptic "Neo-Tokyo." Stories that take place in these settings tend to have the same atmosphere: crime out of control; corrupt government; revolutions: and/or science and technology worshipped as gods. This film takes a bit of all of these aspects and mixes them together so we get a good sense of an abstract reality and an intense reality. We meet our main characters, a motorcycle gang of high school-aged boys, but they are not villains, in fact, they are quite likable. Immediately the film jumps into a high speed action sequence, which is probably the best scene in the movie. The animators pull no punches in depicting the graphic violence that takes place, such as: decapitation; a man being shot by hundreds of rounds; blood and gore; and total mass destruction. Perhaps what's most fascinating is the graphicness to it, because we don't get to see this stuff in America. The first half is a mad romp through Neo-Tokyo, defining the setting and introducing the main characters. Kenada (Thomas), the leader of the gang, is a wisecracking delinquent but is adorable. He and his gang are searching for their friend Tetsuo (Flanders) who was taken away by the military in a previous scene.  There is some sort of secret government project called Akira that could change the world and give tremendous power to its beholder, and this element will later play a key role. Meanwhile, Tetsuo realizes he has special powers, and is told by other "gifted children" who they are and where they came from. Eastern ideology plays a major role in defining these powers, we might consider it pure fantasy but I'm sure the Japanese hold some validity to the concept. There's really no single plot driving the film, it's basically a dizzying journey through many characters and storylines that are loosely connected. The film is story oriented, but it is the characterization and the spectacular action sequences that make it good. Still, "Akira" is interesting because we never know what's going to happen next. Just watching the animation and the fact that it has a pretty intricate, detailed story makes it all worthwhile.
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


{% extends "otree/BaseAdmin.html" %} {% block title %} Data Export {% endblock %} {% block content %}
If you publish research conducted using oTree, you are required by the oTree license to cite this paper.
Citation:
Chen, D.L., Schonger, M., Wickens, C., 2016. oTree - An open-source platform for laboratory, online and field experiments. Journal of Behavioral and Experimental Finance, vol 9: 88-97
| App | Data | Documentation | |
|---|---|---|---|
| {{ app.name }} |
No sessions has yet taken place
{% endif %}


Hello everyone!
Welcome to GeeksforGeeks
Translate this page in your preferred language:
You can translate the content of this page by selecting a language in the select box.


So you want to chat securely on Android?
Go back to the main screen and you should see the Guardian Project apps. Click on ChatSecure to install. Got it.
Enter: https://guardianproject.info/repo/ (don't forget the s!)
Done. Where are the apps?
Run the app and navigate over to Menu > Manage Repos > New Repository Cool. What do I enter?
There's an alternative app store. Install F-droid by entering
https://f-droid.org/FDroid.apk into a web browser. Done. Next?
Got it! I checked on a trusted channel: Spotify. Send the secret.
I'm thinking of a question...
I can see Bryan's fingerprint. Now let me send him a message that only you would know the answer to.
9. Let's send him an unencrypted message. Send "Oh hai!"
8. The padlock has a yellow "?"! Bryan got our chat & turned on encryption. Let's verify it's really Bryan.
Uh oh! The padlock has a Red "x", so not encrypted yet. Let's wait to see if Bryan turns on encryption.
6. Enter your account info:
Gchat, Facebook, DukGo, & XMPP all work.
All set!
Now we're getting started.
All set!
4. Open ChatSecure. Done.
3. Review the permissions. Then, maybe, accept them. OK, I trust you.
2. Search for ChatSecure. Got it.


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include "VOClient.h"
Defines | |
| #define | _VOCLIENT_LIB_ |
| #define | vx_regsearch vxregh_ |
| #define | vx_regsearchbysvc vxregc_ |
| #define | vx_regquery vxregy_ |
| #define | vx_raddsearchterm vxradm_ |
| #define | vx_rremovesearchterm vxrrem_ |
| #define | vx_rgetstcount vxrget_ |
| #define | vx_rgetquerystring vxrgeg_ |
| #define | vx_rexecute vxrexe_ |
| #define | vx_rexecuteraw vxrexw_ |
| #define | vx_rscount vxrsct_ |
| #define | vx_rsstr vxrssr_ |
| #define | vx_rsfloat vxrsft_ |
| #define | vx_rsint vxrsit_ |
| #define | XCHAR short |
| #define | PKCHAR char |
| #define | XINT int |
| #define | XEOS NULL |
Functions | |
| RegResult | vx_regsearch (XCHAR *term1, XCHAR *term2, int *orValues) |
| High-level Registry query interface. | |
| RegResult | vx_regsearchbysvc (XCHAR *svc, XCHAR *term, int *orValues) |
| Search Registry using a search term and service constraint. | |
| RegQuery | vx_regquery (XCHAR *term, int *orValues) |
| Create a RegistryQuery object. | |
| void | vx_raddsearchterm (RegQuery *query, XCHAR *term, int *orValue) |
| Add a search term to the specified query. | |
| void | vx_rremovesearchterm (RegQuery *query, XCHAR *term) |
| Remove a search term to the specified query. | |
| int | vx_rgetstcount (RegQuery *query) |
| Get the number of search terms in the current query. | |
| int | vx_rgetquerystring (RegQuery *query, XCHAR *qstring, int *maxch) |
| Get the current query as an http GET URL. | |
| RegResult | vx_rexecute (RegQuery *query) |
| Execute the specified query. | |
| int | vx_rexecuteraw (RegQuery *query, XCHAR *result, int *maxch) |
| Execute the specified query and return raw result string. | |
| int | vx_rgcount (RegResult *res) |
| int | vx_rgstr (RegResult *res, XCHAR *attribute, int *index, XCHAR *result, int *maxch) |
| double | vx_rgfloat (RegResult *res, XCHAR *attribute, int *index) |
| int | vx_rgint (RegResult *res, XCHAR *attribute, int *index) |
| PKCHAR * | spp2c (XCHAR *instr, int maxch) |
| int | c2spp (PKCHAR *instr, XCHAR *outstr, int maxch) |
| int | spplen (XCHAR *str) |
| int | vx_rscount (RegResult *res) |
| Return a count of the number of results records. | |
| int | vx_rsstr (RegResult *res, XCHAR *attribute, int *index, XCHAR *result, int *maxch) |
| Get a string-valued attribute from the result resource record. | |
| double | vx_rsfloat (RegResult *res, XCHAR *attribute, int *index) |
| Get a real-valued attribute from the result resource record. | |
| int | vx_rsint (RegResult *res, XCHAR *attribute, int *index) |
| Get an int-valued attribute from the result resource record. | |
Variables | |
| VOClient * | vo |
RegistryQuery ----------------------
High-Level Query:
res = voc_regSearch (term1, term2, orValues)
Programmatic Query:
query = voc_regQuery (term, orValues) // OR keyword list?
voc_regAddSearchTerm (query, term, orValue) // OR term w/ previous voc_regRemoveSearchTerm (query, term) // remove search term count = voc_regGetSTCount (query)
str = voc_regGetQueryString (query) // GET form of query
res = voc_regExecute (query) // return result obj str = voc_regExecuteRaw (query) // return raw XML
RegistryQueryResult
count = voc_resGetCount (res)
str = voc_resGetStr (res, attribute, index) dval = voc_resGetFloat (res, attribute, index) ival = voc_resGetInt (res, attribute, index)
For this implementation, we've chose to use the NVO Registry at JHU/STScI, specifically the QueryRegistry() method which provides a 'SimpleResource' form of the resource record. Support for the newer IVOA standard will be added later, for now we can quickly access the most commonly used fields of a resource using both a keyword and SQL form of the search.
| void vx_raddsearchterm | ( | RegQuery * | query, | |
| XCHAR * | term, | |||
| int * | orValue | |||
| ) |
Add a search term to the specified query.
VX_REGADDSEARCHTERM -- Add a search term (sql predicate or keyword list) to the specified query.
| query | Registry query handle | |
| term | keyword search term | |
| orValues | logically OR values? |
| RegQuery vx_regquery | ( | XCHAR * | term, | |
| int * | orValues | |||
| ) |
Create a RegistryQuery object.
VX_REGQUERY -- Get a RegistryQuery object.
| term | keyword search term | |
| orValues | logically OR values? |
| RegResult vx_regsearch | ( | XCHAR * | term1, | |
| XCHAR * | term2, | |||
| int * | orValues | |||
| ) |
High-level Registry query interface.
VX_REGSEARCH -- High-level procedure to form a query and execute it immediately. We allow that 'term1' may be a complex SQL WHERE predicate, and that 'term2' (or vice versa) is a search-keyword list. The 'orValues' applies to the keyword list (if present), otherwise it applies to the two search term elements. The default action if two terms are specified is to logically AND them.
The thinking here is that one might want SIAP services for Quasars. This is easily expressed in an SQL form to get SIAP resources, however a Quasar may be known as a QSO, AGN, active-nuclei, etc and so we need a easy way to OR the keywords but AND that result with the SQL predicate.
| term1 | first search term | |
| term2 | second search term | |
| orValues | logically OR values? |
| RegResult vx_regsearchbysvc | ( | XCHAR * | svc, | |
| XCHAR * | term, | |||
| int * | orValues | |||
| ) |
Search Registry using a search term and service constraint.
VX_REGSEARCHBYSERVICE -- Search the Registry using a search term and constrain by service type.
| svc | service type constraint | |
| term | keyword search term | |
| orValues | logically OR values? |
| RegResult vx_rexecute | ( | RegQuery * | query | ) |
Execute the specified query.
VX_REGEXECUTE -- Execute the specified query, returning a result object code or NULL.
| query | Registry query handle |
| int vx_rexecuteraw | ( | RegQuery * | query, | |
| XCHAR * | raw, | |||
| int * | maxch | |||
| ) |
Execute the specified query and return raw result string.
VX_REGEXECUTERAW -- Execute the specified query and return the raw resulting XML string.
| query | Registry query handle | |
| raw | raw result string | |
| maxch | length of result string |
| int vx_rgetquerystring | ( | RegQuery * | query, | |
| XCHAR * | qstr, | |||
| int * | maxch | |||
| ) |
Get the current query as an http GET URL.
VX_REGGETQUERYSTRING -- Get the current query as an http GET URL.
| query | Registry query handle | |
| qstr | returned query string | |
| maxch | length of query string |
| int vx_rgetstcount | ( | RegQuery * | query | ) |
Get the number of search terms in the current query.
VX_REGGETSTCOUNT -- Get the number of search terms in the current query.
| query | Registry query handle |
| void vx_rremovesearchterm | ( | RegQuery * | query, | |
| XCHAR * | term | |||
| ) |
Remove a search term to the specified query.
VX_REMOVESEARCHTERM -- Remove the search term from the query.
| query | Registry query handle | |
| term | keyword search term |
| count vx_rscount | ( | RegResult * | res | ) |
Return a count of the number of results records.
VX_RESGETCOUNT -- Return a count of the number of results records.
| res | Registry result handle |
| dval vx_rsfloat | ( | RegResult * | res, | |
| XCHAR * | attr, | |||
| int * | index | |||
| ) |
Get a real-valued attribute from the result resource record.
VX_GETFLOAT -- Get a real-valued attribute from the result resource record. Currently recognized real-valued attributes include:
MaxSR maximum search radius
Attribute string are case-insensitive.
| res | Registry result handle | |
| attr | record attribute | |
| index | record index |
| ival vx_rsint | ( | RegResult * | res, | |
| XCHAR * | attr, | |||
| int * | index | |||
| ) |
Get an int-valued attribute from the result resource record.
VX_GETINT -- Get a integer-valued attribute from the result resource record. Currently recognized real-valued attributes include:
MaxRecords maximum records returned by the service
Attribute string are case-insensitive.
| res | Registry result handle | |
| attr | record attribute | |
| index | record index |
| len vx_rsstr | ( | RegResult * | res, | |
| XCHAR * | attr, | |||
| int * | index, | |||
| XCHAR * | result, | |||
| int * | maxch | |||
| ) |
Get a string-valued attribute from the result resource record.
VX_GETSTR -- Get a string-valued attribute from the result resource record. Currently recognized real-valued attributes include:
Title Resource title (long version) ShortName Short name of Resource ServiceURL Service URL (if appropriate) ReferenceURL URL to reference about Resource Description Text description of resource Identifier Standard ivo identifier of resource ServiceType Service Type (Cone, Siap, etc) Type Resource Type (catalog, survey, etc) CoverageSpatial Spatial coverage (STC) CoverageTemporal Temporal coverage of data
CoverageSpectral Spectral coverage (csv list of bandpasses) ContentLevel Content level (research, EPO, etc -- csv list)
Attribute string are case-insensitive.
| res | Registry result handle | |
| attr | record attribute | |
| index | record index | |
| result | attribute string | |
| maxch | length of attribute string |


Return to homepage
It's a match
Contact email
Skills matched
Send email?
<EMAIL_ADDRESS>Website development
<EMAIL_ADDRESS>Set up hardware
<EMAIL_ADDRESS>Social media
<EMAIL_ADDRESS>Listing items on ebay


THE DEEP END A film review by Mark R. Leeper CAPSULE: Tilda Swinton stars as a mother who tries to hide the death of her son's male lover and in the process gets herself involved in a web of blackmail and deceit. Swinton gives a very good performance, but her character is more like a cork in water buffeted by the force of those around her than a person who takes action. The film is tense but not entirely satisfying. Rating: 6 (0 to 10), high +1 (-4 to +4)
For any thriller to work fully there are two real requirements. The viewer has to have some emotional investment in the characters, particularly the main character, and the characters have to make choices that will affect the outcome of the story. If we do not care what happens to the main character we might as well be watching pieces on a chessboard. If the people in the story do not make judgments and choices then they might as well be on a thrill ride at an amusement park following its inevitable track. They just ride through the various dangers they face. In THE DEEP END we are given reason to empathize with Margaret Hall (played by Tilda Swinton), but after the first half-hour or so she is mostly doing just what she has to do. While other characters are complex and at times do the unexpected, once we know Margaret well enough to care for her, we also know the choices that she will make. And by never doing anything unexpected she loses much of her interest value. The film is almost a morality tale. Having made a bad choice at the beginning, this long chain of events is what she has earned for herself.
Margaret Hall lives with her family in an idyllic existence in a nice house on Lake Tahoe. Her son Beau (Jonathan Tucker) is a promising music student making applications to various colleges. Margaret's one wish is to protect Beau from the clutches of a male lover whom she is sure just wants to use her son. After a clandestine assignation between the two Margaret finds the lover dead. Without telling anyone she decides to hide the body so her son will not be implicated in the investigation. This leaves her prey to blackmail and a horrific chain of events.
Swinton is known mostly for roles of women who have foregone anything like a "normal" lifestyle. Somehow her unusual, almost albino, looks lead to unusual roles. In ORLANDO she plays her best known role, an immortal who at one point for no obvious reason spontaneously changes gender from male to female. Frequently she plays women of power. It is a little odd seeing her play a housewife who at least starts out somewhat typical. Of course not long into the movie she is juggling her life as a housewife with her secret life dealing with blackmailers. The man who has contacted her for hush money also shows sides to his personality we would not expect.
This is the second screen adaptation of the 1947 novel THE BLANK WALL by Elizabeth Sanxay Holding. The first was the 1949 film THE RECKLESS MOMENT with James Mason and Joan Bennett directed by Max Ophuls. Ophuls chose to use actors who would be familiar to audiences, hence making it a glossier production. The team of Scott McGehee and David Siegal who have been writing and directing thrillers since 1993's SUTURE. Here again they wrote and directed. They chose to use generally less familiar actors than the previous version. Only Swinton and character actor Peter Donat were even vaguely familiar to me.
 I rate it a 6 on the 0 to 10 scale and a high +1 on the -4 to +4 scale.
Mark R. Leeper<EMAIL_ADDRESS>Copyright 2001 Mark R. Leeper
-- Mark R. Leeper,http://www.geocities.com/markleeper/ Or try your search engine on "Mark Leeper"
========== X-RAMR-ID: 29358 X-Language: en X-RT-ReviewID: 246528 X-RT-TitleID: 1109447 X-RT-AuthorID: 1309 X-RT-RatingText: 6/10
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


Quick memo for a setup process for arch linux arm on rpi with a wireless adapter:
Plugin the ethenet cable into rpi. Verify the wireless adapter is recognized by the kernel using
lsusb
:[root@alarmpi ~]# lsusb Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. LAN9500 Ethernet 10/100 Adapter Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. Bus 001 Device 004: ID 050d:945a Belkin Components F7D1101 v1 Basic Wireless Adapter [Realtek RTL8188SU]
Update the system:
pacman -Syu
- Install the base system and vim, netctl is the replcaement for the netcfg package:
packman -S base-devel vim netctl
- Following is just a replica of contents in arch wiki:
cp /etc/netctl/examples/wireless-wpa /etc/netctl
Editing the netctl/wireless-wpa file:
vim /etc/netctl/wireless-wpa
ESSID='yourssid' Key='yourpassword'
Testing the connection:
netctl start wireless-wpa
See the logs:
netctl status wireless-wpa
[root@alarmpi netctl]# netctl status wireless-wpa<EMAIL_ADDRESS>- Networking for netctl profile wireless-wpa Loaded: loaded<EMAIL_ADDRESS>static) Active: active (exited) since Sat 2013-04-27 07:56:54 BST; 7s ago Docs: man:netctl.profile(5) Process: 716 ExecStart=/usr/lib/network/network start %I (code=exited, status=0/SUCCESS) CGroup<EMAIL_ADDRESS>├─ 735 wpa_supplicant -B -P /run/wpa_supplicant_wlan0.pid -i wlan0... └─1066 dhcpcd -qL -t 10 wlan0`
Add entry into systemd:
netctl enable wireless-wpa
- Unplug the cable and testing the wireless connection!!!


Patch Panel Manager is a GUI for configuring mappings in the Patch Panel. It provides are three methods of configuring mappings:
Patch Panel Manager can read in a script file and configures the Patch Panel accordingly. A PP Manager script file describes sets of events, states, global variables, and transitions. As an example is displayed below with annotations.
java -cp iROS.jar iwork.patchpanel.manager.PPManager -s doubleclick.txt
iw-room2.stanford.edu 4535
// Patch Panel group must have a unique name so that its states can be // delineated from states of other PP scripts. group DoubleClickScript; // GLOBAL VARIABLE DECLARATIONS: // ----------------------------- // These are the only declarations that must actually be at the top of the file. // It's not reflected below, but the event declarations and the state // declarations below can be freely intermingled. // // (I'm working on relaxing this further so that the variables can be intermingled too, // but this is a tricky issue, so for now global variables won't always work unless they're // at the top.) // // Init values must be specified and must be constants (they can't be set based on // input events or other global variable values. int numDoubleClicks = 1; int numSingleClicks = 0; // EVENT DECLARATIONS: // ------------------- // These are specifications for events that will be used later in the program. // Each event has both a unique name (only used within this script) as well as // an actual EventType event MyDoubleClickEvent type DoubleClickEvent { // Event fields: // ------------- // Each field in an event has a type, a name (optionally in quotes), "=", and then a post value, // (and then optionally a comma then a template value) then a semicolon. // Valid values are int, short, float, long, double, boolean, string constant (in quotes), // or FORMAL or VIRTUAL (not in quotes). Equation strings can be used and they // will work as expected (but the field type must be 'string'). // // Now, equations can be entered directly into the field and they'll work pretty much // as you would expect if you were using Java or C. Prefixing names of global variables // with "global." is optional, as seen below. Values of "in." and "out." variables can be // use this way too, but they must be prefixed. int DoubleClicked = 1; string "DeviceName" = "=(string) in.DeviceName"; int numDoubleClicks = global.numDoubleClicks; string doublePlusSingle = "=(int) global.numDoubleClicks", FORMAL; int "doubleTimesSingle" = numDoubleClicks * numSingleClicks; } event MyClickEvent type ClickEvent { int "ButtonState" = 1, 1; string DeviceName = "helloWorld", "helloWorld"; } event MyInitialEnteredEvent type InitialStateEnteredEvent { // Empty events are allowed, they will only have default fields. } event EvenClicks type EvenClicksEvent { int "NumClicksOverTwo" = numSingleClicks / 2; } even OddClicks type OddClicksEvent { } event Mult3 type Mult3ClicksEvent { string message = "the number of clicks is a multiple of 3"; } event Rem2 type Rem2Event { string message = "the number of clicks over 3 has remainder 2"; } event Rem1 type Rem1Event { string message = "the number of clicks over 3 has remainder 1"; } // STATE DECLARATIONS // ------------------ // There must be a state called "Initial" which will be the starting state state Initial { // on entering this state, the "on enter" trigger will be executed : on enter { send MyInitialEnteredEvent; } // when a MyClickEvent (as defined above) is received in state Initial, // this trigger will be executed: on MyClickEvent { set timer 500; send MyDoubleClickEvent; goto OneClickDone; numSingleClicks = numSingleClicks + 1; // Switch statements are a little different from C and Java: // Each case must be a constant and the type of the test equation // must come after "switch". Also, // The flow of control will never cover multiple case blocks // (there is no equivalent of "break" in patchscript since it is // a declarative rather than imperative language). switch int (numSingleClicks % 3) { case 0 { send Mult3; } case 1 { send Rem1; } case 2 { send Rem2; } } } } state OneClickDone { on MyClickEvent { goto Initial; numSingleClicks = numSingleClicks + 1; if (numSingleClicks % 2 == 0) { send EvenClicks; } else { send OddClicks; } // if, else, and else if all work as you'd expect. // Nested if statements are also allowed, and you can nest if statements // in switch statements and vice versa. // The "{" and "}" surround an if-block are mandatory, unlike in C and Java } on timer { goto Initial; } }
11 February 2004, Andy Szybalski, andys@cs.stanford.edu


Are you sure you want to revoke access from the user named "{{user}}" ?
This user will no longer have access to the bucket and its content.


FINAL DESTINATION A film review by Steve Rhodes Copyright 2000 Steve Rhodes RATING (0 TO ****): * 1/2
"Live it up, Alex, you've got your whole life ahead of you," his father prophetically advises. Since James Wong's FINAL DESTINATION is a teen horror movie, one immediately sees the humorous irony in this advice, which occurs in the first few minutes of the story.
Alex Browning (Devon Sawa) and the rest of his French class are off to France for the summer. Using the horror genre's favorite weather, noisy lightning, the movie sets the stage for what will be a disastrous plane flight.
Filled with premonitions of catastrophe, Alex gets on board the aircraft, only to see every mechanical part as a possible source of failure. After a daydream during passenger loading, he yells, "This plane will explode on takeoff!"
Needless to say, this isn't something you want to go screaming on a jumbo jet. The crew does not take kindly to such outbursts and neither do his fellow students. The upshot of all of this is that the plane leaves without Alex and 6 other would-be travelers to the land of Brie and croissants.
Of course, the plane crashes in a massive fireball. If you've ever been afraid to fly, this isn't the movie for you. Actually, if you are currently okay with flying several miles up in the air in a long metal tube, you still may want to avoid the film since its images may not go away. The rest of the story is a traditional teen horror flick with severed heads and flying knives, but the plane crash is something else entirely. The director makes it seem entirely plausible and shockingly realistic.
One problem that some viewers may have is that the details of the tragedy sound remarkably similar to real-life plane crashes. But, the problem that most viewers will have with FINAL DESTINATION is that they have seen it all before. If you feel in the need for a generic teen horror film, there is no reason to choose this one over any of the others.
The body of the story has Alex trying to cheat death by outsmarting him. Death, you see, doesn't like having had 7 of his intended victims escape, so he's back on the prowl to collect them.
The movie is at its best when it goes more for humor than shock. "I will not let this plane crash be the most important thing in my life!" the blonde bimbo survivor tells the others. She doesn't need to worry. It won't be.
FINAL DESTINATION runs 1:33. It is rated R for violence, terror and language and would be acceptable for older teenagers.
Email<EMAIL_ADDRESS>Web: http://www.InternetReviews.com
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


| tidy.summary_emm {broom} | R Documentation |
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'summary_emm' tidy(x, null.value = NULL, ...)
x |
A |
null.value |
Value to which estimate is compared. |
... |
Additional arguments passed to |
Returns a data frame with one observation for each estimated marginal mean, and one column for each combination of factors. When the input is a contrast, each row will contain one estimated contrast.
There are a large number of arguments that can be
passed on to emmeans::summary.emmGrid()
or lsmeans::summary.ref.grid()
.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
contrast |
Levels being compared. |
den.df |
Degrees of freedom of the denominator. |
df |
Degrees of freedom used by this term in the model. |
null.value |
Value to which the estimate is compared. |
num.df |
Degrees of freedom. |
p.value |
The two-sided p-value associated with the observed statistic. |
std.error |
The standard error of the regression term. |
level1 |
One level of the factor being contrasted |
level2 |
The other level of the factor being contrasted |
term |
Model term in joint tests |
estimate |
Expected marginal mean |
statistic |
T-ratio statistic or F-ratio statistic |
tidy()
, emmeans::ref_grid()
, emmeans::emmeans()
,
emmeans::contrast()
Other emmeans tidiers:
tidy.emmGrid()
,
tidy.lsmobj()
,
tidy.ref.grid()
library(emmeans) # linear model for sales of oranges per day oranges_lm1 <- lm(sales1 ~ price1 + price2 + day + store, data = oranges) # reference grid; see vignette("basics", package = "emmeans") oranges_rg1 <- ref_grid(oranges_lm1) td <- tidy(oranges_rg1) td # marginal averages marginal <- emmeans(oranges_rg1, "day") tidy(marginal) # contrasts tidy(contrast(marginal)) tidy(contrast(marginal, method = "pairwise")) # plot confidence intervals library(ggplot2) ggplot(tidy(marginal, conf.int = TRUE), aes(day, estimate)) + geom_point() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # by multiple prices by_price <- emmeans(oranges_lm1, "day", by = "price2", at = list( price1 = 50, price2 = c(40, 60, 80), day = c("2", "3", "4") ) ) by_price tidy(by_price) ggplot(tidy(by_price, conf.int = TRUE), aes(price2, estimate, color = day)) + geom_line() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # joint_tests tidy(joint_tests(oranges_lm1))


Pedantic
Configuration
The 'Pedantic' filter is enabled by specifying:
- Apache:
ModPagespeedEnableFilters pedantic
- Nginx:
pagespeed EnableFilters pedantic;
in the configuration file.
Description
The 'Pedantic' filter is used to make PageSpeed more HTML4 compliant. Some filters remove type attributes in style and script tags, which are required for HTML4 validation checks but not HTML5. This filter adds default types to script and style tags. Note that it will increase HTML size and thus possibly increase latency so use it only if you require HTML4 validation.
Operation
There are two cases where a type
attribute can be added. First, if
a <style>
tag does not have a type
attribute
then a type="text/css"
attribute will be added to
the style
tag. Second, if a <script>
tag does
not have a type
attribute then
a type="text/javascript"
attribute will be added to
the script
tag.
The expected method of using the pedantic filter is via a query parameter
such as: '?ModPagespeedFilters=+pedantic
'.
You can see the filter in action at www.modpagespeed.com
on
this example.
Requirements
The 'Pedantic' filter will not alter a page with an HTML5 DOCTYPE.
Risks
This filter is considered medium risk. It is safe for most pages, but could
possibly break scripts by adding text/javascript
to a tag if the
default mime type is something other than text/javascript
.


Hide Children with CSS
Task
Account
Complete?
Approved?
Logs
You should see me
STS-Master
You should not see me
STS-LP


Add Host
Host List
Id
Name
MAC
IPv4
IPv6
VLAN
DHCP
Show
Edit
Delete
Id
Name
MAC
IPv4
IPv6
100
no
Show
Edit
Delete


{{ setModalTitle() }}
Delete {{data.name}} from the blocklist? This will allow this {{data.action == 'removeCurrency' ? 'currency' : 'country'}} to be available for transactions by all participants on the World Wire network.


Good Geyser Not Included
How is it work? ISSUE
Welcome To Cosmic Upgrade !!!!!
Author zsnmwy
or click here to upload your geyser screenshot.
Recognition is complete. the recognition result may be wrong. Please check it and click "Cal" Re-upload
Please fill the geyser information. And click "Cal".
Hosted by Coding Pages


An email has been sent to your specified address. Please follow the instructions in the email to finish creating your account.


Cooking Tree
The Cooking Tree YouTube Channel focuses on diverse and interesting cooking. The content creator shows artistry and creativity with food in her videos. Cooking Tree's videos are unique because it is purely visual with text in English and Korean. No verbal instruction are in videos. She uses audio from her baking adventures to enhances viewer's experience. The Cooking Tree channel will leave you feeling inspired to create an exceptional dessert!
Favorite video: Green tea (Matcha) Double Cheesecake Recipe
Eugene Kitchen
Eugene Kitchen YouTube Channel focuses on aesthetically pleasing baking videos. She gives verbal directions on how to create trendy and eye-catching baked goods, desserts, and beverages. Eugene's videos are unique because incorporates the latest food trends and social media logos in her creations. Her quick videos demosrtates on how to bake and cook at home with easy instructions. Eugene Kitchen channel is eye candy for anyone who wants to view extraordinary desserts!
Favorite video: Chocolate Financiers - French Petit-Four Cake
Simply Quinoa
Simply Quinoa YouTube Channel focuses on plant-based recipies that are healthy and delicious. Content creator, Alyssa, also promotes a healthy living, sustainable, and self-care lifestyle. Most of the recipe videos are inspired with fresh produce and all are 100% gluten free. She gives simple how-to recipes to create pantry staples, fast breakfasts, holiday dishes. Plus tips on organizing, cleaning, and traveling.
Favorite video: Healthy Vegan Soups
Apron
Apron YouTube Channel focus on ASMR cooking videos, with an emphasis on breads and Asian-style pastries. The videos are purely visual with no verbal instructions. Viewers are tantalized by the sounds of food being mixed, whipped, and kneaded. The recipe videos are for the more advanced and professional baker with written instructions in the description. The Apron channel will fill your kitchen and ears with the pleasing sounds of someone baking a delectable dessert!


0; else emptyMessage">
Add terms that define your study eg. technique, disease,
targeted / untargeted metabolities
No design descriptors defined.


keyboard_arrow_right
keyboard_arrow_left
{{film.rating}}
{{film.title}}
{{film.genre}}
Book {{film.title}}
Buy {{film.title}}
{{film.title}}
{{film.information}}
query_builder
{{film.length}}