Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python Neural network

Raja_yousuf

New Coder
Can anyone help me with the error when I use neural network:
<p>
import pandas as pd
from sklearn.naive_bayes import MultinomialNB
from sklearn.neural_network import MLPClassifier
from sklearn import tree
from sklearn.model_selection import train_test_split #to avoid overfitting
from sklearn import metrics
#import data
df = pd.read_csv("https://www.dropbox.com/s/0k5rzco88jflks4/group 7 6308 - employment new.csv?dl=1")


#features and target
features = ['Population','Gdp','Gdp growth','Inflation','Gas Price']
target = 'Employment'
#X and y data
x = df[features]
y = df[target]
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.3,random_state=1)
#Model
model = MLPClassifier()
model.fit(x_train, y_train)
#predict
y_test_pred = model.predict(x_test)
#performance
print("coefficients: ", model.coef_)
print("constant term: ", model.intercept_)
print(metrics.r2_score(y_test, y_test_pred))</p>
 

Latest posts

Buy us a coffee!

Back
Top Bottom