Need Help in Python

 

NEED HELP IN PYTHON.

{
“cells”: [
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“* In this assignment, you will investigate UFO data over the last century to gain some insight.\n”,
“* Please use all the techniques we have learned in the class to preprocesss/clean the dataset

ufo_sightings_large.csv

. \n”,
“* After the dataset is preprocessed, please split the dataset into training sets and test sets\n”,
“* Fit KNN to the training sets. \n”,
“* Print the score of KNN on the test sets”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## 1. Import dataset \”ufo_sightings_large.csv\” in pandas”
]
},
{
“cell_type”: “code”,
“execution_count”: 3,
“metadata”: {
“collapsed”: true
},
“outputs”: [],
“source”: []
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## 2. Checking column types & Converting Column types \n”,
“Take a look at the UFO dataset’s column types using the dtypes attribute. Please convert the column types to the proper types.\n”,
“For example, the date column, which can be transformed into the datetime type. \n”,
“That will make our feature engineering efforts easier later on.”
]
},
{
“cell_type”: “code”,
“execution_count”: null,
“metadata”: {
“collapsed”: true
},
“outputs”: [],
“source”: []
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## 3. Dropping missing data \n”,
“Let’s remove some of the rows where certain columns have missing values. ”
]
},
{
“cell_type”: “code”,
“execution_count”: null,
“metadata”: {
“collapsed”: true
},
“outputs”: [],
“source”: []
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## 4. Extracting numbers from strings \n”,
“The length_of_time column in the UFO dataset is a text field that has the number of \n”,
“minutes within the string. \n”,
“Here, you’ll extract that number from that text field using regular expressions.”
]
},
{
“cell_type”: “code”,
“execution_count”: null,
“metadata”: {
“collapsed”: true
},
“outputs”: [],
“source”: []
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## 5. Identifying features for standardization \n”,
“In this section, you’ll investigate the variance of columns in the UFO dataset to \n”,
“determine which features should be standardized. You can log normlize the high variance column.”
]
},
{
“cell_type”: “code”,
“execution_count”: null,
“metadata”: {
“collapsed”: true
},
“outputs”: [],
“source”: []
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## 6. Encoding categorical variables\n”,
“There are couple of columns in the UFO dataset that need to be encoded before they can be \n”,
“modeled through scikit-learn. \n”,
“You’ll do that transformation here, using both binary and one-hot encoding methods.”
]
},
{
“cell_type”: “code”,
“execution_count”: null,
“metadata”: {
“collapsed”: true
},
“outputs”: [],
“source”: []
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## 7. Text vectorization \n”,
“Let’s transform the desc column in the UFO dataset into tf/idf vectors, \n”,
“since there’s likely something we can learn from this field.”
]
},
{
“cell_type”: “code”,
“execution_count”: null,
“metadata”: {
“collapsed”: true
},
“outputs”: [],
“source”: []
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## 8. Selecting the ideal dataset \n”,
“Let’s get rid of some of the unnecessary features. ”
]
},
{
“cell_type”: “code”,
“execution_count”: null,
“metadata”: {
“collapsed”: true
},
“outputs”: [],
“source”: []
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## 9. Split the X and y using train_test_split, setting stratify = y ”
]
},
{
“cell_type”: “code”,
“execution_count”: 9,
“metadata”: {
“collapsed”: true
},
“outputs”: [],
“source”: [
“X = ufo.drop([\”type\”],axis = 1)\n”,
“y = ufo[\”type\”].astype(str)\n”,
“\n”,
“\n”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“## 10. Fit knn to the training sets and print the score of knn on the test sets ”
]
},
{
“cell_type”: “code”,
“execution_count”: 1,
“metadata”: {},
“outputs”: [
{
“ename”: “NameError”,
“evalue”: “name ‘train_X’ is not defined”,
“output_type”: “error”,
“traceback”: [
“\u001b[1;31m—————————————————————————\u001b[0m”,
“\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)”,
“\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[0mknn\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mKNeighborsClassifier\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mn_neighbors\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[1;31m# Fit knn to the training sets\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m—-> 4\u001b[1;33m \u001b[0mknn\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtrain_X\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtrain_y\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 5\u001b[0m \u001b[1;31m# Print the score of knn on the test sets\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mknn\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mscore\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtest_X\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtest_y\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n”,
“\u001b[1;31mNameError\u001b[0m: name ‘train_X’ is not defined”
]
}
],
“source”: [
“from sklearn.neighbors import KNeighborsClassifier\n”,
“knn = KNeighborsClassifier(n_neighbors=5)\n”,
“# Fit knn to the training sets\n”,
“knn.fit(train_X, train_y)\n”,
“# Print the score of knn on the test sets\n”,
“print(knn.score(test_X, test_y))”
]
},
{
“cell_type”: “code”,
“execution_count”: null,
“metadata”: {},
“outputs”: [],
“source”: []
}
],
“metadata”: {
“kernelspec”: {
“display_name”: “Python 3 (ipykernel)”,
“language”: “python”,
“name”: “python3”
},
“language_info”: {
“codemirror_mode”: {
“name”: “ipython”,
“version”: 3
},
“file_extension”: “.py”,
“mimetype”: “text/x-python”,
“name”: “python”,
“nbconvert_exporter”: “python”,
“pygments_lexer”: “ipython3”,
“version”: “3.9.7”
}
},
“nbformat”: 4,
“nbformat_minor”: 2
}

Get 20% Discount on This Paper
Pages (550 words)
Approximate price: -

Try it now!

Get 20% Discount on This Paper

We'll send you the first draft for approval by at
Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

Paper Helper has assembled a team of highly skilled writers with diverse experience in the online writing circles. Our aim is to become a one stop shop for all your Academic/ online writing. Check out below our amazing service!

Essays

Essay Writing Services

At Paper Helper, we prioritize on all aspects that creates a good grade such as impeccable grammar, proper structure, zero-plagiarism, and conformance to guidelines. The principal purpose of essay writing is to present the author's evaluation concerning a singular subject about which they have made. Since Professionalism is the mother of every success, try our team of experienced writers in helping you complete your essays and other assignments.

Admissions

Admission Papers

You have been trying to join that prestigious institution you long yearned for, but the hurdle of an admission essay has become a stumbling block. We have your back, with our proven team that has gained invaluable experience over time, your chance of joining that institution is now! Just let us work on that essay.How do you write an admission essay? How do you begin the essay? For answers, try Quality Custom Writers Now!

Editing

Editing and Proofreading

Regardless of whether you're pleased with your composing abilities, it's never an impractical notion to have a second eye go through your work. The best editing services leaves no mistake untouched. We recognize the stuff needed to polish up a writing; as a component of our editing and proofreading, we'll change and refine your write up to guarantee it's amazing, and blunder free. Our group of expert editors will examine your work, giving an impeccable touch of English while ensuring your punctuation and sentence structures are top-notch.

Coursework

Technical papers

We pride ourselves in having a team of clinical writers. The stringent and rigorous vetting process ensures that only the best persons for job. We hire qualified PhD and MA writers only. We equally offer our team of writers bonuses and incentives to motivate their working spirit in terms of delivering original, unique, and informative content. They are our resources drawn from diverse fields. Therefore your technical paper is in the right hands. Every paper is assessed and only the writers with the technical know-how in that field get to work on it.

Coursework

College Essay Writing

If all along you have been looking for a trustworthy college essay service provider that provides superb academic papers at reasonable prices, then be glad that you search has ended with us. We are your best choice! Get high-quality college essay writing from our magnificent team of knowledgeable and dedicated writers right now!

Coursework

Quality Assignment/Homework Help

We give the students premium quality assignments, without alarming them with plagiarism and referencing issues. We ensure that the assignments stick to the rules given by the tutors. We are specific about the deadlines you give us. We assure you that you will get your papers well in advance, knowing that you will review and return it if there are any changes, which should be incorporated.

togel macau togel terbesar bocoran admin jarwo data macau