Posts

Showing posts from October, 2017

Machine Learning with Python example

import pandas as pd import pylab as pl import numpy as np train=pd.read_csv('https://raw.githubusercontent.com/yhat/DataGotham2013/master/notebooks/data/credit-data-trainingset.csv') test=pd.read_csv('https://raw.githubusercontent.com/yhat/DataGotham2013/master/notebooks/data/credit-data-testset.csv') pd.value_counts(train.serious_dlqin2yrs).plot(kind='bar') pd.value_counts(train.number_of_dependents).plot(kind='bar') pd.crosstab(train.serious_dlqin2yrs,train.number_of_times90_days_late) test.head() from sklearn.linear_model import LogisticRegression from sklearn.neighbors import KNeighborsClassifier from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier from sklearn.svm import SVC featuresTest = ['revolving_utilization_of_unsecured_lines', 'debt_ratio', 'monthly_income', 'age', 'number_of_times90_days_late'] featuresTrain = ['RevolvingUtilizationOfUnsecuredLines', ...

Python Lessons 1-11

Untitled In [6]: # Exercise 1: A Good First Program print ( "Hello World!" ) print ( "Hello Again" ) print ( "I like typing this." ) print ( "This is fun." ) print ( 'Yay! Printing.' ) print ( "I'd much rather you 'not'." ) print ( 'I "said" do not touch this.' ) # Exercise 2: Comments and Pound Characters # A comment, this is so you can read your program later. # Anything after the # is ignored by python. print ( "I could have code like this." ) # and the comment after is ignored # You can also use a comment to "disable" or comment out a piece of code: # print "This won't run." print ( "This will run." ) # Exercise 3: Numbers and Math print ( "I will now count my chickens:" ) print ( "Hens" , 25 + 30 / 6 ) print ( "Rooster...