path
stringlengths
13
14
screenshot_names
sequencelengths
1
2
code
stringlengths
5
3.34k
cell_type
stringclasses
1 value
312349/cell_4
[ "text_plain_output_1.png", "image_output_1.png" ]
import matplotlib.pyplot as plt import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) df = pd.read_csv('../input/cdc_zika.csv', parse_dates=['report_date'], infer_datetime_format=True, index_col=0) df.location.value_counts()[:30].plot(kind='bar', figsize=(12, 7)) plt.title('Number of locations reported - Top 30')
code
312349/cell_6
[ "text_plain_output_1.png" ]
import matplotlib.pyplot as plt import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) df = pd.read_csv('../input/cdc_zika.csv', parse_dates=['report_date'], infer_datetime_format=True, index_col=0) age_groups = ('confirmed_age_under_1', 'confirmed_age_1-4', 'confirmed_age_5-9', 'confirmed_age_10-14', 'confirmed_age_15-19', 'confirmed_age_20-24', 'confirmed_age_25-34', 'confirmed_age_35-49', 'confirmed_age_50-59', 'confirmed_age_60-64', 'confirmed_age_60_plus') for i, age_group in enumerate(age_groups): print(age_group) print(df[df.data_field == age_group].value) print('')
code
312349/cell_2
[ "text_plain_output_1.png" ]
from subprocess import check_output import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sbn from subprocess import check_output print(check_output(['ls', '../input']).decode('utf8'))
code
312349/cell_8
[ "text_plain_output_1.png", "image_output_1.png" ]
import matplotlib.pyplot as plt import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) df = pd.read_csv('../input/cdc_zika.csv', parse_dates=['report_date'], infer_datetime_format=True, index_col=0) age_groups = ('confirmed_age_under_1', 'confirmed_age_1-4', 'confirmed_age_5-9', 'confirmed_age_10-14', 'confirmed_age_15-19', 'confirmed_age_20-24', 'confirmed_age_25-34', 'confirmed_age_35-49', 'confirmed_age_50-59', 'confirmed_age_60-64', 'confirmed_age_60_plus') symptoms = ['confirmed_fever', 'confirmed_acute_fever', 'confirmed_arthralgia', 'confirmed_arthritis', 'confirmed_rash', 'confirmed_conjunctivitis', 'confirmed_eyepain', 'confirmed_headache', 'confirmed_malaise'] fig = plt.figure(figsize=(13, 13)) for symptom in symptoms: df[df.data_field == symptom].value.plot() plt.legend(symptoms, loc='best') plt.title('Understanding symptoms of zika virus')
code
312349/cell_3
[ "text_html_output_1.png", "application_vnd.jupyter.stderr_output_1.png" ]
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) df = pd.read_csv('../input/cdc_zika.csv', parse_dates=['report_date'], infer_datetime_format=True, index_col=0) df.head(3)
code
312349/cell_5
[ "text_plain_output_1.png", "image_output_1.png" ]
import matplotlib.pyplot as plt import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) df = pd.read_csv('../input/cdc_zika.csv', parse_dates=['report_date'], infer_datetime_format=True, index_col=0) df[df.data_field == 'confirmed_male'].value.plot() df[df.data_field == 'confirmed_female'].value.plot().legend(('Male', 'Female'), loc='best') plt.title('Confirmed Male vs Female cases')
code
316827/cell_13
[ "text_html_output_1.png" ]
import pandas as pd posts = pd.read_csv('../input/post.csv', parse_dates=['timeStamp']) comments = pd.read_csv('../input/comment.csv') com_count = comments.groupby('pid').count()['cid'] data = posts.join(com_count, on='pid', rsuffix='c')[['msg', 'likes', 'shares', 'cid', 'gid']] data.columns = ['msg', 'likes', 'shares', 'comments', 'gid'] data['msg_len'] = data.msg.apply(len) data.gid = data.gid.map({117291968282998: 1, 25160801076: 2, 1443890352589739: 3}) data.fillna(0, inplace=True) data.head()
code
316827/cell_30
[ "text_plain_output_1.png" ]
from scipy.stats import mannwhitneyu from statsmodels.sandbox.stats.multicomp import multipletests from statsmodels.stats.weightstats import zconfint import pandas as pd posts = pd.read_csv('../input/post.csv', parse_dates=['timeStamp']) comments = pd.read_csv('../input/comment.csv') com_count = comments.groupby('pid').count()['cid'] data = posts.join(com_count, on='pid', rsuffix='c')[['msg', 'likes', 'shares', 'cid', 'gid']] data.columns = ['msg', 'likes', 'shares', 'comments', 'gid'] data['msg_len'] = data.msg.apply(len) data.gid = data.gid.map({117291968282998: 1, 25160801076: 2, 1443890352589739: 3}) data.fillna(0, inplace=True) park = data[data.gid == 1] town = data[data.gid == 2] free = data[data.gid == 3] def conf_interval(field): """" Calculate confidence interval for given field """ def compare_means(field): """ Mann–Whitney test to compare mean values level """ mapping = {1: 'EPH', 2: 'UCT', 3: 'FSZ'} comparison = pd.DataFrame(columns=['group1', 'group2', 'p_value']) for i in range(1, 4): for j in range(1, 4): if i >= j: continue p = mannwhitneyu(data[data.gid == i][field], data[data.gid == j][field])[1] comparison = comparison.append({'group1': mapping[i], 'group2': mapping[j], 'p_value': p}, ignore_index=True) rejected, p_corrected, a1, a2 = multipletests(comparison.p_value, alpha=0.05, method='holm') comparison['p_value_corrected'] = p_corrected comparison['rejected'] = rejected return comparison conf_interval('comments') print(compare_means('comments'))
code
316827/cell_33
[ "text_plain_output_1.png" ]
from scipy.stats import mannwhitneyu from statsmodels.sandbox.stats.multicomp import multipletests from statsmodels.stats.weightstats import zconfint import pandas as pd posts = pd.read_csv('../input/post.csv', parse_dates=['timeStamp']) comments = pd.read_csv('../input/comment.csv') com_count = comments.groupby('pid').count()['cid'] data = posts.join(com_count, on='pid', rsuffix='c')[['msg', 'likes', 'shares', 'cid', 'gid']] data.columns = ['msg', 'likes', 'shares', 'comments', 'gid'] data['msg_len'] = data.msg.apply(len) data.gid = data.gid.map({117291968282998: 1, 25160801076: 2, 1443890352589739: 3}) data.fillna(0, inplace=True) park = data[data.gid == 1] town = data[data.gid == 2] free = data[data.gid == 3] def conf_interval(field): """" Calculate confidence interval for given field """ def compare_means(field): """ Mann–Whitney test to compare mean values level """ mapping = {1: 'EPH', 2: 'UCT', 3: 'FSZ'} comparison = pd.DataFrame(columns=['group1', 'group2', 'p_value']) for i in range(1, 4): for j in range(1, 4): if i >= j: continue p = mannwhitneyu(data[data.gid == i][field], data[data.gid == j][field])[1] comparison = comparison.append({'group1': mapping[i], 'group2': mapping[j], 'p_value': p}, ignore_index=True) rejected, p_corrected, a1, a2 = multipletests(comparison.p_value, alpha=0.05, method='holm') comparison['p_value_corrected'] = p_corrected comparison['rejected'] = rejected return comparison conf_interval('msg_len') print(compare_means('msg_len'))
code
316827/cell_20
[ "text_plain_output_1.png" ]
from statsmodels.stats.weightstats import zconfint import pandas as pd posts = pd.read_csv('../input/post.csv', parse_dates=['timeStamp']) comments = pd.read_csv('../input/comment.csv') com_count = comments.groupby('pid').count()['cid'] data = posts.join(com_count, on='pid', rsuffix='c')[['msg', 'likes', 'shares', 'cid', 'gid']] data.columns = ['msg', 'likes', 'shares', 'comments', 'gid'] data['msg_len'] = data.msg.apply(len) data.gid = data.gid.map({117291968282998: 1, 25160801076: 2, 1443890352589739: 3}) data.fillna(0, inplace=True) park = data[data.gid == 1] town = data[data.gid == 2] free = data[data.gid == 3] def conf_interval(field): """" Calculate confidence interval for given field """ conf_interval('likes')
code
316827/cell_16
[ "text_plain_output_1.png", "image_output_1.png" ]
import pandas as pd import seaborn as sns posts = pd.read_csv('../input/post.csv', parse_dates=['timeStamp']) comments = pd.read_csv('../input/comment.csv') com_count = comments.groupby('pid').count()['cid'] data = posts.join(com_count, on='pid', rsuffix='c')[['msg', 'likes', 'shares', 'cid', 'gid']] data.columns = ['msg', 'likes', 'shares', 'comments', 'gid'] data['msg_len'] = data.msg.apply(len) data.gid = data.gid.map({117291968282998: 1, 25160801076: 2, 1443890352589739: 3}) data.fillna(0, inplace=True) sns.pairplot(data, hue='gid')
code
316827/cell_24
[ "text_plain_output_1.png" ]
from scipy.stats import mannwhitneyu from statsmodels.sandbox.stats.multicomp import multipletests from statsmodels.stats.weightstats import zconfint import pandas as pd posts = pd.read_csv('../input/post.csv', parse_dates=['timeStamp']) comments = pd.read_csv('../input/comment.csv') com_count = comments.groupby('pid').count()['cid'] data = posts.join(com_count, on='pid', rsuffix='c')[['msg', 'likes', 'shares', 'cid', 'gid']] data.columns = ['msg', 'likes', 'shares', 'comments', 'gid'] data['msg_len'] = data.msg.apply(len) data.gid = data.gid.map({117291968282998: 1, 25160801076: 2, 1443890352589739: 3}) data.fillna(0, inplace=True) park = data[data.gid == 1] town = data[data.gid == 2] free = data[data.gid == 3] def conf_interval(field): """" Calculate confidence interval for given field """ def compare_means(field): """ Mann–Whitney test to compare mean values level """ mapping = {1: 'EPH', 2: 'UCT', 3: 'FSZ'} comparison = pd.DataFrame(columns=['group1', 'group2', 'p_value']) for i in range(1, 4): for j in range(1, 4): if i >= j: continue p = mannwhitneyu(data[data.gid == i][field], data[data.gid == j][field])[1] comparison = comparison.append({'group1': mapping[i], 'group2': mapping[j], 'p_value': p}, ignore_index=True) rejected, p_corrected, a1, a2 = multipletests(comparison.p_value, alpha=0.05, method='holm') comparison['p_value_corrected'] = p_corrected comparison['rejected'] = rejected return comparison conf_interval('likes') print(compare_means('likes'))
code
316827/cell_27
[ "text_plain_output_1.png" ]
from scipy.stats import mannwhitneyu from statsmodels.sandbox.stats.multicomp import multipletests from statsmodels.stats.weightstats import zconfint import pandas as pd posts = pd.read_csv('../input/post.csv', parse_dates=['timeStamp']) comments = pd.read_csv('../input/comment.csv') com_count = comments.groupby('pid').count()['cid'] data = posts.join(com_count, on='pid', rsuffix='c')[['msg', 'likes', 'shares', 'cid', 'gid']] data.columns = ['msg', 'likes', 'shares', 'comments', 'gid'] data['msg_len'] = data.msg.apply(len) data.gid = data.gid.map({117291968282998: 1, 25160801076: 2, 1443890352589739: 3}) data.fillna(0, inplace=True) park = data[data.gid == 1] town = data[data.gid == 2] free = data[data.gid == 3] def conf_interval(field): """" Calculate confidence interval for given field """ def compare_means(field): """ Mann–Whitney test to compare mean values level """ mapping = {1: 'EPH', 2: 'UCT', 3: 'FSZ'} comparison = pd.DataFrame(columns=['group1', 'group2', 'p_value']) for i in range(1, 4): for j in range(1, 4): if i >= j: continue p = mannwhitneyu(data[data.gid == i][field], data[data.gid == j][field])[1] comparison = comparison.append({'group1': mapping[i], 'group2': mapping[j], 'p_value': p}, ignore_index=True) rejected, p_corrected, a1, a2 = multipletests(comparison.p_value, alpha=0.05, method='holm') comparison['p_value_corrected'] = p_corrected comparison['rejected'] = rejected return comparison conf_interval('shares') print(compare_means('shares'))
code
316827/cell_37
[ "application_vnd.jupyter.stderr_output_2.png", "text_plain_output_1.png" ]
from scipy.stats import mannwhitneyu from statsmodels.sandbox.stats.multicomp import multipletests from statsmodels.stats.weightstats import zconfint import pandas as pd posts = pd.read_csv('../input/post.csv', parse_dates=['timeStamp']) comments = pd.read_csv('../input/comment.csv') com_count = comments.groupby('pid').count()['cid'] data = posts.join(com_count, on='pid', rsuffix='c')[['msg', 'likes', 'shares', 'cid', 'gid']] data.columns = ['msg', 'likes', 'shares', 'comments', 'gid'] data['msg_len'] = data.msg.apply(len) data.gid = data.gid.map({117291968282998: 1, 25160801076: 2, 1443890352589739: 3}) data.fillna(0, inplace=True) park = data[data.gid == 1] town = data[data.gid == 2] free = data[data.gid == 3] def conf_interval(field): """" Calculate confidence interval for given field """ def compare_means(field): """ Mann–Whitney test to compare mean values level """ mapping = {1: 'EPH', 2: 'UCT', 3: 'FSZ'} comparison = pd.DataFrame(columns=['group1', 'group2', 'p_value']) for i in range(1, 4): for j in range(1, 4): if i >= j: continue p = mannwhitneyu(data[data.gid == i][field], data[data.gid == j][field])[1] comparison = comparison.append({'group1': mapping[i], 'group2': mapping[j], 'p_value': p}, ignore_index=True) rejected, p_corrected, a1, a2 = multipletests(comparison.p_value, alpha=0.05, method='holm') comparison['p_value_corrected'] = p_corrected comparison['rejected'] = rejected return comparison shared = data[data.shares > data.shares.quantile(0.98)][data.shares > data.likes * 10][['msg', 'shares']] top = 10 print('top %d out of %d' % (top, shared.shape[0])) sorted_data = shared.sort_values(by='shares', ascending=False)[:top] for i in sorted_data.index.values: print('shares:', sorted_data.shares[i], '\n', 'message:', sorted_data.msg[i][:200], '\n')
code
309674/cell_3
[ "text_plain_output_1.png" ]
import matplotlib.pyplot as plt import networkx as nx import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) import numpy as np import pandas as pd import networkx as nx import matplotlib.pyplot as plt from subprocess import check_output comments = pd.read_csv('../input/comment.csv') likes = pd.read_csv('../input/like.csv') members = pd.read_csv('../input/member.csv') posts = pd.read_csv('../input/post.csv') likeResponse = pd.merge(likes.loc[likes['gid'] == 117291968282998], posts.loc[posts['gid'] == 117291968282998, ['pid', 'name']], left_on='pid', right_on='pid') result = likeResponse.groupby(['name_y', 'name_x'])['response'].count() finalResult = pd.DataFrame(result.index.values, columns=['NameCombo']) finalResult['Weight'] = result.values finalResult['From'] = finalResult['NameCombo'].map(lambda x: x[0]) finalResult['To'] = finalResult['NameCombo'].map(lambda x: x[1]) del finalResult['NameCombo'] g = nx.Graph() plt.figure() g.add_edges_from([(row['From'], row['To']) for index, row in finalResult.iterrows()]) d = nx.degree(g) spring_pos = nx.spring_layout(g) plt.axis('off') nx.draw_networkx(g, spring_pos, with_labels=False, nodelist=d.keys(), node_size=[v * 10 for v in d.values()]) plt.savefig('LIKE_PLOT_GROUP1.png') plt.clf()
code
311500/cell_4
[ "text_plain_output_1.png", "image_output_1.png" ]
import matplotlib.pyplot as plt import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) df = pd.read_csv('../input/cdc_zika.csv', parse_dates=['report_date'], infer_datetime_format=True, index_col=0) df[df.data_field == 'confirmed_male'].value.plot() df[df.data_field == 'confirmed_female'].value.plot().legend(('Male', 'Female'), loc='best') plt.title('Confirmed Male vs Female cases')
code
311500/cell_6
[ "text_plain_output_1.png" ]
import matplotlib.pyplot as plt import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) df = pd.read_csv('../input/cdc_zika.csv', parse_dates=['report_date'], infer_datetime_format=True, index_col=0) df.data_field.unique()
code
311500/cell_2
[ "text_html_output_1.png", "application_vnd.jupyter.stderr_output_1.png" ]
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) df = pd.read_csv('../input/cdc_zika.csv', parse_dates=['report_date'], infer_datetime_format=True, index_col=0) df.head(3)
code
311500/cell_1
[ "text_plain_output_1.png" ]
from subprocess import check_output import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sbn from subprocess import check_output print(check_output(['ls', '../input']).decode('utf8'))
code
311500/cell_7
[ "text_plain_output_1.png" ]
import matplotlib.pyplot as plt import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) df = pd.read_csv('../input/cdc_zika.csv', parse_dates=['report_date'], infer_datetime_format=True, index_col=0) df.data_field.unique() age_groups = ('confirmed_age_under_1', 'confirmed_age_1-4', 'confirmed_age_5-9', 'confirmed_age_10-14', 'confirmed_age_15-19', 'confirmed_age_20-24', 'confirmed_age_25-34', 'confirmed_age_35-49', 'confirmed_age_50-59', 'confirmed_age_60-64', 'confirmed_age_60_plus') for i, age_group in enumerate(age_groups): print(age_group) print(df[df.data_field == age_group].value) print('')
code
311500/cell_3
[ "text_plain_output_1.png", "image_output_1.png" ]
import matplotlib.pyplot as plt import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) df = pd.read_csv('../input/cdc_zika.csv', parse_dates=['report_date'], infer_datetime_format=True, index_col=0) df.location.value_counts()[:30].plot(kind='bar', figsize=(12, 7)) plt.title('Number of locations reported - Top 30')
code
306027/cell_4
[ "text_html_output_1.png" ]
import pandas as pd import sqlite3 import pandas as pd import sqlite3 con = sqlite3.connect('../input/database.sqlite') scripts = pd.read_sql_query('\n\nSELECT s.Id,\n\n cv.Title,\n\n COUNT(DISTINCT vo.Id) NumVotes,\n\n COUNT(DISTINCT CASE WHEN vo.UserId!=s.AuthorUserId THEN vo.Id ELSE NULL END) NumNonSelfVotes,\n\n CASE WHEN COUNT(DISTINCT CASE WHEN vo.UserId!=s.AuthorUserId THEN vo.Id ELSE NULL END)>0 THEN 1 ELSE 0 END HasNonSelfVotes,\n\n COUNT(DISTINCT v.Id) NumVersions,\n\n SUM(CASE WHEN r.WorkerStatus=2 THEN 1 ELSE 0 END) NumSuccessfulRuns,\n\n SUM(CASE WHEN r.WorkerStatus=3 THEN 1 ELSE 0 END) NumErroredRuns,\n\n SUM(CASE WHEN v.IsChange=1 THEN 1 ELSE 0 END) NumChangedVersions,\n\n SUM(v.LinesInsertedFromPrevious-v.LinesDeletedFromPrevious) Lines,\n\n SUM(v.LinesInsertedFromPrevious+v.LinesChangedFromPrevious) LinesAddedOrChanged,\n\n l.Name\n\nFROM Scripts s\n\nINNER JOIN ScriptVersions v ON v.ScriptId=s.Id\n\nINNER JOIN ScriptVersions cv ON s.CurrentScriptVersionId=cv.Id\n\nINNER JOIN ScriptRuns r ON r.ScriptVersionId=v.Id\n\nINNER JOIN ScriptLanguages l ON v.ScriptLanguageId=l.Id\n\nLEFT OUTER JOIN ScriptVotes vo ON vo.ScriptVersionId=v.Id\n\nWHERE r.WorkerStatus != 4\n\n AND r.WorkerStatus != 5\n\nGROUP BY s.Id,\n\n cv.Title,\n\n cv.Id,\n\n l.Name\n\nORDER BY cv.Id DESC\n\n', con) scripts pd.read_sql_query('\nSELECT *\nFROM ScriptLanguages\nLIMIT 100\n', con)
code
306027/cell_2
[ "text_html_output_1.png" ]
import pandas as pd import sqlite3 import pandas as pd import sqlite3 con = sqlite3.connect('../input/database.sqlite') scripts = pd.read_sql_query('\nSELECT s.Id,\n cv.Title,\n COUNT(DISTINCT vo.Id) NumVotes,\n COUNT(DISTINCT CASE WHEN vo.UserId!=s.AuthorUserId THEN vo.Id ELSE NULL END) NumNonSelfVotes,\n CASE WHEN COUNT(DISTINCT CASE WHEN vo.UserId!=s.AuthorUserId THEN vo.Id ELSE NULL END)>0 THEN 1 ELSE 0 END HasNonSelfVotes,\n COUNT(DISTINCT v.Id) NumVersions,\n SUM(CASE WHEN r.WorkerStatus=2 THEN 1 ELSE 0 END) NumSuccessfulRuns,\n SUM(CASE WHEN r.WorkerStatus=3 THEN 1 ELSE 0 END) NumErroredRuns,\n SUM(CASE WHEN v.IsChange=1 THEN 1 ELSE 0 END) NumChangedVersions,\n SUM(v.LinesInsertedFromPrevious-v.LinesDeletedFromPrevious) Lines,\n SUM(v.LinesInsertedFromPrevious+v.LinesChangedFromPrevious) LinesAddedOrChanged,\n l.Name\nFROM Scripts s\nINNER JOIN ScriptVersions v ON v.ScriptId=s.Id\nINNER JOIN ScriptVersions cv ON s.CurrentScriptVersionId=cv.Id\nINNER JOIN ScriptRuns r ON r.ScriptVersionId=v.Id\nINNER JOIN ScriptLanguages l ON v.ScriptLanguageId=l.Id\nLEFT OUTER JOIN ScriptVotes vo ON vo.ScriptVersionId=v.Id\nWHERE r.WorkerStatus != 4\n AND r.WorkerStatus != 5\nGROUP BY s.Id,\n cv.Title,\n cv.Id,\n l.Name\nORDER BY cv.Id DESC\n', con) scripts
code
306027/cell_3
[ "application_vnd.jupyter.stderr_output_2.png", "text_plain_output_1.png" ]
from sklearn.cross_validation import train_test_split from sklearn.ensemble import RandomForestClassifier from sklearn.pipeline import Pipeline, FeatureUnion import pandas as pd import sqlite3 import pandas as pd import sqlite3 con = sqlite3.connect('../input/database.sqlite') scripts = pd.read_sql_query('\n\nSELECT s.Id,\n\n cv.Title,\n\n COUNT(DISTINCT vo.Id) NumVotes,\n\n COUNT(DISTINCT CASE WHEN vo.UserId!=s.AuthorUserId THEN vo.Id ELSE NULL END) NumNonSelfVotes,\n\n CASE WHEN COUNT(DISTINCT CASE WHEN vo.UserId!=s.AuthorUserId THEN vo.Id ELSE NULL END)>0 THEN 1 ELSE 0 END HasNonSelfVotes,\n\n COUNT(DISTINCT v.Id) NumVersions,\n\n SUM(CASE WHEN r.WorkerStatus=2 THEN 1 ELSE 0 END) NumSuccessfulRuns,\n\n SUM(CASE WHEN r.WorkerStatus=3 THEN 1 ELSE 0 END) NumErroredRuns,\n\n SUM(CASE WHEN v.IsChange=1 THEN 1 ELSE 0 END) NumChangedVersions,\n\n SUM(v.LinesInsertedFromPrevious-v.LinesDeletedFromPrevious) Lines,\n\n SUM(v.LinesInsertedFromPrevious+v.LinesChangedFromPrevious) LinesAddedOrChanged,\n\n l.Name\n\nFROM Scripts s\n\nINNER JOIN ScriptVersions v ON v.ScriptId=s.Id\n\nINNER JOIN ScriptVersions cv ON s.CurrentScriptVersionId=cv.Id\n\nINNER JOIN ScriptRuns r ON r.ScriptVersionId=v.Id\n\nINNER JOIN ScriptLanguages l ON v.ScriptLanguageId=l.Id\n\nLEFT OUTER JOIN ScriptVotes vo ON vo.ScriptVersionId=v.Id\n\nWHERE r.WorkerStatus != 4\n\n AND r.WorkerStatus != 5\n\nGROUP BY s.Id,\n\n cv.Title,\n\n cv.Id,\n\n l.Name\n\nORDER BY cv.Id DESC\n\n', con) scripts from sklearn.pipeline import Pipeline, FeatureUnion from sklearn.cross_validation import train_test_split from sklearn.ensemble import RandomForestClassifier class RawColumnExtractor: def __init__(self, column): self.column = column def fit(self, *_): return self def transform(self, data): return data[[self.column]] features = FeatureUnion([('NumSuccessfulRuns', RawColumnExtractor('NumSuccessfulRuns')), ('NumChangedVersions', RawColumnExtractor('NumChangedVersions'))]) pipeline = Pipeline([('feature_union', features), ('predictor', RandomForestClassifier())]) train = scripts target_name = 'HasNonSelfVotes' x_train, x_test, y_train, y_test = train_test_split(train, train[target_name], test_size=0.4, random_state=0) pipeline.fit(x_train, y_train) score = pipeline.score(x_test, y_test) print('Score %f' % score)
code
311174/cell_4
[ "text_plain_output_1.png", "image_output_1.png" ]
import matplotlib.pyplot as plt import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) df = pd.read_csv('../input/cdc_zika.csv', parse_dates=['report_date'], infer_datetime_format=True, index_col=0) df.location.value_counts()[:30].plot(kind='bar', figsize=(12, 7)) plt.title('Number of locations reported - Top 30')
code
311174/cell_2
[ "text_plain_output_1.png" ]
from subprocess import check_output import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sbn from subprocess import check_output print(check_output(['ls', '../input']).decode('utf8'))
code
311174/cell_3
[ "text_html_output_1.png", "application_vnd.jupyter.stderr_output_1.png" ]
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) df = pd.read_csv('../input/cdc_zika.csv', parse_dates=['report_date'], infer_datetime_format=True, index_col=0) df.head(3)
code
311174/cell_5
[ "text_plain_output_1.png", "image_output_1.png" ]
import matplotlib.pyplot as plt import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) df = pd.read_csv('../input/cdc_zika.csv', parse_dates=['report_date'], infer_datetime_format=True, index_col=0) df[df.data_field == 'confirmed_male'].value.plot() df[df.data_field == 'confirmed_female'].value.plot().legend(('Male', 'Female'), loc='best') plt.title('Confirmed Male vs Female cases')
code
311188/cell_4
[ "text_plain_output_1.png" ]
50 + 100
code
311188/cell_6
[ "text_plain_output_1.png" ]
100 + 200
code
311188/cell_1
[ "text_plain_output_1.png" ]
1 + 1
code
311188/cell_3
[ "text_plain_output_1.png" ]
20 + 30
code
311188/cell_5
[ "image_output_1.png" ]
import matplotlib.pyplot as plt import numpy as np import matplotlib.pyplot as plt import numpy as np t = np.arange(0.0, 2.0, 0.01) s = np.sin(2 * np.pi * t) plt.plot(t, s) plt.xlabel('time (s)') plt.ylabel('voltage (mV)') plt.title('About as simple as it gets, folks') plt.grid(True) plt.savefig('test.png') plt.show()
code
309683/cell_4
[ "image_output_1.png" ]
import matplotlib.pyplot as plt import networkx as nx import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) import numpy as np import pandas as pd import networkx as nx import matplotlib.pyplot as plt from subprocess import check_output comments = pd.read_csv('../input/comment.csv') likes = pd.read_csv('../input/like.csv') members = pd.read_csv('../input/member.csv') posts = pd.read_csv('../input/post.csv') likeResponse = pd.merge(likes.loc[likes['gid'] == 117291968282998], posts.loc[posts['gid'] == 117291968282998, ['pid', 'name']], left_on='pid', right_on='pid') result = likeResponse.groupby(['name_y', 'name_x'])['response'].count() finalResult = pd.DataFrame(result.index.values, columns=['NameCombo']) finalResult['Weight'] = result.values finalResult['From'] = finalResult['NameCombo'].map(lambda x: x[0]) finalResult['To'] = finalResult['NameCombo'].map(lambda x: x[1]) del finalResult['NameCombo'] g = nx.Graph() g.add_edges_from([(row['From'], row['To']) for index, row in finalResult.iterrows()]) d = nx.degree(g) spring_pos = nx.spring_layout(g) plt.axis('off') plt.clf() g.number_of_nodes() spring_pos = nx.spring_layout(g, scale=2) nx.draw(g, spring_pos, with_labels=False, nodelist=d.keys(), node_size=[v * 5 for v in d.values()])
code
309683/cell_3
[ "text_plain_output_1.png" ]
import matplotlib.pyplot as plt import networkx as nx import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) import numpy as np import pandas as pd import networkx as nx import matplotlib.pyplot as plt from subprocess import check_output comments = pd.read_csv('../input/comment.csv') likes = pd.read_csv('../input/like.csv') members = pd.read_csv('../input/member.csv') posts = pd.read_csv('../input/post.csv') likeResponse = pd.merge(likes.loc[likes['gid'] == 117291968282998], posts.loc[posts['gid'] == 117291968282998, ['pid', 'name']], left_on='pid', right_on='pid') result = likeResponse.groupby(['name_y', 'name_x'])['response'].count() finalResult = pd.DataFrame(result.index.values, columns=['NameCombo']) finalResult['Weight'] = result.values finalResult['From'] = finalResult['NameCombo'].map(lambda x: x[0]) finalResult['To'] = finalResult['NameCombo'].map(lambda x: x[1]) del finalResult['NameCombo'] g = nx.Graph() plt.figure() g.add_edges_from([(row['From'], row['To']) for index, row in finalResult.iterrows()]) d = nx.degree(g) spring_pos = nx.spring_layout(g) plt.axis('off') nx.draw_networkx(g, spring_pos, with_labels=False, nodelist=d.keys(), node_size=[v * 10 for v in d.values()]) plt.savefig('LIKE_PLOT_GROUP1.png') plt.clf()
code
309683/cell_5
[ "text_plain_output_1.png" ]
import matplotlib.pyplot as plt import networkx as nx import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) import numpy as np import pandas as pd import networkx as nx import matplotlib.pyplot as plt from subprocess import check_output comments = pd.read_csv('../input/comment.csv') likes = pd.read_csv('../input/like.csv') members = pd.read_csv('../input/member.csv') posts = pd.read_csv('../input/post.csv') likeResponse = pd.merge(likes.loc[likes['gid'] == 117291968282998], posts.loc[posts['gid'] == 117291968282998, ['pid', 'name']], left_on='pid', right_on='pid') result = likeResponse.groupby(['name_y', 'name_x'])['response'].count() finalResult = pd.DataFrame(result.index.values, columns=['NameCombo']) finalResult['Weight'] = result.values finalResult['From'] = finalResult['NameCombo'].map(lambda x: x[0]) finalResult['To'] = finalResult['NameCombo'].map(lambda x: x[1]) del finalResult['NameCombo'] g = nx.Graph() g.add_edges_from([(row['From'], row['To']) for index, row in finalResult.iterrows()]) d = nx.degree(g) spring_pos = nx.spring_layout(g) plt.axis('off') plt.clf() f = open('g.json', 'w') f.write('{"nodes":[') str1 = '' for i in finalResult['From'].unique(): str1 += '{"name":"' + str(i) + '","group":' + str(1) + '},' f.write(str1[:-1]) f.write('],"links":[') str1 = '' for i in range(len(finalResult)): str1 += '{"source":' + str(finalResult['From'][i]) + ',"target":' + str(finalResult['To'][i]) + ',"value":' + str(finalResult['Weight'][i]) + '},' f.write(str1[:-1]) f.write(']}') f.close h1 = '\n<!DOCTYPE html>\n<meta charset="utf-8">\n<style>\n.link {stroke: #ccc;}\n.node text {pointer-events: none; font: 10px sans-serif;}\n</style>\n<body>\n<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>\n<script>\nvar width = 800, height = 800;\nvar color = d3.scale.category20();\nvar force = d3.layout.force()\n .charge(-120)\n .linkDistance(80)\n .size([width, height]);\nvar svg = d3.select("body").append("svg")\n .attr("width", width)\n .attr("height", height);\nd3.json("g.json", function(error, graph) {\n if (error) throw error;\n\tforce.nodes(graph.nodes)\n\t .links(graph.links)\n\t .start();\n\tvar link = svg.selectAll(".link")\n\t .data(graph.links)\n\t .enter().append("line")\n\t .attr("class", "link")\n\t .style("stroke-width", function (d) {return Math.sqrt(d.value);});\n\tvar node = svg.selectAll(".node")\n\t .data(graph.nodes)\n\t .enter().append("g")\n\t .attr("class", "node")\n\t .call(force.drag);\n\tnode.append("circle")\n\t .attr("r", 8)\n\t .style("fill", function (d) {return color(d.group);})\n\tnode.append("text")\n\t .attr("dx", 10)\n\t .attr("dy", ".35em")\n\t .text(function(d) { return d.name });\n\tforce.on("tick", function () {\n\t link.attr("x1", function (d) {return d.source.x;})\n\t\t.attr("y1", function (d) {return d.source.y;})\n\t\t.attr("x2", function (d) {return d.target.x;})\n\t\t.attr("y2", function (d) {return d.target.y;});\n\t d3.selectAll("circle").attr("cx", function (d) {return d.x;})\n\t\t.attr("cy", function (d) {return d.y;});\n\t d3.selectAll("text").attr("x", function (d) {return d.x;})\n\t\t.attr("y", function (d) {return d.y;});\n });\n});\n</script>\n' f = open('output.html', 'w') f.write(h1) f.close
code
README.md exists but content is empty.
Downloads last month
18