Reputation: 317
I'm using IPython's UI with appropriate libraries (Anaconda, pandas, numpy)
I've declared a pandas object df, I've changed it so that the first column is the desired value I wish to predict but my code still continues to stop at line 10. Line 11 does not run. Instead, the Terminal IPython window quits and displays this error:
~/anaconda/bin/python.app: line 3: 45581 Killed: 9 ~/anaconda/python.app/Contents/MacOS/python "$@"
Start of code
In [1]: import pandas as pd
In [2]: import numpy as np
In [3]: df = pd.read_csv('train.csv', header=0)
In [4]: cols = list(df)
In [5]: cols.insert(0, cols.pop(cols.index('Cover_Type'))) %Cover type is column I wanted to bring to column position 1 or value I'm predicting
In [6]: cols
In [7]: df = df.ix[:, cols]
In [8]: df
In [9]: forest = RandomForestClassifier(n_estimators = 100)
In [10]: forest = forest.fit(train_data[0::,1::],train_data[0::,0])
In [11]: output = forest.predict(test_data)
In [12]: train_data = df.values
In [13]: train_data
Upvotes: 2
Views: 306
Reputation: 2202
You are using train Data in line 10 which is not available. You assign it later on.
First assign train data , then use it in forest.fit
Upvotes: 1