Hello everyone. I am trying to create a flood prediction map by using the Naive Bayes algorithm. The types of data which exported raster data is ASCII. I used this data for Random forest algorithm but I don't know how can I implement this data in Naive Bayes algorithm.

Note: When ı used the same technique, I get an error :  AttributeError: 'numpy.ndarray' object has no attribute 'predict'

This is an example which belongs to RF algorithm:

slopedata = numpy.genfromtxt('data_name.txt')
slope = numpy.reshape(slopedata,250*433) Oct 5 54 views

## 1 answer to this question.

Hi@Ogun,

The Numpy module doesn't have a predict attribute. So you need to check your code. If you are facing issues with your code then paste your complete code here. answered Oct 5 by
• 79,930 points
These are my Random forest codes. I used an RF classification for comparing past and future data which was edited from raster data as ASCII data type.  I am trying to make a similar map by using any other algorithm, but i don't know it works or not with the same data type.

train_x = numpy.array([elevation, soil, slope, wetness, annualp]) (past data)

train_x60 = numpy.array([elevation, soil, slope, wetness, annualp60]) (future data)

train_y = floodwatch

clf = ensemble.RandomForestClassifier(n_estimators=100, bootstrap=True, oob_score=True)
clf = clf.fit(train_x, train_y)
print ('OOB score = ', clf.oob_score_)

Ytrain = clf.predict(train_x60)
Ytrain2 = numpy.reshape(Ytrain,[250,433])
numpy.savetxt('rslt_IP_60A.txt',Ytrain2)

To Naive Bayes algorithm

x = numpy.array([elevation, soil, slope, wetness, annualp]).T
y = floodwatch

x_train, x_test, y_train, y_test = train_test_split(x, y,)
GausNB = GaussianNB()
GausNB.fit(x_train, y_train)
print(GausNB)

y_expect = y_test
y_pred = GausNB.predict(x_test)
print(accuracy_score(y_expect, y_pred))

When I used same future data or different future data ı obtain same map. Because of that, I am not sure the ASCII data proper for these algorithm.

Hi@Ogun,

The first thing that you need to check your datatype. So every one step tries to check the datatype. And match that with your requirement.

## What is greedy approach in Decision tree algorithm?

“Greedy Approach is based on the concept ...READ MORE

## Attribute selection in Decision tree Algorithm

If you have a dataset that consists ...READ MORE

## Example to run KNN algorithm using python

Have a look at this one: from sklearn.datasets ...READ MORE

## What is the process involved in machine Learning?

Discussing this on a high level, these ...READ MORE

## Reliability of Bayes Theorem

Baye’s theorem is useful for determining the ...READ MORE

## how do i change string to a list?

suppose you have a string with a ...READ MORE

## how can i randomly select items from a list?

You can also use the random library's ...READ MORE

+1 vote

## how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE