Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

gen_data.py 662 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  1. import numpy as np
  2. import pandas as pd
  3. import argparse
  4. parser = argparse.ArgumentParser()
  5. parser.add_argument('--data', '-d', help='specify data amount')
  6. parser.add_argument('--coef', '-c', help='specify data amount')
  7. args = parser.parse_args()
  8. if args.data:
  9. n = int(args.data)
  10. else:
  11. n = 1000
  12. if args.coef:
  13. coef = args.coef.split(',')
  14. coef = [int(x) for x in coef]
  15. else:
  16. coef = [1,2,3,4]
  17. X = np.random.randn(n,4)
  18. noise = np.random.randn(n)/20
  19. y = np.sum(X * coef, axis=1) + noise
  20. df = pd.DataFrame(X, columns=['x1', 'x2', 'x3', 'x4'])
  21. df['target'] = y
  22. for col in df.columns:
  23. df[col] = "'"+df[col].astype(str)+"'"
  24. df.to_csv('data.csv')
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...